From 02e8097289ca278c0035ffd3102cfb7672dbbb56 Mon Sep 17 00:00:00 2001 From: Byroks Date: Wed, 21 Feb 2024 18:45:34 +0100 Subject: [PATCH] Button um Kampf beizutreten MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: + Button um Kampf beizutreten + buttons um initiative zu verändern für Fernangriffe und Zauber --- lang/de.json | 8 ++-- source/module/rolls/M5Roll.ts | 21 ---------- source/module/sheets/M5CharacterSheet.ts | 51 ++++++++++++++++++++++++ source/style/Character-sheet.less | 4 ++ templates/sheets/character/combat.hbs | 15 +++++-- 5 files changed, 72 insertions(+), 27 deletions(-) diff --git a/lang/de.json b/lang/de.json index 622128d..0993551 100644 --- a/lang/de.json +++ b/lang/de.json @@ -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", diff --git a/source/module/rolls/M5Roll.ts b/source/module/rolls/M5Roll.ts index f0b2565..9a5f316 100644 --- a/source/module/rolls/M5Roll.ts +++ b/source/module/rolls/M5Roll.ts @@ -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 = { diff --git a/source/module/sheets/M5CharacterSheet.ts b/source/module/sheets/M5CharacterSheet.ts index d2ffa4c..9faf8dd 100644 --- a/source/module/sheets/M5CharacterSheet.ts +++ b/source/module/sheets/M5CharacterSheet.ts @@ -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", diff --git a/source/style/Character-sheet.less b/source/style/Character-sheet.less index a0047fd..68c3dcc 100644 --- a/source/style/Character-sheet.less +++ b/source/style/Character-sheet.less @@ -225,6 +225,10 @@ height: 1rem; } + .wide-button { + margin: 0.25rem 0; + } + .learn-button { padding: 0; margin: 0; diff --git a/templates/sheets/character/combat.hbs b/templates/sheets/character/combat.hbs index 800610a..080bedf 100644 --- a/templates/sheets/character/combat.hbs +++ b/templates/sheets/character/combat.hbs @@ -1,6 +1,6 @@
-
+
{{localize "midgard5.calculated-values"}}
@@ -8,8 +8,8 @@ - - + + @@ -26,6 +26,15 @@ +
+
+
{{localize "midgard5.initiative"}}
+ + + +
+
+
{{localize "midgard5.attack"}}
{{localize "midgard5.movementRange"}} {{data.calc.stats.movement.value}}{{localize "midgard5.initiative"}}{{data.calc.attributes.gw.value}}
{{localize "midgard5.defense"}} {{data.calc.stats.defense.value}}