From bab57fb4de2655376d21f9df633ec30df0a7390c Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 25 Apr 2022 12:02:37 -0400 Subject: [PATCH] make gang button a component --- src/Faction/ui/FactionRoot.tsx | 46 +------------------ src/Faction/ui/GangButton.tsx | 79 +++++++++++++++++++++++++++++++++ src/data/codingcontracttypes.ts | 2 +- 3 files changed, 82 insertions(+), 45 deletions(-) create mode 100644 src/Faction/ui/GangButton.tsx diff --git a/src/Faction/ui/FactionRoot.tsx b/src/Faction/ui/FactionRoot.tsx index dbcc34b22..4410e5bdb 100644 --- a/src/Faction/ui/FactionRoot.tsx +++ b/src/Faction/ui/FactionRoot.tsx @@ -22,6 +22,7 @@ import { Box, Paper, Typography, Button, Tooltip } from "@mui/material"; import { CovenantPurchasesRoot } from "../../PersonObjects/Sleeve/ui/CovenantPurchasesRoot"; import { FactionNames } from "../data/FactionNames"; import { GangConstants } from "../../Gang/data/Constants"; +import { GangButton } from "./GangButton"; type IProps = { faction: Faction; @@ -61,18 +62,8 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea const player = use.Player(); const router = use.Router(); const [sleevesOpen, setSleevesOpen] = useState(false); - const [gangOpen, setGangOpen] = useState(false); const factionInfo = faction.getInfo(); - function manageGang(): void { - // If player already has a gang, just go to the gang UI - if (player.inGang()) { - return router.toGang(); - } - - setGangOpen(true); - } - function startWork(): void { player.startFocusing(); router.toWork(); @@ -104,20 +95,6 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea const canPurchaseSleeves = faction.name === FactionNames.TheCovenant && player.bitNodeN === 10; - // Note : For future-proofing sake, an assumption is made that player is intended to retain access to his gang if his karma were to somehow increases. - let isManageGangVisible = GangConstants.Names.includes(faction.name) && player.isAwareOfGang(); - // karma threshold is only checked at that point, via canAccessGang(). No further check is made. - let isManageGangClickable = player.canAccessGang(); - if (player.inGang()) { - if (player.getGangName() !== faction.name) { - isManageGangVisible = false; - } else if (player.getGangName() === faction.name) { - isManageGangVisible = true; - // The following line will enable the button, without checking for karma threshold. - isManageGangClickable = true; - } - } - return ( <> @@ -125,26 +102,7 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea {faction.name} - {isManageGangVisible && ( - <> - - - Unlocked when reaching {GangConstants.GangKarmaRequirement} karma : ""} - > - - - {gangInfo} - - - - - - setGangOpen(false)} /> - - )} + {!isPlayersGang && factionInfo.offerHackingWork && (