From 4b35cd84c5ab4bce1685933a59438901bff333b1 Mon Sep 17 00:00:00 2001 From: Adam Oresten Date: Mon, 28 Aug 2023 18:11:59 +0100 Subject: [PATCH] Fixed minor calculation error (#25) * Fixed minor calculation error * More feels like sentences --- src/js/strategy.js | 52 ++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/src/js/strategy.js b/src/js/strategy.js index fd3d46e..9d5f6c4 100644 --- a/src/js/strategy.js +++ b/src/js/strategy.js @@ -17,6 +17,15 @@ class EncounterStrategy { "someone forgot to bring snacks", "rocks fall", "someone insulted the DM", + "the DM's revenge for that missed crit.", + "accidentally crashing a dragon's private spa day.", + "a masterclass in \"How Not to Survive.\"", + "the gods will want popcorn to watch this disaster.", + "the universe is asking, \"Are you sure about this?\"", + "the DM drew a \"TPK\" card from their deck of many things.", + "a plot twist written by Murphy's Law.", + "something from the \"Cruel and Unusual\" rulebook.", + "the DM is an amateur horror movie director.", ]; static getTotalExp() { @@ -209,10 +218,6 @@ class KFC extends EncounterStrategy { const [upperKey, upperValue] = levels[i]; const ratio = helpers.ratio(lowerValue, upperValue, adjustedExp); - if (ratio >= 10) { - return "... insane?"; - } - if (upperKey === "daily" && ratio >= 0.0) { if (ratio >= 0.2) { return ratio >= 1.0 @@ -431,29 +436,11 @@ class MCDM extends EncounterStrategy { { easy: "4-5", standard: "2-3", hard: "0-1" }, ]; - static #getGroupBudget(acc, group) { - const crGroupBudget = this.encounterCrPerCharacter[group.level]; - return { - Easy: (acc?.["Easy"] ?? 0) + crGroupBudget.easy * (group?.players ?? 1), - Standard: - (acc?.["Standard"] ?? 0) + - crGroupBudget.standard * (group?.players ?? 1), - Hard: (acc?.["Hard"] ?? 0) + crGroupBudget.hard * (group?.players ?? 1), - }; - } - static getBudget() { - if (!useParty().totalPlayers) { + let totalPlayers = useParty().totalPlayers; + if (!totalPlayers) { return {}; } - let groupBudget = useParty().groups.reduce( - this.#getGroupBudget.bind(this), - {} - ); - let totalBudget = useParty().activePlayers.reduce( - this.#getGroupBudget.bind(this), - groupBudget - ); let totalLevels = useParty().groups.reduce( @@ -461,12 +448,17 @@ class MCDM extends EncounterStrategy { 0 ) + useParty().activePlayers.reduce((acc, player) => acc + player.level, 0); - let averageLevel = Math.floor(totalLevels / useParty().totalPlayers); - totalBudget["One Monster Cap"] = - this.encounterCrPerCharacter[averageLevel].cap; + let averageLevel = Math.floor(totalLevels / totalPlayers); + + let crBudget = this.encounterCrPerCharacter[averageLevel]; - return totalBudget; + return { + "Easy": crBudget.easy * totalPlayers, + "Standard": crBudget.standard * totalPlayers, + "Hard": crBudget.hard * totalPlayers, + "One Monster Cap": crBudget.cap + }; } static getBudgetSpend(encounter) { @@ -514,10 +506,6 @@ class MCDM extends EncounterStrategy { const ratio = helpers.ratio(lowerValue, upperValue, budgetSpend); if (lowerValue === upperValue) continue; - if (ratio >= 10) { - return "... insane?"; - } - if (upperKey === "Hard" && ratio > 1.0) { if (ratio >= 1.5) { return ratio >= 3.0