Skip to content

Commit

Permalink
Fixed minor calculation error (#25)
Browse files Browse the repository at this point in the history
* Fixed minor calculation error

* More feels like sentences
  • Loading branch information
Haxxer authored Aug 28, 2023
1 parent 8f22e09 commit 4b35cd8
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions src/js/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -431,42 +436,29 @@ 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(
(acc, group) => acc + group.level * group.players,
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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4b35cd8

Please sign in to comment.