From 6b38d720bba88df0d58b19896e26061c533471f3 Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@mailbox.org> Date: Tue, 21 Feb 2023 20:00:25 +0100 Subject: [PATCH] clean up pit fights --- src/events/scheduled/pitFight.js | 57 +++++++++++++++++++------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/events/scheduled/pitFight.js b/src/events/scheduled/pitFight.js index 483ef1086d3..a7600081b74 100644 --- a/src/events/scheduled/pitFight.js +++ b/src/events/scheduled/pitFight.js @@ -180,26 +180,22 @@ App.Events.SEPitFight = class SEPitFight extends App.Events.BaseEvent { /** * @param {number} success - * @returns {HTMLParagraphElement} + * @returns {string} */ function eventSuccess(success) { - const p = document.createElement("p"); - if (success < 0) { - p.append("The event was an embarrassment."); + return "The event was an embarrassment."; } else if (success === 0) { - p.append("The event had no success."); + return "The event had no success."; } else if (success < 0.2) { - p.append("The event had little success."); + return "The event had little success."; } else if (success < 0.8) { - p.append("The event had normal success."); + return "The event had normal success."; } else if (success < 1.1) { - p.append("The event had high success."); + return "The event had high success."; } else { - p.append("The event had extremely high success."); + return "The event had extremely high success."; } - - return p; } function intro() { @@ -264,8 +260,12 @@ App.Events.SEPitFight = class SEPitFight extends App.Events.BaseEvent { const r = []; V.nextButton = "Continue"; + if (V.pit.audience === "none") { + return new DocumentFragment(); + } + if (completedFights === 0) { - r.push("Opening the arena without hosting fights hurt your reputation."); + r.push("Opening the arena without hosting fights <span class='reputation dec'>hurt your reputation.</span>"); repX(-100 * maxFights, "pit"); const f = new DocumentFragment(); App.Events.addParagraph(f, r); @@ -280,31 +280,42 @@ App.Events.SEPitFight = class SEPitFight extends App.Events.BaseEvent { if (V.pit.lethal === 1) { if (lethalFights === 0) { r.push("The audience expected to see blood and did not get any."); - totalSuccess *= 0.9; + totalSuccess -= 0.1 * Math.abs(totalSuccess); } else if (lethalFights === completedFights) { r.push("The audience only saw blood today and is missing some other outcomes."); - totalSuccess *= 0.9; + totalSuccess -= 0.1 * Math.abs(totalSuccess); } } + totalSuccess *= 0.5 + 0.5 * V.pit.seats; + if (V.pit.seats === 0) { + r.push("The small visitors section <span class='red'>limited</span> the impact today's fights had."); + } else if (V.pit.seats === 2) { + r.push("The large visitors section <span class='green'>greatly enhanced</span> the impact today's fights had."); + } + const averageSuccess = totalSuccess / maxFights; r.push(eventSuccess(averageSuccess)); - totalSuccess *= 1 + 0.5 * V.pit.seats; + r.push("At the and of the day you"); + const repGain = 100 * totalSuccess; + const cashGain = 2000 * totalSuccess; + const direction = totalSuccess > 0 ? "gained" : "lost"; + const cssDir = totalSuccess > 0 ? "inc" : "dec"; if (V.pit.audience === "free") { - const repGain = 100 * totalSuccess; + r.push(`<span class='reputation ${cssDir}'>${direction} reputation.</span>`); repX(repGain, "pit"); - if (V.cheatMode || V.debugMode) { - r.push("rep:" + repGain); - } } else if (V.pit.audience === "paid") { - const cashGain = 2000 * totalSuccess; + r.push(`<span class='cash ${cssDir}'>${direction} credits.</span>`); cashX(cashGain, "pit"); - if (V.cheatMode || V.debugMode) { - r.push("cash:" + cashGain); - } } + + console.log("PIT:"); + console.log("total success:", totalSuccess, "avg:", averageSuccess); + console.log("possible rep gain: ", repGain); + console.log("possible cash gain:", cashGain); + const f = new DocumentFragment(); App.Events.addParagraph(f, r); return f; -- GitLab