From 87a031ae44bc99c9bc149ff2063b2891e117f313 Mon Sep 17 00:00:00 2001 From: Lyle hayhurst Date: Wed, 2 Jun 2021 23:50:12 -0500 Subject: [PATCH] added support for fate and wounds. --- DEVGUIDE.md | 37 +++++++++++++++++++++++++++++++++++++ README.md | 3 +++ src/systems/tokenHelper.js | 6 ++++++ src/systems/wfrp4e.js | 11 ++++++++++- src/token.js | 4 +++- 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 DEVGUIDE.md diff --git a/DEVGUIDE.md b/DEVGUIDE.md new file mode 100644 index 0000000..b659749 --- /dev/null +++ b/DEVGUIDE.md @@ -0,0 +1,37 @@ + +# Dev Guide + + +## Module Development + +### Make a new system.js file + +In the [src/systems](src/systems) directory, create a new system file by copying and pasting a similar system to it; for example, `cp demonlord.js wfrp4.js` +You then need to go through all the functions in there and make sure that the correct data is set. + +### Update TokenHelper +In [src/systems/TokenHelper.js](src/systems/TokenHelper.js), you need to add an `import {}` for your new system. + +In the same file, in the setSystem() function, you need to wire in your system to the if/else block. + +## Debugging + +It's possible to debug on the Stream Deck, so you can do `console.log`. Just follow the instructions [from elgato here](https://developer.elgato.com/documentation/stream-deck/sdk/create-your-own-plugin/). After editing the code for the plugin, you need to either refresh by refreshing the debug window, or by deselecting the current button, and selecting it again. + +## + +For getStats, getRolls you cannot change value + +For the others, it depends on the system. For example: +in 5e, to get the appraise skill modifier, you do token.actor.data.data.skills?.[skill].total where 'skill' is 'apr'. So in the plugin, you have to set the value to 'apr'. + +## Streamdeck + +On the SD side: The plugin in windows is located at AppData/Roaming/Elgato/StreamDeck/Plugins/com.cdeenen.materialdeck.sdPlugin +In propertyinspector/js/common.js starting at line 1274 there's various functions that are used to get the relevant options to show up in the SD plugin. Each array element has a value and a name, you should keep the value the same, but the name can be whatever you like. I think you'll be able to figure out how to add stuff for wfrp by looking at the others. + +To enable logging on the streamdeck, [follow these instructions](https://developer.elgato.com/documentation/stream-deck/sdk/create-your-own-plugin/) from Elgato. + + +## Module Deployment +Copy the new system.js and tokenHelper.js \ No newline at end of file diff --git a/README.md b/README.md index a0fdde6..1af3cf2 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/m Foundry VTT: Tested on 0.7.9 - 0.8.5
Module Incompatibilities: None known.
+## Developer Guide +See the [developer guide](./DEVGUIDE.md) for a guide on how to add new systems to `MaterialDeck`. + ## Feedback If you have any suggestions or bugs to report, feel free to create an issue, contact me on Discord (Cris#6864), or send me an email: cdeenen@outlook.com. diff --git a/src/systems/tokenHelper.js b/src/systems/tokenHelper.js index 4217aa2..c7008a8 100644 --- a/src/systems/tokenHelper.js +++ b/src/systems/tokenHelper.js @@ -186,6 +186,12 @@ export class TokenHelper{ return this.system.getProficiency(token); } + /* WFRP 4E */ + getFate(token) { + return this.system.getFate(token) + } + + /** * Conditions */ diff --git a/src/systems/wfrp4e.js b/src/systems/wfrp4e.js index e5603fb..8216a91 100644 --- a/src/systems/wfrp4e.js +++ b/src/systems/wfrp4e.js @@ -5,12 +5,21 @@ export class wfrp4e { } - getHP(token) { + getFate(token) { + return token.actor.data.data.status.fate.value + } + + getWounds(token) { const wounds = token.actor.data.data.status.wounds return { value: wounds.value, max: wounds.max } + + } + + getHP(token) { + return this.getWounds(token); } getTempHP(token) { diff --git a/src/token.js b/src/token.js index 36efe9b..2c2a4f3 100644 --- a/src/token.js +++ b/src/token.js @@ -94,7 +94,7 @@ export class TokenControl{ } } - if (stats == 'HP') { + if (stats == 'HP' || stats == 'Wounds') { const hp = tokenHelper.getHP(token); txt += hp.value + "/" + hp.max; @@ -135,6 +135,8 @@ export class TokenControl{ else if (stats == 'Save') txt += tokenHelper.getAbilitySave(token, settings.save); else if (stats == 'Skill') txt += tokenHelper.getSkill(token, settings.skill); else if (stats == 'Prof') txt += tokenHelper.getProficiency(token); + else if (stats == 'Fate') txt += tokenHelper.getFate(token) + if (settings.onClick == 'visibility') { //toggle visibility if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {