Merge pull request #79 from lhayhurst/feature/wfrp4
WFRP4e implementation
This commit is contained in:
40
DEVGUIDE.md
Normal file
40
DEVGUIDE.md
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
# Dev Guide
|
||||
|
||||
In addition to this repo, you will also need to check out the [MaterialDeck_SD github repo](https://github.com/CDeenen/MaterialDeck_SD).
|
||||
|
||||
## 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.
|
||||
|
||||
When you go to the debugging page, there should be multiple options. With the property inspector open, you should connect to the one with property inspector in its name. If you go to to propertyinspector/js/common.js, near the top there's the debugEn variable. Set it to true, and you should get tons of messages, especially if you change any settings.
|
||||
In the module, in MaterialDeck.js, at line 60, there's //console.log("Received",data);. If you uncomment that, it'll log everything that's send from the SD to the module. Might be helpful for debugging.
|
||||
|
||||
|
||||
## Streamdeck
|
||||
|
||||
To enable logging on the streamdeck, [follow these instructions](https://developer.elgato.com/documentation/stream-deck/sdk/create-your-own-plugin/) from Elgato.
|
||||
|
||||
The plugin in Windows is located at (Windows) `AppData/Roaming/Elgato/StreamDeck/Plugins/com.cdeenen.materialdeck.sdPlugin`
|
||||
In `propertyinspector/js/common.js::getStats()` there are 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.
|
||||
|
||||
|
||||
## Property discovery
|
||||
In a Foundry client browser instance, if you go to the dev console, you can browser your tokens via the `canvas.tokens` path, for example `canvas.tokens.children[0].children[0].actor.data`.
|
||||
|
||||
## Module Deployment
|
||||
If you make changes to files in this project, you'll need to copy the changed files to your Foundry install folder, probably found here: `C:\Users\$USER\AppData\Local\FoundryVTT\Data\modules\MaterialDeck`.
|
||||
|
||||
If you change the `MaterialDeck_SD` code (for example, `propertyinspector\js\common.js`), you will need to copy that file to the Elgato streamdeck plugins directory, probably found here: `C:\Users\$USER\AppData\Roaming\Elgato\StreamDeck\Plugins\com.cdeenen.materialdeck.sdPlugin`.
|
||||
@@ -390,7 +390,7 @@ Hooks.on('updateToken',(scene,token)=>{
|
||||
if (macroControl != undefined) macroControl.updateAll();
|
||||
});
|
||||
|
||||
Hooks.on('updateActor',(scene,actor)=>{
|
||||
Hooks.on('updateActor',(actor)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
let children = canvas.tokens.children[0].children;
|
||||
for (let i=0; i<children.length; i++){
|
||||
|
||||
@@ -69,6 +69,9 @@ Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/m
|
||||
<b>Foundry VTT:</b> Tested on 0.7.9 - 0.8.5<br>
|
||||
<b>Module Incompatibilities:</b> None known.<br>
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -79,6 +82,7 @@ Special thanks to Asmodeus#7588 who made this module possible by generously dona
|
||||
<br>
|
||||
Please consider supporting me on <a href="https://www.patreon.com/materialfoundry">Patreon</a>, and feel free to join the Material Foundry <a href="https://discord.gg/3hd4G6TkmA">Discord</a> server.
|
||||
|
||||
|
||||
## Abandonment
|
||||
Abandoned modules are a (potential) problem for Foundry, because users and/or other modules might rely on abandoned modules, which might break in future Foundry updates.<br>
|
||||
I consider this module abandoned if all of the below cases apply:
|
||||
|
||||
@@ -2,6 +2,7 @@ import {dnd5e} from "./dnd5e.js"
|
||||
import {dnd35e} from "./dnd35e.js"
|
||||
import {pf2e} from "./pf2e.js"
|
||||
import {demonlord} from "./demonlord.js";
|
||||
import {wfrp4e} from "./wfrp4e.js"
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class TokenHelper{
|
||||
@@ -14,6 +15,7 @@ export class TokenHelper{
|
||||
if (game.system.id == 'D35E' || game.system.id == 'pf1') this.system = new dnd35e();
|
||||
else if (game.system.id == 'pf2e') this.system = new pf2e();
|
||||
else if (game.system.id == 'demonlord') this.system = new demonlord();
|
||||
else if (game.system.id == 'wfrp4e') this.system = new wfrp4e();
|
||||
else this.system = new dnd5e(); //default to dnd5e
|
||||
}
|
||||
|
||||
@@ -184,6 +186,41 @@ export class TokenHelper{
|
||||
return this.system.getProficiency(token);
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getFate(token) {
|
||||
return this.system.getFate(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getFortune(token) {
|
||||
return this.system.getFortune(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getCriticalWounds(token) {
|
||||
return this.system.getCriticalWounds(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getCorruption(token) {
|
||||
return this.system.getCorruption(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getAdvantage(token) {
|
||||
return this.system.getAdvantage(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getResolve(token) {
|
||||
return this.system.getResolve(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getResilience(token) {
|
||||
return this.system.getResilience(token)
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditions
|
||||
*/
|
||||
|
||||
172
src/systems/wfrp4e.js
Normal file
172
src/systems/wfrp4e.js
Normal file
@@ -0,0 +1,172 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class wfrp4e {
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getFate(token) {
|
||||
return token.actor.data.data.status.fate.value
|
||||
}
|
||||
|
||||
getFortune(token) {
|
||||
return token.actor.data.data.status.fortune.value
|
||||
}
|
||||
|
||||
|
||||
getWounds(token) {
|
||||
const wounds = token.actor.data.data.status.wounds
|
||||
return {
|
||||
value: wounds.value,
|
||||
max: wounds.max
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getCriticalWounds(token) {
|
||||
const criticalWounds = token.actor.data.data.status.criticalWounds
|
||||
return {
|
||||
value: criticalWounds.value,
|
||||
max: criticalWounds.max
|
||||
}
|
||||
}
|
||||
|
||||
getCorruption(token) {
|
||||
return token.actor.data.data.status.corruption.value
|
||||
}
|
||||
|
||||
getAdvantage(token) {
|
||||
return token.actor.data.data.status.advantage.value
|
||||
}
|
||||
|
||||
getResolve(token) {
|
||||
return token.actor.data.data.status.resolve.value
|
||||
}
|
||||
|
||||
getResilience(token) {
|
||||
return token.actor.data.data.status.resilience.value
|
||||
}
|
||||
|
||||
getAbility(token, abilityName) {
|
||||
return this.getCharacteristics(token, abilityName);
|
||||
}
|
||||
|
||||
getCharacteristics(token, characteristicName) {
|
||||
if (characteristicName == undefined ) characteristicName = `AG`;
|
||||
const characteristic = token.actor.data.data.characteristics[characteristicName.toLowerCase()]
|
||||
const val = characteristic.value;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getFeatures(token,featureType) {
|
||||
if (featureType == undefined) featureType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'skill' || i.type == 'talent' || i.type == "career" || i.type == 'trait');
|
||||
return allItems.filter(i => i.type == featureType);
|
||||
}
|
||||
getSpells(token,spellType) {
|
||||
const allItems = token.actor.items;
|
||||
return allItems.filter(i => i.type == 'spell')
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
return;
|
||||
}
|
||||
|
||||
getFeatureUses(item) {
|
||||
return {available: `+${item.data.data.total.value}`};
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
return this.getWounds(token);
|
||||
}
|
||||
|
||||
rollItem(item) {
|
||||
return game.wfrp4e.utility.rollItemMacro(item.name, item.type, false);
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
return token.actor.data.data.details.move.value;
|
||||
}
|
||||
|
||||
|
||||
async toggleCondition(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.effects)
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
await token.toggleEffect(effect);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
roll(token,roll,options,ability,skill,save) {
|
||||
//console.log("roll(", token, roll, options, ability, skill, save, ")");
|
||||
if (ability == undefined) ability = 'ag';
|
||||
return game.wfrp4e.utility.rollItemMacro(ability, "characteristic", false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
getItems(token,itemType) {
|
||||
if (itemType == undefined) itemType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (itemType == 'any') return allItems.filter(i => i.type == 'weapon' ||
|
||||
i.type == 'ammunition' ||
|
||||
i.type == 'armour' ||
|
||||
i.type == 'trapping');
|
||||
else {
|
||||
return allItems.filter(i => i.type == itemType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getItemUses(item) {
|
||||
console.log("getItemUses(" , item , ")")
|
||||
if ( item.type == 'ammunition') {
|
||||
return {available: item.data.data.quantity.value};
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* this is all cargo-culted in and some of it could be deleted once the interface is resolved
|
||||
to not be the superset of all possible systems
|
||||
*/
|
||||
|
||||
getAC(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
getConditionIcon(condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
getConditionActive(token,condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
21
src/token.js
21
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;
|
||||
|
||||
@@ -105,6 +105,18 @@ export class TokenControl{
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
if (stats == 'CriticalWounds') { /* WFRP4e */
|
||||
const criticalWounds = tokenHelper.getCriticalWounds(token);
|
||||
txt += criticalWounds.value + "/" + criticalWounds.max;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: criticalWounds.value,
|
||||
maximum: criticalWounds.max,
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
else if (stats == 'HPbox') {
|
||||
const hp = tokenHelper.getHP(token);
|
||||
@@ -135,6 +147,13 @@ 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) /* WFRP4e */
|
||||
else if (stats == 'Fortune') txt += tokenHelper.getFortune(token) /* WFRP4e */
|
||||
else if (stats == 'Corruption') txt += tokenHelper.getCorruption(token) /* WFRP4e */
|
||||
else if (stats == 'Advantage') txt += tokenHelper.getAdvantage(token) /* WFRP4e */
|
||||
else if (stats == 'Resolve') txt += tokenHelper.getResolve(token) /* WFRP4e */
|
||||
else if (stats == 'Resilience') txt += tokenHelper.getResilience(token) /* WFRP4e */
|
||||
|
||||
|
||||
if (settings.onClick == 'visibility') { //toggle visibility
|
||||
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
||||
|
||||
Reference in New Issue
Block a user