diff --git a/CHANGELOG.md b/CHANGELOG.md index de1cd94..dc7220c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.6.0 - SoftLock - Added SoftLock on PC sheet +- GmMonitor : Added ability to add or subtract fatigue/strife/void/casualties/panic points on clic. ## 1.5.0 - FoundryVTT v9 Compatibility - Updated the System to FoundryVTT v9. diff --git a/system/lang/en-en.json b/system/lang/en-en.json index e150463..bf8da27 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -148,7 +148,8 @@ "title": "GM Monitor", "switch_view": "Switch View", "honor_glory_status": "H/G/S", - "focus_vigilance": "Foc./Vig." + "focus_vigilance": "Foc./Vig.", + "mouse_control": "Right click +1, left: -1, middle: reset to 0" }, "max": "Max", "current": "Current", diff --git a/system/lang/es-es.json b/system/lang/es-es.json index d99ba5f..61cf2d2 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -148,7 +148,8 @@ "title": "GM Monitor", "switch_view": "Switch View", "honor_glory_status": "H/G/S", - "focus_vigilance": "Foc./Vig." + "focus_vigilance": "Foc./Vig.", + "mouse_control": "Right click +1, left: -1, middle: reset to 0" }, "max": "Máx", "current": "Actuales", diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index 2951717..58a0a04 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -148,7 +148,8 @@ "title": "GM Monitor", "switch_view": "Switch View", "honor_glory_status": "H/G/S", - "focus_vigilance": "Att./Vig." + "focus_vigilance": "Att./Vig.", + "mouse_control": "Click Droit +1, Gauche: -1, Milieu: Remise à 0" }, "max": "Max", "current": "Actuel", diff --git a/system/scripts/gm/gm-monitor.js b/system/scripts/gm/gm-monitor.js index ab70d12..f784cdb 100644 --- a/system/scripts/gm/gm-monitor.js +++ b/system/scripts/gm/gm-monitor.js @@ -38,7 +38,7 @@ export class GmMonitor extends FormApplication { _getHeaderButtons() { let buttons = super._getHeaderButtons(); - // Send To Chat + // Switch view Characters/Armies buttons.unshift({ label: game.i18n.localize("l5r5e.gm_monitor.switch_view"), class: "switch-view", @@ -150,6 +150,9 @@ export class GmMonitor extends FormApplication { // Delete html.find(`.actor-remove-control`).on("click", this._removeActor.bind(this)); + // Add/Subtract + html.find(`.actor-modify-control`).on("mousedown", this._modifyActor.bind(this)); + // Tooltips game.l5r5e.HelpersL5r5e.popupManager(html.find(".actor-infos-control"), async (event) => { const type = $(event.currentTarget).data("type"); @@ -243,7 +246,102 @@ export class GmMonitor extends FormApplication { } /** - * Get tooltips informations for this character + * Add or subtract fatigue/strife/void/casualties/panic + * @param event + * @return {Promise} + * @private + */ + async _modifyActor(event) { + event.preventDefault(); + event.stopPropagation(); + + const type = $(event.currentTarget).data("type"); + if (!type) { + console.warn("L5R5E | type not set", type); + return; + } + const id = $(event.currentTarget).data("actor-id"); + if (!id) { + console.warn("L5R5E | actor id not set", type); + return; + } + const actor = game.actors.get(id); + if (!actor) { + console.warn("L5R5E | Actor not found", type); + return; + } + + // Mouse bt : middle = 0, left +1, right -1 + const add = event.which === 2 ? -999 : event.which === 1 ? 1 : -1; + + switch (type) { + // *** Characters *** + case "fatigue": + await actor.update({ + data: { + fatigue: { + value: Math.max(0, actor.data.data.fatigue.value + add), + }, + }, + }); + break; + + case "strife": + await actor.update({ + data: { + strife: { + value: Math.max(0, actor.data.data.strife.value + add), + }, + }, + }); + break; + + case "void_points": + await actor.update({ + data: { + void_points: { + value: Math.min( + actor.data.data.void_points.max, + Math.max(0, actor.data.data.void_points.value + add) + ), + }, + }, + }); + break; + + // *** Armies *** + case "casualties": + await actor.update({ + data: { + battle_readiness: { + casualties_strength: { + value: Math.max(0, actor.data.data.battle_readiness.casualties_strength.value + add), + }, + }, + }, + }); + break; + + case "panic": + await actor.update({ + data: { + battle_readiness: { + panic_discipline: { + value: Math.max(0, actor.data.data.battle_readiness.panic_discipline.value + add), + }, + }, + }, + }); + break; + + default: + console.warn("L5R5E | Unsupported type", type); + break; + } + } + + /** + * Get tooltips information for this character * @param {BaseSheetL5r5e} actor * @return {string} * @private diff --git a/system/templates/gm/gm-monitor.html b/system/templates/gm/gm-monitor.html index b7569d6..14d7913 100644 --- a/system/templates/gm/gm-monitor.html +++ b/system/templates/gm/gm-monitor.html @@ -54,20 +54,26 @@ / {{actor.data.data.social.status}} - {{actor.data.data.fatigue.value}} - / {{actor.data.data.fatigue.max}} + + {{actor.data.data.fatigue.value}} + / {{actor.data.data.fatigue.max}} + - {{actor.data.data.strife.value}} - / {{actor.data.data.strife.max}} + + {{actor.data.data.strife.value}} + / {{actor.data.data.strife.max}} + {{actor.data.data.focus}} / {{#if actor.data.data.is_compromised}}1{{else}}{{actor.data.data.vigilance}}{{/if}} - {{actor.data.data.void_points.value}} - / {{actor.data.data.void_points.max}} + + {{actor.data.data.void_points.value}} + / {{actor.data.data.void_points.max}} + @@ -101,12 +107,16 @@ {{/if}} - {{actor.data.data.battle_readiness.casualties_strength.value}} - / {{actor.data.data.battle_readiness.casualties_strength.max}} + + {{actor.data.data.battle_readiness.casualties_strength.value}} + / {{actor.data.data.battle_readiness.casualties_strength.max}} + - {{actor.data.data.battle_readiness.panic_discipline.value}} - / {{actor.data.data.battle_readiness.panic_discipline.max}} + + {{actor.data.data.battle_readiness.panic_discipline.value}} + / {{actor.data.data.battle_readiness.panic_discipline.max}} + {{#if actor.data.data.commander_actor_id}}