/** * Root React Component for displaying a Faction's UI. * This is the component for displaying a single faction's UI, not the list of all * accessible factions */ import React, { useState } from "react"; import { DonateOption } from "./DonateOption"; import { Info } from "./Info"; import { Option } from "./Option"; import { Faction } from "../Faction"; import { Router } from "../../ui/GameRoot"; import { Page } from "../../ui/Router"; import { Player } from "@player"; import { Typography, Button } from "@mui/material"; import { CovenantPurchasesRoot } from "../../PersonObjects/Sleeve/ui/CovenantPurchasesRoot"; import { FactionName, FactionWorkType } from "@enums"; import { GangButton } from "./GangButton"; import { FactionWork } from "../../Work/FactionWork"; import { useRerender } from "../../ui/React/hooks"; import { repNeededToDonate } from "../formulas/donation"; type FactionRootProps = { faction: Faction; }; // Info text for all options on the UI const hackingContractsInfo = "Complete hacking contracts for your faction. " + "Your effectiveness, which determines how much " + "reputation you gain for this faction, is based on your hacking skill. " + "You will gain hacking exp."; const fieldWorkInfo = "Carry out field missions for your faction. " + "Your effectiveness, which determines how much " + "reputation you gain for this faction, is based on all of your stats. " + "You will gain exp for all stats."; const securityWorkInfo = "Serve in a security detail for your faction. " + "Your effectiveness, which determines how much " + "reputation you gain for this faction, is based on your combat stats. " + "You will gain exp for all combat stats."; const augmentationsInfo = "As your reputation with this faction rises, you will " + "unlock Augmentations, which you can purchase to enhance " + "your abilities."; const sleevePurchasesInfo = "Purchase Duplicate Sleeves and upgrades. These are permanent!"; interface IMainProps { faction: Faction; rerender: () => void; onAugmentations: () => void; } function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.ReactElement { const [sleevesOpen, setSleevesOpen] = useState(false); const factionInfo = faction.getInfo(); function startWork(): void { Player.startFocusing(); Router.toPage(Page.Work); } function startFieldWork(faction: Faction): void { Player.startWork( new FactionWork({ singularity: false, faction: faction.name, factionWorkType: FactionWorkType.field, }), ); startWork(); } function startHackingContracts(faction: Faction): void { Player.startWork( new FactionWork({ singularity: false, faction: faction.name, factionWorkType: FactionWorkType.hacking, }), ); startWork(); } function startSecurityWork(faction: Faction): void { Player.startWork( new FactionWork({ singularity: false, faction: faction.name, factionWorkType: FactionWorkType.security, }), ); startWork(); } // We have a special flag for whether the player this faction is the player's // gang faction because if the player has a gang, they cannot do any other action const isPlayersGang = Player.gang && Player.getGangName() === faction.name; // Flags for whether special options (gang, sleeve purchases, donate, etc.) // should be shown const favorToDonate = repNeededToDonate(); const canDonate = faction.favor >= favorToDonate; const canPurchaseSleeves = faction.name === FactionName.TheCovenant && Player.bitNodeN === 10; return ( <> {faction.name} {!isPlayersGang && factionInfo.offerHackingWork && (