Skip to content

Commit

Permalink
fixed a bug dark die not increasing stress
Browse files Browse the repository at this point in the history
  • Loading branch information
philote committed Aug 28, 2023
1 parent 0468be4 commit 6aaafab
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions module/sheets/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,32 @@ export class CthulhuDeepGreenActorSheet extends ActorSheet {
this.actor.update({ ["system.stress.states"]: currentArray });
}

_increaseStressByOne() {
let newStress = duplicate(this.actor.system.stress.value);

if (newStress < 6) {
let currentArray = this.actor.system.stress.states;
const firstPos = currentArray.indexOf(false);
if (firstPos != -1) {
currentArray[firstPos] = true;
this.actor.update({ ["system.stress.states"]: currentArray });
}
}
}

_increaseInsightByOne() {
let newInsight = duplicate(this.actor.system.insight.value);

if (newInsight < 6) {
let currentArray = this.actor.system.insight.states;
const firstPos = currentArray.indexOf(false);
if (firstPos != -1) {
currentArray[firstPos] = true;
this.actor.update({ ["system.insight.states"]: currentArray });
}
}
}

// ----------------------
// Dice rolling functions
// ----------------------
Expand Down Expand Up @@ -278,9 +304,9 @@ export class CthulhuDeepGreenActorSheet extends ActorSheet {

if (effectsStress && rollValue > previousStress) {
// update Stress
this._increaseStressByOne();

++newStress;
this.actor.system.stress.value = newStress;
this.actor.update({ "system.stress.value": newStress });
darkDieMessage = darkDieMessage.concat(
game.i18n.format("CDG.StressContent", {
previousstress: previousStress,
Expand All @@ -294,9 +320,9 @@ export class CthulhuDeepGreenActorSheet extends ActorSheet {
darkDieMessage = darkDieMessage.concat("<br>");
}
// update Insight
this._increaseInsightByOne();

++newInsight;
this.actor.system.insight.value = newInsight;
this.actor.update({ "system.insight.value": newInsight });
darkDieMessage = darkDieMessage.concat(
game.i18n.format("CDG.InsightContent", {
previousinsight: previousInsight,
Expand Down Expand Up @@ -332,11 +358,13 @@ export class CthulhuDeepGreenActorSheet extends ActorSheet {
const darkDieRoll = await new Roll("1d6").evaluate({
async: true,
});

let riskMessage = this.darkDieChatContent(
darkDieRoll.result,
darkDieEffectsInsight,
darkDieEffectsStress
);

let diceOutput = this.getDiceForOutput(
darkDieRoll.result,
CONFIG.CDG.DarkDieColor
Expand Down

0 comments on commit 6aaafab

Please sign in to comment.