Skip to content

Commit

Permalink
#92: He borrado los logs y he sacado la modificación del dado al gett…
Browse files Browse the repository at this point in the history
…er canExplode(); sacarlo más a fuera es complicado dado que no se tratan del mismo modo las abiertas normales y las obtenidas mediante dobles. canExplode debería dejar de devolver un boolean para indicar que tipo de abierta es
  • Loading branch information
JordiAlonsoLlovet committed May 29, 2022
1 parent 2703216 commit 965b3a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
25 changes: 11 additions & 14 deletions src/module/rolls/ABFExploderRoll/ABFExploderRoll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/module/types/Actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type ABFActorDataSourceData = {
value: number;
};
openOnDoubles: {
value: number;
value: boolean;
};
defenseType: {
value: string;
Expand Down
7 changes: 6 additions & 1 deletion src/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
Expand Down

0 comments on commit 965b3a5

Please sign in to comment.