Function for combat phase as character info
This commit is contained in:
parent
976cd83a04
commit
64fd95c814
|
|
@ -95,10 +95,7 @@ Hooks.on("getChatLogEntryContext", function (html, options) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on("createCombatant", async function () {
|
Hooks.on("createCombatant", function () {
|
||||||
const test="Dritter Test";
|
|
||||||
console.log("Test: ", test);
|
|
||||||
await (game as Game).combat.setFlag('world', 'Test', test);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on("updateCombat", function (combat: Combat, updateData: { round: number; turn: number }, updateOptions: { advanceTime: number; direction: number }) {
|
Hooks.on("updateCombat", function (combat: Combat, updateData: { round: number; turn: number }, updateOptions: { advanceTime: number; direction: number }) {
|
||||||
|
|
@ -146,15 +143,8 @@ Hooks.on("updateCombat", function (combat: Combat, updateData: { round: number;
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on("renderCombatTracker", (combatTracker, html, context) => {
|
Hooks.on("renderCombatTracker", (combatTracker, html, context) => {
|
||||||
if (context.combat === null) {
|
handleRenderCombatTracker(combatTracker, html, context);
|
||||||
html.find("h3.encounter-title")[0].innerHTML = game["i18n"].localize("midgard5.no-encounter");
|
});
|
||||||
} else if (Math.ceil(context.round / 2) === 0) {
|
|
||||||
html.find("h3.encounter-title")[0].innerHTML = game["i18n"].localize("midgard5.encounter-not-started");
|
|
||||||
} else {
|
|
||||||
html.find("h3.encounter-title")[0].innerHTML =
|
|
||||||
(context.round % 2 == 1 ? game["i18n"].localize("midgard5.phase-movement") : game["i18n"].localize("midgard5.phase-action")) + " " + Math.ceil(context.round / 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Hooks.once("ready", () => {
|
Hooks.once("ready", () => {
|
||||||
Logger.ok("Template module is now ready.");
|
Logger.ok("Template module is now ready.");
|
||||||
|
|
@ -207,3 +197,28 @@ function limitHeal(heal: number, current: number, max: number): number {
|
||||||
}
|
}
|
||||||
return heal;
|
return heal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleRenderCombatTracker(combatTracker, html, context) {
|
||||||
|
let combatPhase = -1;
|
||||||
|
if (context.combat === null) {
|
||||||
|
combatPhase = 0;
|
||||||
|
html.find("h3.encounter-title")[0].innerHTML = game["i18n"].localize("midgard5.no-encounter");
|
||||||
|
} else if (Math.ceil(context.round / 2) === 0) {
|
||||||
|
combatPhase = 1;
|
||||||
|
html.find("h3.encounter-title")[0].innerHTML = game["i18n"].localize("midgard5.encounter-not-started");
|
||||||
|
} else if (context.round % 2 == 1) {
|
||||||
|
combatPhase = 2;
|
||||||
|
html.find("h3.encounter-title")[0].innerHTML = game["i18n"].localize("midgard5.phase-movement");
|
||||||
|
} else {
|
||||||
|
combatPhase = 3;
|
||||||
|
html.find("h3.encounter-title")[0].innerHTML = game["i18n"].localize("midgard5.phase-action") + " " + Math.ceil(context.round / 2);
|
||||||
|
}
|
||||||
|
console.log("Combat Phase: ", combatPhase);
|
||||||
|
context.combat?.setFlag('world', 'combatPhase', combatPhase);
|
||||||
|
|
||||||
|
for (const key in context.combat?.combatants.contents) {
|
||||||
|
let actorId = context.combat?.combatants.contents[key].actorId;
|
||||||
|
let actor = (game as Game).actors.get(actorId);
|
||||||
|
actor.render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -170,6 +170,7 @@ export interface M5CharacterCalculatedData {
|
||||||
reason: string;
|
reason: string;
|
||||||
};
|
};
|
||||||
group: string;
|
group: string;
|
||||||
|
combatPhase: number;
|
||||||
movement: number;
|
movement: number;
|
||||||
attributes: {
|
attributes: {
|
||||||
st: M5AttributeCalculated;
|
st: M5AttributeCalculated;
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ export class M5Character extends Actor {
|
||||||
ret.initiative = M5Character.initiativeFromAnfuehren(data.calc.skills?.general, (game as Game).i18n.localize("midgard5.anfuehren"), data.skills.general.anfuehren.fw);
|
ret.initiative = M5Character.initiativeFromAnfuehren(data.calc.skills?.general, (game as Game).i18n.localize("midgard5.anfuehren"), data.skills.general.anfuehren.fw);
|
||||||
ret.unableToAct = M5Character.unableToActFromEffect(data.calc.gear?.effects);
|
ret.unableToAct = M5Character.unableToActFromEffect(data.calc.gear?.effects);
|
||||||
ret.group = M5Character.groupFromDisposition(this);
|
ret.group = M5Character.groupFromDisposition(this);
|
||||||
|
ret.combatPhase = M5Character.combatPhaseFromEncounter(this);
|
||||||
|
|
||||||
ret.attributes.st.value = M5Character.attributeMinMax(data.attributes.st); // TODO item effects
|
ret.attributes.st.value = M5Character.attributeMinMax(data.attributes.st); // TODO item effects
|
||||||
ret.attributes.gs.value = M5Character.attributeMinMax(data.attributes.gs);
|
ret.attributes.gs.value = M5Character.attributeMinMax(data.attributes.gs);
|
||||||
|
|
@ -635,7 +636,7 @@ export class M5Character extends Actor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static groupFromDisposition(actor: any): string {
|
static groupFromDisposition(actor: any): string {
|
||||||
console.log("Group:", actor);
|
// console.log("Group:", actor);
|
||||||
let disposition:number = 0;
|
let disposition:number = 0;
|
||||||
if (actor.isToken) {
|
if (actor.isToken) {
|
||||||
disposition = actor.token.disposition;
|
disposition = actor.token.disposition;
|
||||||
|
|
@ -651,6 +652,14 @@ export class M5Character extends Actor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static combatPhaseFromEncounter(actor: any): any {
|
||||||
|
if (actor.inCombat) {
|
||||||
|
let combatPhase = (game as Game).combat.getFlag('world', 'combatPhase');
|
||||||
|
return combatPhase ? combatPhase : -1;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static readonly defenseThreshold: Array<[number, number]> = [
|
static readonly defenseThreshold: Array<[number, number]> = [
|
||||||
[30, 18],
|
[30, 18],
|
||||||
[25, 17],
|
[25, 17],
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
.midgard5 {
|
.midgard5 {
|
||||||
.flexbox {
|
.flexbox {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -16,31 +16,31 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.flexcolumn-1 {
|
.flexcolumn-1 {
|
||||||
flex-basis: 99%;
|
flex-basis: 100%;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flexcolumn-2 {
|
.flexcolumn-2 {
|
||||||
flex-basis: 49%;
|
flex-basis: 50%;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flexcolumn-3 {
|
.flexcolumn-3 {
|
||||||
flex-basis: 32%;
|
flex-basis: 33%;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flexcolumn-4 {
|
.flexcolumn-4 {
|
||||||
flex-basis: 24%;
|
flex-basis: 25%;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flexcolumn-5 {
|
.flexcolumn-5 {
|
||||||
flex-basis: 19%;
|
flex-basis: 20%;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +69,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.flexrow {
|
.flexrow {
|
||||||
align-items: center;
|
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<h3>{{localize "midgard5.combatPhases"}}</h3>
|
<h3>{{localize "midgard5.combatPhases"}}</h3>
|
||||||
<div class="flexbox">
|
<div class="flexbox flexpart">
|
||||||
<div class="flexcolumn-2 flexpart">
|
<div class="flexcolumn-2 flexpart" style="flex: 1 1 200px;">
|
||||||
<div class="flexpart-header"><img src="icons/magic/time/arrows-circling-pink.webp" class="flexpart-icon">{{localize "midgard5.initiative"}}</div>
|
<div class="flexpart-header"><img src="icons/magic/time/arrows-circling-pink.webp" class="flexpart-icon">{{localize "midgard5.initiative"}}</div>
|
||||||
<br>
|
<br>
|
||||||
<div class="flexrow">
|
<div class="flexrow">
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flexcolumn-2 flexpart">
|
<div class="flexcolumn-2 flexpart" style="flex: 1 1 200px;">
|
||||||
<div class="flexpart-header"><img src="icons/magic/time/arrows-circling-pink.webp" class="flexpart-icon">{{localize "midgard5.phase-action"}}</div>
|
<div class="flexpart-header"><img src="icons/magic/time/arrows-circling-pink.webp" class="flexpart-icon">{{localize "midgard5.phase-action"}}</div>
|
||||||
<br>
|
<br>
|
||||||
<div class="flexrow">
|
<div class="flexrow">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue