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 } from "react"; import { Player } from "@player"; import { Settings } from "../../Settings/Settings"; import { formatFavor, formatReputation } from "../../ui/formatNumber"; import { Router } from "../../ui/GameRoot"; import { FactionName } from "@enums"; import { Faction } from "../Faction"; import { getFactionAugmentationsFiltered, joinFaction } from "../FactionHelpers"; import { Factions } from "../Factions"; import { useRerender } from "../../ui/React/hooks"; export const InvitationsSeen: string[] = []; const fontSize = "small"; const marginRight = 0.5; const WorkTypesOffered = (props: { faction: Faction }): React.ReactElement => { const info = props.faction.getInfo(); return ( <> {info.offerFieldWork && ( )} {info.offerHackingWork && ( )} {info.offerSecurityWork && ( )} ); }; interface FactionElementProps { faction: Faction; /** Whether the player is a member of this faction already */ joined: boolean; /** Rerender function to force the entire FactionsRoot to rerender */ rerender: () => void; } const FactionElement = (props: FactionElementProps): React.ReactElement => { const facInfo = props.faction.getInfo(); const augsLeft = getFactionAugmentationsFiltered(props.faction).filter((aug) => !Player.hasAugmentation(aug)).length; function openFaction(faction: Faction): void { Router.toFaction(faction); } function openFactionAugPage(faction: Faction): void { 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} {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
} > )}
{!Player.hasGangWith(props.faction.name) && } {`${augsLeft || "No"} Augmentations left`}
{props.joined && ( {formatFavor(Math.floor(props.faction.favor))} favor {formatReputation(props.faction.playerReputation)} rep )}
); }; export function FactionsRoot(): React.ReactElement { const theme = useTheme(); const rerender = useRerender(200); useEffect(() => { Player.factionInvitations.forEach((faction) => { if (InvitationsSeen.includes(faction)) return; InvitationsSeen.push(faction); }); }, []); const allFactions = Object.values(FactionName).map((faction) => faction as string); const allJoinedFactions = [...Player.factions]; allJoinedFactions.sort((a, b) => allFactions.indexOf(a) - allFactions.indexOf(b)); const invitations = 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 (!Object.hasOwn(Factions, facName)) return null; return ; })} )} Your Factions {allJoinedFactions.length > 0 ? ( allJoinedFactions.map((facName) => { if (!Object.hasOwn(Factions, facName)) return null; return ; }) ) : ( You have not yet joined any Factions. )} ); }