Button um Kampf beizutreten #61

Merged
Byroks merged 1 commits from #60-join-combat into develop 2024-02-21 22:29:50 +01:00
5 changed files with 72 additions and 27 deletions
Showing only changes of commit 02e8097289 - Show all commits

View File

@ -17,7 +17,11 @@
"midgard5.phase-movement": "Bewegungsphase", "midgard5.phase-movement": "Bewegungsphase",
"midgard5.no-encounter": "Kein Kampf", "midgard5.no-encounter": "Kein Kampf",
"midgard5.encounter-not-started": "Kein aktiver 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-duration": "Dauer",
"midgard5.time-round": "Runde(n)", "midgard5.time-round": "Runde(n)",
@ -92,7 +96,6 @@
"midgard5.kampfkuenste": "Kampfkünste", "midgard5.kampfkuenste": "Kampfkünste",
"midgard5.combat": "Kampf", "midgard5.combat": "Kampf",
"midgard5.actor-name": "Figur", "midgard5.actor-name": "Figur",
"midgard5.level": "Grad", "midgard5.level": "Grad",
"midgard5.class": "Typ", "midgard5.class": "Typ",
@ -260,7 +263,6 @@
"midgard5.itemsInContainers": "Gegenstände in Aufbewahrung", "midgard5.itemsInContainers": "Gegenstände in Aufbewahrung",
"midgard5.allItems": "Alle Gegenstände", "midgard5.allItems": "Alle Gegenstände",
"midgard5.pw": "Prüfwurf", "midgard5.pw": "Prüfwurf",
"midgard5.attack": "Angriff", "midgard5.attack": "Angriff",
"midgard5.damage": "Schaden", "midgard5.damage": "Schaden",

View File

@ -269,27 +269,6 @@ export class M5Roll {
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.resistanceMind")); 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) { static resistanceBody(actor: any) {
const rollData = actor.getRollData() as M5RollData; const rollData = actor.getRollData() as M5RollData;
rollData.i = { 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); 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 // Drag & Drop
const dragDrop = new DragDrop({ const dragDrop = new DragDrop({
dragSelector: ".items-list .item", dragSelector: ".items-list .item",

View File

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

View File

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