From 8a8f2450d409b7574be57041d879ab5a653af990 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 8 Jan 2022 23:28:16 +0100 Subject: [PATCH] Minor fixes --- module/actor/actor-sheet.js | 2 +- module/actor/actor.js | 41 +++++++++++++++++----- system.json | 4 +-- template.json | 3 +- templates/actor/parts/actor-header.hbs | 16 ++++++++- templates/actor/parts/tabs/actor-stats.hbs | 4 ++- 6 files changed, 56 insertions(+), 14 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index d4e98e4..18070af 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -115,7 +115,7 @@ export class BoLActorSheet extends ActorSheet { formData.details = this.actor.details; formData.attributes = this.actor.attributes; formData.aptitudes = this.actor.aptitudes; - formData.resources = this.actor.resources; + formData.resources = this.actor.getResourcesFromType(); formData.equipment = this.actor.equipment; formData.weapons = this.actor.weapons; formData.protections = this.actor.protections; diff --git a/module/actor/actor.js b/module/actor/actor.js index 1eeda1d..7ddc704 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -12,7 +12,12 @@ export class BoLActor extends Actor { // const flags = actorData.flags; // Make separate methods for each Actor type (character, npc, etc.) to keep things organized. if (actorData.type === 'character') { - //this._prepareCharacterData(actorData); + actorData.type = 'player'; + actorData.villainy = false; + } + if (actorData.type === 'encounter') { + actorData.type = 'tough'; + actorData.villainy = true; } super.prepareData(); } @@ -24,13 +29,15 @@ export class BoLActor extends Actor { /* -------------------------------------------- */ updateResourcesData( ) { - let newVitality = 10 + this.data.data.attributes.vigor.value + this.data.data.resources.hp.bonus - if ( this.data.data.resources.hp.max != newVitality) { - this.update( {'data.resources.hp.max': newVitality} ); - } - let newPower = 10 + this.data.data.attributes.mind.value + this.data.data.resources.power.bonus - if ( this.data.data.resources.power.max != newPower) { - this.update( {'data.resources.power.max': newPower} ); + if ( this.type == 'character') { + let newVitality = 10 + this.data.data.attributes.vigor.value + this.data.data.resources.hp.bonus + if ( this.data.data.resources.hp.max != newVitality) { + this.update( {'data.resources.hp.max': newVitality} ); + } + let newPower = 10 + this.data.data.attributes.mind.value + this.data.data.resources.power.bonus + if ( this.data.data.resources.power.max != newPower) { + this.update( {'data.resources.power.max': newPower} ); + } } } @@ -127,6 +134,24 @@ export class BoLActor extends Actor { return this.itemData.filter(i => i.type === "item" && i.data.category === "equipment" && (i.data.subtype === "other" ||i.data.subtype === "container" ||i.data.subtype === "scroll" || i.data.subtype === "jewel")); } + getResourcesFromType() { + let resources = {}; + if (this.type == 'encounter') { + resources['hp'] = this.data.data.resources.hp; + if (this.data.data.type != 'base') { + resources['faith'] = this.data.data.resources.faith + resources['power'] = this.data.data.resources.power + } + if (this.data.data.type == 'adversary') { + resources['hero'] = duplicate(this.data.data.resources.hero) + resources['hero'].label = "BOL.resources.villainy" + } + } else { + resources = this.data.data.resources; + } + return resources + } + buildFeatures(){ return { "careers": { diff --git a/system.json b/system.json index a4f0249..f6fc827 100644 --- a/system.json +++ b/system.json @@ -7,8 +7,8 @@ "url": "https://github.com/ZigmundKreud/bol", "license": "LICENSE.txt", "flags": {}, - "version": "0.8.9.4", - "templateVersion": 13, + "version": "0.8.9.5", + "templateVersion": 14, "minimumCoreVersion": "0.8.6", "compatibleCoreVersion": "9", "scripts": [], diff --git a/template.json b/template.json index 5dde955..16645eb 100644 --- a/template.json +++ b/template.json @@ -117,7 +117,7 @@ }, "character": { "templates": [ "base" ], - "type": "npc", + "type": "player", "villainy": false, "xp": { "key": "xp", @@ -135,6 +135,7 @@ "encounter": { "templates": [ "base" ], "type": "tough", + "villainy": false, "size": "", "environment": "" } diff --git a/templates/actor/parts/actor-header.hbs b/templates/actor/parts/actor-header.hbs index 4a867b8..49b9937 100644 --- a/templates/actor/parts/actor-header.hbs +++ b/templates/actor/parts/actor-header.hbs @@ -5,6 +5,8 @@
+ + {{#if (eq data.type "player")}}

@@ -15,7 +17,19 @@

-
+ {{else}} +
+
+ +
+ {{/if}} + diff --git a/templates/actor/parts/tabs/actor-stats.hbs b/templates/actor/parts/tabs/actor-stats.hbs index b5fb75d..ba97b77 100644 --- a/templates/actor/parts/tabs/actor-stats.hbs +++ b/templates/actor/parts/tabs/actor-stats.hbs @@ -23,13 +23,15 @@
- {{#each data.resources as |resource id|}} + {{#each resources as |resource id|}}

+ {{#if (eq @root.data.type 'player')}} {{#if (exists bonus)}} {{/if}} + {{/if}}
{{/each}}