From 857f36387ae6047cef2cc3cad36c3777adbc1aa4 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 25 Sep 2022 14:45:02 +0200 Subject: [PATCH] Fix #6 Crew limits --- modules/pegasus-actor.js | 6 +++++- template.json | 2 ++ templates/partial-vehicle-stat-block.html | 16 ++++++++++++---- templates/vehicle-sheet.html | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index edde77b..f7216c9 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -1122,7 +1122,7 @@ export class PegasusActor extends Actor { modifyHeroLevelRemaining(incDec) { let biodata = duplicate(this.system.biodata) biodata.currentlevelremaining = Math.max(biodata.currentlevelremaining + incDec, 0) - this.update({ "data.biodata": biodata }) + this.update({ "system.biodata": biodata }) ChatMessage.create({ content: `${this.name} has used a Hero Level to reroll !` }) return biodata.currentlevelremaining } @@ -2063,6 +2063,10 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ addCrew(actorId) { + if ( this.system.crew.length >= this.system.crewmax) { + ui.notifications.warn("Vehicle crew is already full.") + return + } let crewList = duplicate(this.system.crew.filter(actorDef => actorDef.id != actorId) || []) crewList.push({ id: actorId }) this.update({ 'system.crew': crewList }) diff --git a/template.json b/template.json index f11ebed..16bf87e 100644 --- a/template.json +++ b/template.json @@ -201,6 +201,8 @@ }, "vehicle": { "crew": [], + "crewmax": 0, + "crewmin": 0, "statistics": { "fc": { "label": "FC", diff --git a/templates/partial-vehicle-stat-block.html b/templates/partial-vehicle-stat-block.html index 8b243fc..7cfb146 100644 --- a/templates/partial-vehicle-stat-block.html +++ b/templates/partial-vehicle-stat-block.html @@ -11,7 +11,11 @@ @@ -20,8 +24,12 @@ {{#if (eq key "man")}} @@ -30,7 +38,7 @@ diff --git a/templates/vehicle-sheet.html b/templates/vehicle-sheet.html index 7cce902..e95edd9 100644 --- a/templates/vehicle-sheet.html +++ b/templates/vehicle-sheet.html @@ -553,6 +553,20 @@ {{!-- Crew Tab --}}
+ +
+
    +
  • + Maximum Crew Capacity + + Minimum Crew Required + +
  • +
+
+