From 337fa4e274ffd97408f9f8bfa86c3d2588715cf7 Mon Sep 17 00:00:00 2001
From: catloversg <152669316+catloversg@users.noreply.github.com>
Date: Fri, 21 Jun 2024 17:05:33 +0700
Subject: [PATCH] GANG: Fix wrong wanted gain rate (#1415)
---
src/Gang/Gang.ts | 6 ++++--
src/Gang/ui/GangStats.tsx | 32 ++++++++++++++++++--------------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/src/Gang/Gang.ts b/src/Gang/Gang.ts
index 49df55b06..7d2c51737 100644
--- a/src/Gang/Gang.ts
+++ b/src/Gang/Gang.ts
@@ -154,9 +154,11 @@ export class Gang {
const newWanted = oldWanted + wantedLevelGainPerCycle * numCycles;
// Allows recovery when wanted / respect ratio is too high
this.wanted = newWanted * (1 - justice * 0.001);
- this.wantedGainRate -= newWanted - this.wanted;
+ this.wantedGainRate = (this.wanted - oldWanted) / numCycles;
// Prevent overflow
- if (this.wanted < 1 || (wantedLevelGainPerCycle <= 0 && this.wanted > oldWanted)) this.wanted = 1;
+ if (this.wanted < 1 || (wantedLevelGainPerCycle <= 0 && this.wanted > oldWanted)) {
+ this.wanted = 1;
+ }
}
Player.gainMoney(moneyGainPerCycle * numCycles, "gang");
}
diff --git a/src/Gang/ui/GangStats.tsx b/src/Gang/ui/GangStats.tsx
index 67ad3409f..55981cde4 100644
--- a/src/Gang/ui/GangStats.tsx
+++ b/src/Gang/ui/GangStats.tsx
@@ -27,6 +27,21 @@ export function GangStats(): React.ReactElement {
} else {
territoryStr = formatNumberNoSuffix(territoryMult, 2);
}
+ const hasEnoughBonusTime = gang.storedCycles > GangConstants.maxCyclesToProcess;
+ const bonusCyclesInOneSecond = 5 * GangConstants.maxCyclesToProcess;
+ const respectGainRateInBonusTime = hasEnoughBonusTime
+ ? `[Effective Gain: ${formatRespect(gang.respectGainRate * bonusCyclesInOneSecond)} / sec]`
+ : "";
+ const wantedGainRateInBonusTime = hasEnoughBonusTime
+ ? `[Effective Gain: ${formatWanted(gang.wantedGainRate * bonusCyclesInOneSecond)} / sec]`
+ : "";
+ const moneyGainRateInBonusTime = hasEnoughBonusTime ? (
+ <>
+ [Effective Gain: ]
+ >
+ ) : (
+ ""
+ );
return (
<>
@@ -42,9 +57,7 @@ export function GangStats(): React.ReactElement {
>
Respect: {formatRespect(gang.respect)} ({formatRespect(5 * gang.respectGainRate)} / sec){" "}
- {gang.storedCycles > 2 * GangConstants.maxCyclesToProcess
- ? `[Effective Gain: ${formatRespect(5 * gang.respectGainRate * GangConstants.maxCyclesToProcess)} / sec]`
- : ""}
+ {respectGainRateInBonusTime}
@@ -60,9 +73,7 @@ export function GangStats(): React.ReactElement {
>
Wanted Level: {formatWanted(gang.wanted)} ({formatWanted(5 * gang.wantedGainRate)} / sec){" "}
- {gang.storedCycles > 2 * GangConstants.maxCyclesToProcess
- ? `[Effective Gain: ${formatWanted(5 * gang.wantedGainRate * GangConstants.maxCyclesToProcess)} / sec]`
- : ""}
+ {wantedGainRateInBonusTime}
@@ -76,14 +87,7 @@ export function GangStats(): React.ReactElement {
- Money gain rate: {" "}
- {gang.storedCycles > 2 * GangConstants.maxCyclesToProcess ? "[Effective Gain:" : ""}{" "}
- {gang.storedCycles > 2 * GangConstants.maxCyclesToProcess ? (
-
- ) : (
- ""
- )}
- {gang.storedCycles > 2 * GangConstants.maxCyclesToProcess ? "]" : ""}
+ Money gain rate: {moneyGainRateInBonusTime}