diff --git a/DEVGUIDE.md b/DEVGUIDE.md new file mode 100644 index 0000000..cc1f038 --- /dev/null +++ b/DEVGUIDE.md @@ -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`. \ No newline at end of file diff --git a/MaterialDeck.js b/MaterialDeck.js index bd9c508..7e5ea67 100644 --- a/MaterialDeck.js +++ b/MaterialDeck.js @@ -57,7 +57,7 @@ let WSconnected = false; async function analyzeWSmessage(msg){ if (enableModule == false) return; const data = JSON.parse(msg); - //console.log("Received",data); +// console.log("Received",data); if (data.type == "connected" && data.data == "SD"){ const msg = { @@ -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; iFoundry 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. @@ -79,6 +82,7 @@ Special thanks to Asmodeus#7588 who made this module possible by generously dona
Please consider supporting me on Patreon, and feel free to join the Material Foundry Discord 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.
I consider this module abandoned if all of the below cases apply: diff --git a/lang/ja.json b/lang/ja.json index d9718e1..c8e0416 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -13,13 +13,13 @@ "MaterialDeck.Sett.MacroConfig": "マクロ設定", "MaterialDeck.Sett.SoundboardConfig": "サウンド設定", "MaterialDeck.Sett.ServerAddr": "Material Server アドレス", - "MaterialDeck.Sett.ServerAddrHint": "MaterialServerのIPアドレスとポート。デフォルト値は99%の人に有効ですが、何をしているのかがわかっている場合にのみ変更してください。[ip_address]:[port]の形式に従う必要があります。例:「localhost:3001」または「192.168.1.1:4000」。", + "MaterialDeck.Sett.ServerAddrHint": "Material ServerのIPアドレスとポート。デフォルト値は99%の人に有効ですが、何をしているのかがわかっている場合にのみ変更してください。[ip_address]:[port]の形式に従う必要があります。例:「localhost:3001」または「192.168.1.1:4000」。", "MaterialDeck.Sett.ImageBuffer": "画像キャッシュサイズ", "MaterialDeck.Sett.ImageBufferHint": "画像キャッシュに保存する画像のデータ量を設定します。画像キャッシュは、ストリームデッキに送信されたすべての画像をローカルに保存します。これにより更新速度は向上しますが、メモリ使用量は増加します。", "MaterialDeck.Sett.ImageBrightness": "画像の明るさ", "MaterialDeck.Sett.ImageBrightnessHint": "デフォルトの画像の明るさを設定します。画像キャッシュサイズが0より大きい場合、更新を実行してください。", - "MaterialDeck.Sett.NrOfConnMessages": "Number of Connection Warnings", - "MaterialDeck.Sett.NrOfConnMessagesHint": "Sets the number of times a connection warning is displayed if Material Deck cannot connect to Material Server. If set to 0, it will give not be limited.", + "MaterialDeck.Sett.NrOfConnMessages": "接続警告回数", + "MaterialDeck.Sett.NrOfConnMessagesHint": "Material DeckがMaterial Serverに接続できない場合に表示される接続警告回数を設定します。0に設定すると、無制限となります。", "MaterialDeck.PL.Unrestricted": "無制限", "MaterialDeck.PL.OneTrackPlaylist": "プレイリストごとに1つのトラック", @@ -49,24 +49,24 @@ "MaterialDeck.Name": "名前", "MaterialDeck.None": "無し", "MaterialDeck.Save": "セーブ", - "MaterialDeck.ClearAll": "Clear All", - "MaterialDeck.ClearAll_Content": "This will clear all the data. This cannot be undone, are you sure you want to proceed?", - "MaterialDeck.ClearPage": "Clear Page", - "MaterialDeck.ClearPage_Content": "This will clear all the data on this page. This cannot be undone, are you sure you want to proceed?", - "MaterialDeck.Continue": "Continue", - "MaterialDeck.Cancel": "Cancel", - "MaterialDeck.Import": "Import", - "MaterialDeck.Export": "Export", - "MaterialDeck.Filename": "Filename", + "MaterialDeck.ClearAll": "すべて クリア", + "MaterialDeck.ClearAll_Content": "すべてのデータがクリアされます。この操作は取り消すことができません、続行しますか?", + "MaterialDeck.ClearPage": "ページ クリア", + "MaterialDeck.ClearPage_Content": "このページのすべてのデータがクリアされます。この操作は取り消すことができません、続行しますか?", + "MaterialDeck.Continue": "継続", + "MaterialDeck.Cancel": "キャンセル", + "MaterialDeck.Import": "インポート", + "MaterialDeck.Export": "エクスポート", + "MaterialDeck.Filename": "ファイル名", - "MaterialDeck.ExportDialog.Title": "Export", - "MaterialDeck.ExportDialog.SoundboardContent": "Export the soundboard data. Please note that only the metadata is exported, so you will have to make sure the audio files are in the same relative location when you import them.", - "MaterialDeck.ExportDialog.MacroboardContent": "Export the macro board data. Please note that only the metadata is exported, so you will have to make sure the same macros are available when you import them.", + "MaterialDeck.ExportDialog.Title": "エクスポート", + "MaterialDeck.ExportDialog.SoundboardContent": "SouseBoardデータをエクスポートします。メタデータのみがエクスポートされるので、インポートするときにオーディオファイルが相対的に同じ場所にあることを確認する必要があります。", + "MaterialDeck.ExportDialog.MacroboardContent": "MacroBoardデータをエクスポートします。メタデータのみがエクスポートされるため、インポートしたときに同じマクロが使用可能であることを確認する必要があります。", - "MaterialDeck.ImportDialog.Title": "Import", - "MaterialDeck.ImportDialog.SoundboardContent": "Select a file to import. Please note that only the metadata is imported, so you will have to make sure the audio files are in the same relative location as when you exported them.", - "MaterialDeck.ImportDialog.MacroboardContent": "Import the macro board data. ", - "MaterialDeck.ImportDialog.Warning": "This will overwrite your current settings, and cannot be undone.", + "MaterialDeck.ImportDialog.Title": "インポート", + "MaterialDeck.ImportDialog.SoundboardContent": "インポートするファイルを選択してください。メタデータのみがインポートされるので、オーディオファイルがそれらをエクスポートしたときと同じ相対的な場所にあることを確認する必要があります。", + "MaterialDeck.ImportDialog.MacroboardContent": "MacroBoardデータをインポートします。 ", + "MaterialDeck.ImportDialog.Warning": "現在の設定が上書きされ、元に戻すことはできません。", "MaterialDeck.FxMaster.Colorize": "色付け", "MaterialDeck.FxMaster.Clear": "すべてクリア", @@ -190,20 +190,20 @@ "MaterialDeck.AboutTime.Fourth": "4", "MaterialDeck.AboutTime.Of": "/", - "MaterialDeck.DownloadUtility.Title": "Download Utility", - "MaterialDeck.DownloadUtility.Plugin": "Plugin & Material Server", - "MaterialDeck.DownloadUtility.Minimum": "Minimum", - "MaterialDeck.DownloadUtility.Current": "Current", - "MaterialDeck.DownloadUtility.Latest": "Latest", + "MaterialDeck.DownloadUtility.Title": "ダウンロード・ユーティリティ", + "MaterialDeck.DownloadUtility.Plugin": "プラグイン&Material Server", + "MaterialDeck.DownloadUtility.Minimum": "最小", + "MaterialDeck.DownloadUtility.Current": "現在", + "MaterialDeck.DownloadUtility.Latest": "最新", "MaterialDeck.DownloadUtility.OS": "OS", - "MaterialDeck.DownloadUtility.Download": "Download", - "MaterialDeck.DownloadUtility.SDplugin": "SD Plugin", + "MaterialDeck.DownloadUtility.Download": "ダウンロード", + "MaterialDeck.DownloadUtility.SDplugin": "SDプラグイン", "MaterialDeck.DownloadUtility.MSserver": "Material Server", "MaterialDeck.DownloadUtility.Windows": "Windows", "MaterialDeck.DownloadUtility.Macos": "MacOS", "MaterialDeck.DownloadUtility.Linux": "Linux", - "MaterialDeck.DownloadUtility.Source": "Source", - "MaterialDeck.DownloadUtility.Profiles": "Profiles", - "MaterialDeck.DownloadUtility.Name": "Name", - "MaterialDeck.DownloadUtility.Refresh": "Refresh" + "MaterialDeck.DownloadUtility.Source": "ソース", + "MaterialDeck.DownloadUtility.Profiles": "プロファイル", + "MaterialDeck.DownloadUtility.Name": "名前", + "MaterialDeck.DownloadUtility.Refresh": "更新" } \ No newline at end of file diff --git a/src/systems/demonlord.js b/src/systems/demonlord.js index ad8cd53..2cabe4a 100644 --- a/src/systems/demonlord.js +++ b/src/systems/demonlord.js @@ -130,4 +130,8 @@ export class demonlord{ getSpellUses(token,level,item) { return; } + + rollItem(item) { + return item.roll() + } } \ No newline at end of file diff --git a/src/systems/dnd35e.js b/src/systems/dnd35e.js index 10eb4cc..32d1604 100644 --- a/src/systems/dnd35e.js +++ b/src/systems/dnd35e.js @@ -195,4 +195,8 @@ export class dnd35e{ maximum: item.maxCharges } } + + rollItem(item) { + return item.roll() + } } \ No newline at end of file diff --git a/src/systems/dnd5e.js b/src/systems/dnd5e.js index 20844c0..b32ee24 100644 --- a/src/systems/dnd5e.js +++ b/src/systems/dnd5e.js @@ -198,4 +198,8 @@ export class dnd5e{ maximum: token.actor.data.data.spells?.[`spell${level}`].max } } + + rollItem(item) { + return item.roll() + } } \ No newline at end of file diff --git a/src/systems/pf2e.js b/src/systems/pf2e.js index f4798af..21ee59f 100644 --- a/src/systems/pf2e.js +++ b/src/systems/pf2e.js @@ -192,4 +192,8 @@ export class pf2e{ maximum: spellbook.data.data.slots?.[`slot${level}`].max } } + + rollItem(item) { + return item.roll() + } } \ No newline at end of file diff --git a/src/systems/tokenHelper.js b/src/systems/tokenHelper.js index 4198a05..aad53eb 100644 --- a/src/systems/tokenHelper.js +++ b/src/systems/tokenHelper.js @@ -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 */ @@ -238,4 +275,8 @@ export class TokenHelper{ getSpellUses(token,level,item) { return this.system.getSpellUses(token,level,item); } + + rollItem(item) { + return this.system.rollItem(item); + } } \ No newline at end of file diff --git a/src/systems/wfrp4e.js b/src/systems/wfrp4e.js new file mode 100644 index 0000000..6588b2f --- /dev/null +++ b/src/systems/wfrp4e.js @@ -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; + } + + +} \ No newline at end of file diff --git a/src/token.js b/src/token.js index 36efe9b..b89cc50 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; @@ -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 ) { @@ -739,7 +758,9 @@ export class TokenControl{ items = this.sortItems(items); const item = items[itemNr]; - if (item != undefined) item.roll(); + if (item != undefined) { + tokenHelper.rollItem(item); + } } }