From 99383eb1c797a4f7cadebd164df25d40bd4ebcb2 Mon Sep 17 00:00:00 2001 From: Jesse Clark Date: Sun, 3 Dec 2023 01:07:59 -0800 Subject: [PATCH] Only show "joining this faction will prevent you from joining enemies" for factions that have enemies (#921) --- src/Faction/ui/InvitationModal.tsx | 34 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Faction/ui/InvitationModal.tsx b/src/Faction/ui/InvitationModal.tsx index 3c6c31396..5cbbdc14d 100644 --- a/src/Faction/ui/InvitationModal.tsx +++ b/src/Faction/ui/InvitationModal.tsx @@ -2,24 +2,23 @@ import React, { useState, useEffect } from "react"; import { joinFaction } from "../FactionHelpers"; import { Faction } from "../Faction"; import { Modal } from "../../ui/React/Modal"; -import { Player } from "@player"; import { EventEmitter } from "../../utils/EventEmitter"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; +import { Report } from "@mui/icons-material"; +import { Settings } from "../../Settings/Settings"; export const InvitationEvent = new EventEmitter<[Faction | null]>(); export function InvitationModal({ hidden }: { hidden: boolean }): React.ReactElement { const [faction, setFaction] = useState(null); + + const enemies = faction?.getInfo().enemies ?? []; + function join(): void { if (faction === null) return; - //Remove from invited factions - const i = Player.factionInvitations.findIndex((facName) => facName === faction.name); - if (i === -1) { - console.error("Could not find faction in Player.factionInvitations"); - } else { - joinFaction(faction); - } + if (!faction.alreadyInvited) return; + joinFaction(faction); setFaction(null); } @@ -29,10 +28,23 @@ export function InvitationModal({ hidden }: { hidden: boolean }): React.ReactEle setFaction(null)}> You have received a faction invitation. - Would you like to join {faction?.name}?
-
- Warning: Joining this faction may prevent you from joining other factions during this run! + Would you like to join {faction?.name}?
+ {enemies.length > 0 && ( + +
+ Joining this Faction will prevent you from joining its enemies until your next augmentation. +
+ {faction?.name} is enemies with: + {enemies.map((enemy) => ( + + + {enemy} + + ))} +
+ )} +