From 2394026d0ca3909e1abffd2420a027231ebb9cc8 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Thu, 14 Sep 2023 21:03:08 +0200 Subject: [PATCH] Minor changes --- modules/pegasus-actor.js | 2 +- modules/pegasus-combat.js | 47 ++++++++++++++++++++++----- system.json | 4 +-- templates/chat-generic-result.html | 9 +++++ templates/pegasus-combat-tracker.html | 5 ++- 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index a3ad121..55d70c2 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -2057,7 +2057,7 @@ export class PegasusActor extends Actor { if (statKey == 'phy' && subKey == "dmg-res") { let armors = this.getArmors() for (let armor of armors) { - rollData.armorsList.push({ label: `Armor ${armor.name}`, type: "armor", applied: false, value: armor.system.resistance }) + rollData.armorsList.push({ label: `Armor ${armor.name}`, type: "armor", applied: false, value: armor.system.resistance, adrl:armor.system.adrl }) } } if (useShield) { diff --git a/modules/pegasus-combat.js b/modules/pegasus-combat.js index 392f8c1..c69deb7 100644 --- a/modules/pegasus-combat.js +++ b/modules/pegasus-combat.js @@ -19,6 +19,11 @@ export class PegasusCombatTracker extends CombatTracker { let combatantId = $(ev.currentTarget).data("combatant-id") game.combat.revealTIC(ticNum, combatantId) }) + + html.find('.reset-npc-initiative').click(ev => { + game.combat.resetNPCInitiative() + }) + } } @@ -39,18 +44,27 @@ export class PegasusCombat extends Combat { return this; } + /* -------------------------------------------- */ + async resetNPCInitiative() { + for(let c of this.combatants) { + if (c.actor && c.actor.type == "npc") { + await this.updateEmbeddedDocuments("Combatant", [{ _id: c.id, initiative: -1 }]); + } + } + } + /* -------------------------------------------- */ isCharacter(combatantId) { const combatant = game.combat.combatants.get(combatantId) if (combatant) { return combatant.actor.type == "character" - } + } return false } /* -------------------------------------------- */ async setTic(combatantId, rollData) { - if ( !combatantId) { + if (!combatantId) { return } const combatant = game.combat.combatants.get(combatantId) @@ -62,25 +76,35 @@ export class PegasusCombat extends Combat { /* -------------------------------------------- */ getTIC(num, combatantId) { - if ( !combatantId) { + if (!combatantId) { return "" } const combatant = game.combat.combatants.get(combatantId) if (combatant) { let ticData = combatant.getFlag("world", "tic" + num) if (ticData) { - let ticText = "TIC" + num + ":" + ticData.text + let ticText = "ACTED" /* returns if revealed or if GM and NPC or if player and owner */ - if (ticData.revealed || (game.user.isGM && combatant.isNPC) || (!game.user.isGM && combatant.isOwner)) { + if (ticData.revealed && !ticData.displayed) { + ticData.displayed = true + combatant.setFlag("world", "tic" + num, ticData ) + let chatData = { + user: game.user.id, + alias: combatant.actor.name, + rollMode: game.settings.get("core", "rollMode"), + whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')), + content: `
${combatant.actor.name} is performing ${ticData.text}Damage type : {{weapon.weapon.system.damagetype}} {{weapon.weapon.system.damagetypelevel}} {{/if}} {{/if}} + + {{#if (eq subKey "dmg-res")}} +
  • Damage Resistance
  • + {{#each armorsList as |armor idx|}} + {{#if armor.applied}} +
  • ADRL: {{armor.adrl}}
  • + {{/if}} + {{/each}} + {{/if}} {{#if power}}
  • Power Damage type : {{power.system.powerdamagetype}} {{power.system.powerdamagetypelevel}}
  • diff --git a/templates/pegasus-combat-tracker.html b/templates/pegasus-combat-tracker.html index 8ca2326..5cda55c 100644 --- a/templates/pegasus-combat-tracker.html +++ b/templates/pegasus-combat-tracker.html @@ -30,7 +30,10 @@ - {{/if}} + + + + {{/if}} {{#if combatCount}} {{#if combat.round}}