From ba98d9c264e6f9c7e73c17859bf356766050d34f Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Wed, 13 Sep 2023 21:25:44 +0200 Subject: [PATCH] Add hindrance dice --- images/dice/hindrance-dice-empty.png | Bin 0 -> 7197 bytes modules/pegasus-hindrance-die.js | 25 ++++++++++++ modules/pegasus-main.js | 3 +- modules/pegasus-utility.js | 57 +++++++++++++++++++-------- system.json | 4 +- 5 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 images/dice/hindrance-dice-empty.png create mode 100644 modules/pegasus-hindrance-die.js diff --git a/images/dice/hindrance-dice-empty.png b/images/dice/hindrance-dice-empty.png new file mode 100644 index 0000000000000000000000000000000000000000..2da485b891860282235763e3f57333e1719617ed GIT binary patch literal 7197 zcmeHMdpMM9*MIE3(hlj!E~0WOhbBgBXHhhcmG(G9PBTQ#CWCQmOG3yv4n-wwIfaan zLm@N=gftiwhH=a(hQW7F-+T2P-uHU$%r&qAr@~ z^X)pk3xXg%#D#O0A!wTd=h(Rej1bQ($w3g;Z5LhLiwIraqh3CqPA+a}2s)7voS<=` zQCqm#)~uP|>fdILe!l-$m6j8YDg5n(PQ*o-7n62A8@DC-5YaK&!&Y8j97`vMKNl8+ z7aZLg685tC*OS#3qP7fo$vLS1I@?l%i?6|kbrdS}Oh;{d=5&aO(jhaD&2{FyNAKD< z?MWu&w<9j^${d*z(X1Oh@1L?#rKNw`_Vl6Q{ZS)E%CevNKGTd1$6uKWJD^oegG|)X z9owTstBPN;-&T!2Z-DFSNotr19~UsRDa6Rj2uaWLdjDGDngm1HP<;nK7b2$$gH1Qz zXrH}m$xx+ui}we5h}{w*m5-LdR*Z1i>#vpV`HoAhvSB#A|0+&2k6-&vwE-RCj%+|hmGx>2(ue5% z_0D}88xS|i=X2zYLpFeAhl8R1IdBFamTpZbIQ{H(!O|Ckc=mA)uJ`m1HW=i_AdJs* zkN?cKAChp7S+D>@hcM?YFuI=Z?r0ATr0avW$DmP1u`ZbFNA(fL7tL?&76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`SeLd`?NnVYAvJ=eb2c}lSy37&I+-eR+sT+9LaS@(1=d^IsE zDK?FDz*?oMw&^VQ6t@5zJUV`_*+Q^9!o9SV=@dz}c8yOK3?GBKwXs_}Lh9#}Eby$9M9)_VUx`GwIi`06VAo<*wB!>u zo!8+i0aeq*l_^%49yePDq6v9;w-XgztNz77OP2u1PqVWddv-u!XY4Rb*VopwP|T)^YCh@|5Q=XO3hFkE9z%+5WTaG<>lo8_Wr*%Ho_DG?~V&a zr9GYBOL+P%0xVrK_F+^&DDR-sS%pj_q)C^-E%;kH@2mX9*Z-dnvRZJi7SI@seCp_;||LseDzQs zOe1%c)0EHd_x=5e+t&F}`nFj$AWddVfm2_3FQ9hE-cua$GLA|EC={gysI`3^6ZzvZ zEeTLj3}#*y!rVMn4e;g23!p}@qN47_#*R%)T!-&g$?9{kPo%6J>9<;{tWOzrrl@`d zeDpM}MhXy3Hr)Wqn9pMiqo~2)6}qrmh%6xGD5^_i;^CBgX~;W9ll9X#T)g&%sWAZo zMt!KZ_(fUNWQFMd21NZ~-c(?nbu~twQ>`q;V3leKC|lPOPnTyzfvhY8*Z6dI_pwwC zLA|lI958w{UK}B^_Ewi^QAwr$3_%D@)@VtU_lRDxZGEPUs7+g5=oUtWBq=Cw%bzw< zwDvpkpej}jvAZe)P)iiG)V?mut|B&`c#s`lZHDW1tGU4gm}3)?zP&)8-S(~LHbJF<;O_=Ossv9=;D+j1Dk12~X_1k}$HOV25;U9k`5ezn!b4 z2deMzwRF>&o6?n<1$zC`THf^KM@-Y0q4S(9&5wO`ujH+NRhEv^V`|{XrEV=c;zLb4 zFwK&hLp<7x(y+^&i?pqF=X', + "2": '', + "3": '', + "4": '', + "5": '', + "6": '' + }[result.result]; + } +} diff --git a/modules/pegasus-main.js b/modules/pegasus-main.js index a528adb..04d1ca0 100644 --- a/modules/pegasus-main.js +++ b/modules/pegasus-main.js @@ -15,6 +15,7 @@ import { PegasusVehicleSheet } from "./pegasus-vehicle-sheet.js"; import { PegasusUtility } from "./pegasus-utility.js"; import { PegasusCombatTracker,PegasusCombat } from "./pegasus-combat.js"; import { PegasusItem } from "./pegasus-item.js"; +import { PegasusHindranceDie } from "./pegasus-hindrance-die.js"; import { PEGASUS_CONFIG } from "./pegasus-config.js" /* -------------------------------------------- */ @@ -57,6 +58,7 @@ Hooks.once("init", async function () { CONFIG.Actor.documentClass = PegasusActor CONFIG.Item.documentClass = PegasusItem CONFIG.ui.combat = PegasusCombatTracker + CONFIG.Dice.terms["h"] = PegasusHindranceDie game.system.pegasus = { utility: PegasusUtility, config: PEGASUS_CONFIG @@ -74,7 +76,6 @@ Hooks.once("init", async function () { PegasusUtility.init() - }); /* -------------------------------------------- */ diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 375bb98..8d27ac2 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -26,6 +26,29 @@ export class PegasusUtility { /* Deprecated, no more used in rules Hooks.on("getCombatTrackerEntryContext", (html, options) => { PegasusUtility.pushInitiativeOptions(html, options); });*/ + Hooks.once('diceSoNiceReady', (dice3d) => { + dice3d.addSystem({ id: "pegasus-hindrance", name: "Hindrance Die" }, "preferred"); + dice3d.addDicePreset({ + type: "dh", + labels: [ + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png' + ], + bumpMaps: [ + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice-empty.png', + 'systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png' + ], + system: "pegasus-hindrance" + }, "d6") + }) Hooks.on("dropCanvasData", (canvas, data) => { PegasusUtility.dropItemOnToken(canvas, data) }); @@ -224,9 +247,9 @@ export class PegasusUtility { for (let weapon of rollData.vehicleWeapons) { if (weapon.applied) { newDicePool = newDicePool.concat(this.buildDicePool("damage", weapon.value, 0)) - if( weapon.weapon.system.extradamage) { - for(let i=0; i < weapon.weapon.system.extradamagevalue; i++) { - newDicePool = newDicePool.concat(this.buildDicePool("damage", 5, 0) ) + if (weapon.weapon.system.extradamage) { + for (let i = 0; i < weapon.weapon.system.extradamagevalue; i++) { + newDicePool = newDicePool.concat(this.buildDicePool("damage", 5, 0)) } } } @@ -567,7 +590,7 @@ export class PegasusUtility { /* -------------------------------------------- */ static getDiceFromLevel(level = 0) { - level = Math.max( Number(level), 0) + level = Math.max(Number(level), 0) return this.diceList[level]; } /* -------------------------------------------- */ @@ -846,7 +869,7 @@ export class PegasusUtility { myRoll = new Roll(diceFormula).roll({ async: false }) rollData.roll = myRoll } - if ( rollData.hindranceDices > 0) { + if (rollData.hindranceDices > 0) { rollData.hindranceRoll = new Roll(rollData.hindranceDices + "d6").roll({ async: false }) this.showDiceSoNice(rollData.hindranceRoll, game.settings.get("core", "rollMode")) for (let res of rollData.hindranceRoll.terms[0].results) { @@ -855,7 +878,7 @@ export class PegasusUtility { rollData.img = `systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png` } } - } + } await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) // Final score and keep data @@ -876,7 +899,7 @@ export class PegasusUtility { if (rollData.isInit) { let combat = game.combats.get(rollData.combatId) await combat.setTic(rollData.combatantId, rollData) - combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]) + combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]) } // Stun specific -> Suffer a stun level when dmg-res for character @@ -1071,9 +1094,9 @@ export class PegasusUtility { let defenderActor = target.actor rollData.defenderTokenId = target.id rollData.defenderSize = 0 - if ( defenderActor.type == "character") { + if (defenderActor.type == "character") { rollData.defenderSize = Number(defenderActor.system.biodata.sizenum) + Number(defenderActor.system.biodata.sizebonus) - } else if ( defenderActor.type == "vehicle" ){ + } else if (defenderActor.type == "vehicle") { rollData.defenderSize = Number(defenderActor.system.statistics.hr.size) } //rollData.attackerId = this.id @@ -1117,10 +1140,10 @@ export class PegasusUtility { /* -------------------------------------------- */ static checkIsVehicleCrew(actorId) { - let vehicles = game.actors.filter( actor=> actor.type == "vehicle") || [] - for(let vehicle of vehicles) { + let vehicles = game.actors.filter(actor => actor.type == "vehicle") || [] + for (let vehicle of vehicles) { console.log("Checking", vehicle.name) - if ( vehicle.inCrew(actorId) ) { + if (vehicle.inCrew(actorId)) { return vehicle } } @@ -1153,7 +1176,7 @@ export class PegasusUtility { let tacticianTokens = canvas.tokens.placeables.filter(token => token.actor.isTactician() && !token.document.hidden) for (let token of tacticianTokens) { token.refresh() - let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition) + let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition) for (let friend of friends) { if (friend.actor.id != token.actor.id) { let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] } @@ -1201,7 +1224,7 @@ export class PegasusUtility { let enhancerTokens = canvas.tokens.placeables.filter(token => token.actor.isEnhancer() && !token.document.hidden) for (let token of enhancerTokens) { token.refresh() - let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition) + let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition) for (let friend of friends) { if (friend.actor.id != token.actor.id) { let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] } @@ -1253,13 +1276,13 @@ export class PegasusUtility { token.refresh() let ennemies = [] if (token.document.disposition == -1) { - ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == 1 || newToken.document.disposition == 0 )) + ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == 1 || newToken.document.disposition == 0)) } if (token.document.disposition == 1) { - ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 0 )) + ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 0)) } if (token.document.disposition == 0) { - ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 1 )) + ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 1)) } console.log("Ennemies for token", token.actor.name, ennemies) for (let ennemy of ennemies) { diff --git a/system.json b/system.json index acdafb2..0358e82 100644 --- a/system.json +++ b/system.json @@ -252,7 +252,7 @@ ], "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "11.0.5", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.5.zip", + "version": "11.0.6", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.6.zip", "background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp" } \ No newline at end of file