From f69bac308c991a0795bceb9f581b55b2302321fd Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Mon, 31 Mar 2025 01:42:34 +0700 Subject: [PATCH] UI: Warn player if they enable territory clash when gang power is too low (#2061) --- src/Gang/ui/TerritorySubpage.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Gang/ui/TerritorySubpage.tsx b/src/Gang/ui/TerritorySubpage.tsx index ea04d1c28..ceb3530d0 100644 --- a/src/Gang/ui/TerritorySubpage.tsx +++ b/src/Gang/ui/TerritorySubpage.tsx @@ -49,13 +49,27 @@ export function TerritorySubpage(): React.ReactElement { break; } } + /** + * tooLowGangPower is a special check. Before the first tick of territory clash, the power of all gangs + * is 1, so the win chance of the player's gang against all gangs is 50%. If the player tries to enable + * the clash in this short time frame, canWinAtLeastOneGang is true, but their gang will still be + * crushed after the first clash tick. + */ + const tooLowGangPower = gang.getPower() < 2; + const needToBeWarned = !canWinAtLeastOneGang || tooLowGangPower; /** * Show a confirmation popup if the player tries to enable the territory clash when their gang is too * weak and cannot win any other gangs. */ - if (event.target.checked && !canWinAtLeastOneGang) { + if (event.target.checked && needToBeWarned) { + let message = "Your gang is too weak."; + if (!canWinAtLeastOneGang) { + message += " Its win chances against all other gangs are below 50%."; + } PromptEvent.emit({ - txt: "Your gang is too weak. Its win chances against all other gangs are below 50%.\nOn average, you will always lose territory when being engaged in clashes.\n\nDo you really want to engage in territory clashes?", + txt: + message + + "\nOn average, you will always lose territory when being engaged in clashes.\n\nDo you really want to engage in territory clashes?", resolve: (value: string | boolean) => { if (value === true) { gang.territoryWarfareEngaged = true;