import { Explore, Info, LastPage, LocalPolice, NewReleases, Report, SportsMma } from "@mui/icons-material"; import { Box, Button, Container, Paper, Tooltip, Typography, useTheme } from "@mui/material"; import React, { useEffect, useState } from "react"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { Settings } from "../../Settings/Settings"; import { numeralWrapper } from "../../ui/numeralFormat"; import { IRouter } from "../../ui/Router"; import { FactionNames } from "../data/FactionNames"; import { Faction } from "../Faction"; import { getFactionAugmentationsFiltered, joinFaction } from "../FactionHelpers"; import { Factions } from "../Factions"; export const InvitationsSeen: string[] = []; const getAugsLeft = (faction: Faction, player: IPlayer): number => { const augs = getFactionAugmentationsFiltered(player, faction); return augs.filter((augmentation: string) => !player.hasAugmentation(augmentation)).length; }; interface IWorkTypeProps { faction: Faction; } const fontSize = "small"; const marginRight = 0.5; const WorkTypesOffered = (props: IWorkTypeProps): React.ReactElement => { const info = props.faction.getInfo(); return ( <> {info.offerFieldWork && ( )} {info.offerHackingWork && ( )} {info.offerSecurityWork && ( )} ); }; interface IFactionProps { player: IPlayer; router: IRouter; faction: Faction; joined: boolean; rerender: () => void; } const FactionElement = (props: IFactionProps): React.ReactElement => { const facInfo = props.faction.getInfo(); function openFaction(faction: Faction): void { props.router.toFaction(faction); } function openFactionAugPage(faction: Faction): void { props.router.toFaction(faction, true); } function acceptInvitation(event: React.MouseEvent, faction: string): void { if (!event.isTrusted) return; joinFaction(Factions[faction]); props.rerender(); } return ( {props.joined ? ( ) : ( )} {props.faction.name} {props.player.hasGangWith(props.faction.name) && ( )} {facInfo.special && ( )} {!props.joined && facInfo.enemies.length > 0 && ( This Faction is enemies with:
    {facInfo.enemies.map((enemy) => (
  • {enemy}
  • ))}
Joining this Faction will prevent you from joining its enemies
} > )}
{!props.player.hasGangWith(props.faction.name) && } {props.joined && ( {getAugsLeft(props.faction, props.player)} Augmentations left )}
{props.joined && ( {numeralWrapper.formatFavor(Math.floor(props.faction.favor))} favor {numeralWrapper.formatReputation(props.faction.playerReputation)} rep )}
); }; interface IProps { player: IPlayer; router: IRouter; } export function FactionsRoot(props: IProps): React.ReactElement { const theme = useTheme(); const setRerender = useState(false)[1]; function rerender(): void { setRerender((old) => !old); } useEffect(() => { const id = setInterval(rerender, 200); return () => clearInterval(id); }, []); useEffect(() => { props.player.factionInvitations.forEach((faction) => { if (InvitationsSeen.includes(faction)) return; InvitationsSeen.push(faction); }); }, []); const allFactions = Object.values(FactionNames).map((faction) => faction as string); const allJoinedFactions = [...props.player.factions]; allJoinedFactions.sort((a, b) => allFactions.indexOf(a) - allFactions.indexOf(b)); const invitations = props.player.factionInvitations; return ( Factions Throughout the game you may receive invitations from factions. There are many different factions, and each faction has different criteria for determining its potential members. Joining a faction and furthering its cause is crucial to progressing in the game and unlocking endgame content. } > 0 ? "1fr " : "") + "2fr", [theme.breakpoints.down("lg")]: { gridTemplateColumns: "1fr", "& > span:nth-of-type(1)": { order: 1 } }, gridTemplateRows: "minmax(0, 1fr)", "& > span > .MuiBox-root": { display: "grid", gridAutoRows: "70px", gap: 1, }, }} > {invitations.length > 0 && ( Faction Invitations {invitations.map((facName) => { if (!Factions.hasOwnProperty(facName)) return null; return ( ); })} )} Your Factions {allJoinedFactions.length > 0 ? ( allJoinedFactions.map((facName) => { if (!Factions.hasOwnProperty(facName)) return null; return ( ); }) ) : ( You have not yet joined any Factions. )} ); }