Button um Kampf beizutreten

Changes:
 + Button um Kampf beizutreten
 + buttons um initiative zu verändern für Fernangriffe und Zauber
This commit is contained in:
Byroks 2024-02-21 18:45:34 +01:00
parent c2aa466ce1
commit 02e8097289
5 changed files with 72 additions and 27 deletions

View File

@ -17,7 +17,11 @@
"midgard5.phase-movement": "Bewegungsphase",
"midgard5.no-encounter": "Kein Kampf",
"midgard5.encounter-not-started": "Kein aktiver Kampf",
"midgard5.initiative": "Initiative",
"midgard5.initiative": "Handlungsrang",
"midgard5.combat-join": "Kampf Beitreten/Handlungsrang zurücksetzen",
"midgard5.combat-ranged": "Fernangriff",
"midgard5.combat-spell": "Zaubern (10 Sec)",
"midgard5.time-duration": "Dauer",
"midgard5.time-round": "Runde(n)",
@ -92,7 +96,6 @@
"midgard5.kampfkuenste": "Kampfkünste",
"midgard5.combat": "Kampf",
"midgard5.actor-name": "Figur",
"midgard5.level": "Grad",
"midgard5.class": "Typ",
@ -260,7 +263,6 @@
"midgard5.itemsInContainers": "Gegenstände in Aufbewahrung",
"midgard5.allItems": "Alle Gegenstände",
"midgard5.pw": "Prüfwurf",
"midgard5.attack": "Angriff",
"midgard5.damage": "Schaden",

View File

@ -269,27 +269,6 @@ export class M5Roll {
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.resistanceMind"));
}
static async initativeRoll(actor: any) {
let newInitiative; // the initiative value for the combatant
// ...
// The intnitiative value is calculated here
// ...
let combatant = game["combat"].getCombatantByActor(actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: actor._id }]);
combatant = game["combat"].getCombatantByActor(actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
static resistanceBody(actor: any) {
const rollData = actor.getRollData() as M5RollData;
rollData.i = {

View File

@ -363,6 +363,57 @@ export default class M5CharacterSheet extends ActorSheet {
character.createItem((game as Game).i18n.localize("TYPES.Item.effect"), M5ItemType.EFFECT);
});
html.find(".join-combat").on("click", async (event) => {
if (!!game["combat"]) {
let combatant = game["combat"].getCombatantByActor(this.actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
combatant = game["combat"].getCombatantByActor(this.actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: this.actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
});
html.find(".ranged-combat").on("click", async (event) => {
if (!!game["combat"]) {
let combatant = game["combat"].getCombatantByActor(this.actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
combatant = game["combat"].getCombatantByActor(this.actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: 0.01 * this.actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
});
html.find(".spell-combat").on("click", async (event) => {
if (!!game["combat"]) {
let combatant = game["combat"].getCombatantByActor(this.actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
combatant = game["combat"].getCombatantByActor(this.actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: 0.001 * this.actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
});
// Drag & Drop
const dragDrop = new DragDrop({
dragSelector: ".items-list .item",

View File

@ -225,6 +225,10 @@
height: 1rem;
}
.wide-button {
margin: 0.25rem 0;
}
.learn-button {
padding: 0;
margin: 0;

View File

@ -1,6 +1,6 @@
<div class="flexbox">
<div class="flexcolumn-1">
<div class="flexcolumn-2">
<div class="flexpart">
<div class="flexpart-header"><img src="icons/magic/time/arrows-circling-pink.webp" class="flexpart-icon">{{localize "midgard5.calculated-values"}}</div>
<table>
@ -8,8 +8,8 @@
<tr>
<td>{{localize "midgard5.movementRange"}}</td>
<td class="fixed-value">{{data.calc.stats.movement.value}}</td>
<td></td>
<td class="fixed-value"></td>
<td>{{localize "midgard5.initiative"}}</td>
<td class="fixed-value"><a class="join-combat">{{data.calc.attributes.gw.value}}</a></td>
</tr>
<td>{{localize "midgard5.defense"}}</td>
<td class="fixed-value">{{data.calc.stats.defense.value}}</td>
@ -26,6 +26,15 @@
</div>
</div>
<div class="flexcolumn-2">
<div class="flexpart" style="padding: 0 0.5rem;">
<div class="flexpart-header">{{localize "midgard5.initiative"}}</div>
<button class="wide-button join-combat">{{localize "midgard5.combat-join"}}</button>
<button class="wide-button ranged-combat">{{localize "midgard5.combat-ranged"}}</button>
<button class="wide-button spell-combat">{{localize "midgard5.combat-spell"}}</button>
</div>
</div>
<div class="flexcolumn-2">
<div class="flexpart">
<div class="flexpart-header"><img src="icons/skills/melee/hand-grip-sword-white-brown.webp" class="flexpart-icon">{{localize "midgard5.attack"}}</div>