diff --git a/lang/en.json b/lang/en.json index ca2dd23..115403f 100644 --- a/lang/en.json +++ b/lang/en.json @@ -39,6 +39,11 @@ "ToursContent": "
Tu t'en sors pas si mal ! Moi je vais te laisser là, mais si tu as d'autres questions, tu peux venir me trouver. Si ca concerne la mécanique, inscris-toi dans notre groupe de parole, par là Totem Foundry Discord. Sinon, tu peux rejoindre la place centrale par ici Vermine Discord
Enjoy!
" } }, + "ATTITUDES": { + "offensive": { "name": "Offensif"}, + "active": { "name": "Actif"}, + "passive": { "name": "Passif"} + }, "IDENTITY": { "name": "Nom", diff --git a/module/system/fight.mjs b/module/system/fight.mjs index fff8d46..16f61f7 100644 --- a/module/system/fight.mjs +++ b/module/system/fight.mjs @@ -421,4 +421,75 @@ export class VermineCombat extends Combat { } super._onDelete()*/ } +} + +export class VermineCombatTracker extends CombatTracker { + + get template() { + return "systems/vermine2047/templates/combat-tracker.hbs"; + } + + async getData(options) { + const context = await super.getData(options); + + if (!context.hasCombat) { + return context; + } + + for (let [i, combatant] of context.combat.turns.entries()) { + context.turns[i].hasActed = combatant.getFlag("world", "hasActed"); + context.turns[i].isPlayer = combatant.actor.type == "player"; + context.turns[i].isNpc = combatant.actor.type == "npc"; + } + return context; + } + + /* -------------------------------------------- */ + get template() { + return "systems/gods-system/templates/combat/tracker.hbs"; +} + +async getData(options) { + const context = await super.getData(options); + + if (!context.hasCombat) { + return context; + } + + for (let [i, combatant] of context.combat.turns.entries()) { + context.turns[i].attitude = combatant.getFlag("world", "attitude"); + context.turns[i].isPlayer = combatant.actor.type == "character"; + context.turns[i].isNpc = combatant.actor.type == "npc"; + context.turns[i].isCreature = combatant.actor.type == "creature"; + } + return context; +} + +activateListeners(html) { + super.activateListeners(html); + + html.find(".status").click(this._setStatut.bind(this)); +} + +/** + * @description Use to put an attitude to an actor + * @param {*} event + */ +async _setStatut(event) { + event.preventDefault(); + event.stopPropagation(); + const btn = event.currentTarget; + const li = btn.closest(".combatant"); + const combat = this.viewed; + const combatant = combat.combatants.get(li.dataset.combatantId); + + if ($(btn).hasClass('offensive')) + await combatant.setFlag("world", "attitude", "offensive"); + else if ($(btn).hasClass('active')) + await combatant.setFlag("world", "attitude", "active"); + else if ($(btn).hasClass('passive')) + await combatant.setFlag("world", "attitude", "passive"); + else + await combatant.setFlag("world", "attitude", null); +} } \ No newline at end of file diff --git a/module/system/handlebars-manager.mjs b/module/system/handlebars-manager.mjs index 535e3a3..8bda001 100644 --- a/module/system/handlebars-manager.mjs +++ b/module/system/handlebars-manager.mjs @@ -46,12 +46,18 @@ export const registerHandlebarsHelpers = function () { return game.i18n.localize(arrayLabel +"."+objectLabel+".name"); }); - // return skill level information - Handlebars.registerHelper('skillLevel', function (property, level, options) { - if (level < 1 || level > 5) - return ""; - let levelData = CONFIG.VERMINE.SkillLevels[level]; - - return (levelData !== undefined) ? levelData[property] : ""; - }); + // return skill level information + Handlebars.registerHelper('skillLevel', function (property, level, options) { + if (level < 1 || level > 5) + return ""; + let levelData = CONFIG.VERMINE.SkillLevels[level]; + + return (levelData !== undefined) ? levelData[property] : ""; + }); + + Handlebars.registerHelper('getCombatTrackerColor', function (isPlayer, isNpc) { + if (isPlayer) return "player"; + if (isNpc) return "npc"; + }); + } \ No newline at end of file diff --git a/module/vermine2047.mjs b/module/vermine2047.mjs index ac713ef..ff904db 100644 --- a/module/vermine2047.mjs +++ b/module/vermine2047.mjs @@ -13,7 +13,7 @@ import { VermineItem } from "./documents/item.mjs"; import { VermineItemSheet } from "./sheets/item-sheet.mjs"; import { VermineRoll } from "./system/roll.mjs"; -import { VermineCombat } from "./system/fight.mjs"; +import { VermineCombat, VermineCombatTracker } from "./system/fight.mjs"; // Import helper/utility classes and constants. import { preloadHandlebarsTemplates, registerHandlebarsHelpers } from "./system/handlebars-manager.mjs"; @@ -42,13 +42,14 @@ Hooks.once('init', async function() { * @type {String} */ CONFIG.Combat.initiative = { - formula: "1d10 + @abilities.dex.mod", + formula: "(@abilities.reflexes.value + @skills.alertness.value)d10cs>=7", decimals: 2 }; // Define custom Document classes CONFIG.Actor.documentClass = VermineActor; CONFIG.Item.documentClass = VermineItem; + CONFIG.ui.combat = VermineCombatTracker; // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); diff --git a/templates/combat-tracker.hbs b/templates/combat-tracker.hbs new file mode 100644 index 0000000..44ab176 --- /dev/null +++ b/templates/combat-tracker.hbs @@ -0,0 +1,132 @@ +