From 965b3a5c92a1d086ce7483474e0e0bee10a97907 Mon Sep 17 00:00:00 2001 From: JordiAlonsoLlovet Date: Sun, 29 May 2022 19:58:41 +0200 Subject: [PATCH] =?UTF-8?q?#92:=20He=20borrado=20los=20logs=20y=20he=20sac?= =?UTF-8?q?ado=20la=20modificaci=C3=B3n=20del=20dado=20al=20getter=20canEx?= =?UTF-8?q?plode();=20sacarlo=20m=C3=A1s=20a=20fuera=20es=20complicado=20d?= =?UTF-8?q?ado=20que=20no=20se=20tratan=20del=20mismo=20modo=20las=20abier?= =?UTF-8?q?tas=20normales=20y=20las=20obtenidas=20mediante=20dobles.=20can?= =?UTF-8?q?Explode=20deber=C3=ADa=20dejar=20de=20devolver=20un=20boolean?= =?UTF-8?q?=20para=20indicar=20que=20tipo=20de=20abierta=20es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rolls/ABFExploderRoll/ABFExploderRoll.ts | 25 ++++++++----------- src/module/types/Actor.ts | 2 +- src/template.json | 7 +++++- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/module/rolls/ABFExploderRoll/ABFExploderRoll.ts b/src/module/rolls/ABFExploderRoll/ABFExploderRoll.ts index dced4001..05d78171 100644 --- a/src/module/rolls/ABFExploderRoll/ABFExploderRoll.ts +++ b/src/module/rolls/ABFExploderRoll/ABFExploderRoll.ts @@ -6,8 +6,14 @@ export default class ABFExploderRoll extends ABFRoll { get canExplode() { const lastResult = this.firstDice.results[this.firstDice.results.length-1] - if (this.openOnDoubles) { - if (this.checkDoubles()) return true; + if (this.openOnDoubles && this.checkDoubles(lastResult.result)) { + this.firstDice.results[this.firstDice.results.length-1] = { + ...lastResult, + success: true, + exploded: true, + count: 100 + } + return true; } let exploded = lastResult.result >= this.lastOpenRange; lastResult.success = exploded; @@ -18,19 +24,11 @@ export default class ABFExploderRoll extends ABFRoll { return this.foundryRoll.firstResult <= this.fumbleRange; } - protected checkDoubles(): boolean { - if (this.foundryRoll.lastResult % 11 === 0) { + protected checkDoubles(result: number): boolean { + if (result % 11 === 0) { const newRoll = new ABFFoundryRoll('1d10').evaluate(); - if (newRoll.total === (this.foundryRoll.lastResult / 11)) { - this.firstDice.results[this.firstDice.results.length-1] = { - ...this.firstDice.results[this.firstDice.results.length-1], - success: true, - exploded: true, - count: 100 - } - return true; - } + return (newRoll.total === (result / 11)) } return false; } @@ -50,7 +48,6 @@ export default class ABFExploderRoll extends ABFRoll { private explodeDice(openRange: number) { this.lastOpenRange = Math.min(openRange, 100); - console.log(this.firstDice); const newRoll = new ABFFoundryRoll('1d100').evaluate(); const newResult = this.addRoll(newRoll); diff --git a/src/module/types/Actor.ts b/src/module/types/Actor.ts index 77f238e8..80d4271e 100644 --- a/src/module/types/Actor.ts +++ b/src/module/types/Actor.ts @@ -23,7 +23,7 @@ export type ABFActorDataSourceData = { value: number; }; openOnDoubles: { - value: number; + value: boolean; }; defenseType: { value: string; diff --git a/src/template.json b/src/template.json index a723bc17..dc1e21ae 100644 --- a/src/template.json +++ b/src/template.json @@ -9,7 +9,12 @@ "tabVisibility": { "mystic": { "value": false }, "domine": { "value": false }, "psychic": { "value": false } } }, "general": { - "settings": { "openRolls": { "value": 0 }, "fumbles": { "value": 0 }, "openOnDoubles": { "value": false }, "defenseType": { "value": "" } }, + "settings": { + "openRolls": { "value": 0 }, + "fumbles": { "value": 0 }, + "openOnDoubles": { "value": false }, + "defenseType": { "value": "" } + }, "modifiers": { "physicalActions": { "value": 0 }, "allActions": { "base": { "value": 0 }, "final": { "value": 0 } },