From 36a8b35cfbbe8ae3d7ae1618e05e981b101540ed Mon Sep 17 00:00:00 2001 From: alutman Date: Mon, 23 Oct 2023 19:55:08 +1100 Subject: [PATCH] Prevent faction invitations appearing after prestige (#872) --- src/Faction/ui/InvitationModal.tsx | 5 +++-- src/PersonObjects/Player/PlayerObjectGeneralMethods.ts | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Faction/ui/InvitationModal.tsx b/src/Faction/ui/InvitationModal.tsx index 04c0ba97d..3c6c31396 100644 --- a/src/Faction/ui/InvitationModal.tsx +++ b/src/Faction/ui/InvitationModal.tsx @@ -7,7 +7,7 @@ import { EventEmitter } from "../../utils/EventEmitter"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; -export const InvitationEvent = new EventEmitter<[Faction]>(); +export const InvitationEvent = new EventEmitter<[Faction | null]>(); export function InvitationModal({ hidden }: { hidden: boolean }): React.ReactElement { const [faction, setFaction] = useState(null); @@ -17,8 +17,9 @@ export function InvitationModal({ hidden }: { hidden: boolean }): React.ReactEle const i = Player.factionInvitations.findIndex((facName) => facName === faction.name); if (i === -1) { console.error("Could not find faction in Player.factionInvitations"); + } else { + joinFaction(faction); } - joinFaction(faction); setFaction(null); } diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts index 43491819d..00de0d37a 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts @@ -26,6 +26,7 @@ import { CONSTANTS } from "../../Constants"; import { Exploit } from "../../Exploits/Exploit"; import { Faction } from "../../Faction/Faction"; import { Factions } from "../../Faction/Factions"; +import { InvitationEvent } from "../../Faction/ui/InvitationModal"; import { resetGangs } from "../../Gang/AllGangs"; import { Cities } from "../../Locations/Cities"; import { Locations } from "../../Locations/Locations"; @@ -104,6 +105,8 @@ export function prestigeAugmentation(this: PlayerObject): void { this.factions = []; this.factionInvitations = []; + // Clear any pending invitation modals + InvitationEvent.emit(null); this.queuedAugmentations = [];