diff --git a/src/Faction/FactionHelpers.tsx b/src/Faction/FactionHelpers.tsx index 47cce44a3..7c61b9140 100644 --- a/src/Faction/FactionHelpers.tsx +++ b/src/Faction/FactionHelpers.tsx @@ -41,16 +41,14 @@ export function joinFaction(faction: Faction): void { // Add this faction to player's faction list, keeping it in standard order Player.factions = getRecordKeys(Factions).filter((facName) => Factions[facName].isMember); - // Ban player from this faction's enemies + // Ban player from joining this faction's enemies for (const enemy of faction.getInfo().enemies) { if (Factions[enemy]) Factions[enemy].isBanned = true; - Player.factionRumors.delete(enemy); } - // Remove invalid invites and rumors + // Remove invalid invites Player.factionInvitations = Player.factionInvitations.filter((factionName) => { return !Factions[factionName].isMember && !Factions[factionName].isBanned; }); - Player.factionRumors.delete(faction.name); } //Returns a boolean indicating whether the player has the prerequisites for the diff --git a/src/Faction/ui/FactionsRoot.tsx b/src/Faction/ui/FactionsRoot.tsx index 4e4bff3e9..512a7d036 100644 --- a/src/Faction/ui/FactionsRoot.tsx +++ b/src/Faction/ui/FactionsRoot.tsx @@ -58,6 +58,16 @@ const JoinChecklist = (props: { faction: Faction }): React.ReactElement => { ); }; +function getStylesForFactionName(faction: Faction) { + return { + overflow: "hidden", + whiteSpace: "nowrap", + textOverflow: "ellipsis", + color: faction.isBanned ? Settings.theme.error : "inherit", + textDecorationLine: faction.isBanned ? "line-through" : "none", + }; +} + interface FactionElementProps { faction: Faction; /** Rerender function to force the entire FactionsRoot to rerender */ @@ -121,7 +131,7 @@ const FactionElement = (props: FactionElementProps): React.ReactElement => { alignItems: "center", }} > - {props.faction.discovery == FactionDiscovery.known ? ( + {props.faction.discovery === FactionDiscovery.known ? ( @@ -130,13 +140,11 @@ const FactionElement = (props: FactionElementProps): React.ReactElement => { } > - - {props.faction.name} - + {props.faction.name} ) : ( - + @@ -217,7 +225,9 @@ export function FactionsRoot(): React.ReactElement { const joinedFactions = Object.values(Factions).filter((faction) => faction.isMember); // Display invitations and rumors in the order they were received const invitedFactions = Player.factionInvitations.map((facName) => Factions[facName]).filter((faction) => !!faction); - const rumoredFactions = [...Player.factionRumors].map((facName) => Factions[facName]).filter((faction) => !!faction); + const rumoredFactions = [...Player.factionRumors] + .map((facName) => Factions[facName]) + .filter((faction) => !!faction && !faction.isMember && !faction.alreadyInvited); return ( diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts index a0356c6ec..36de6b3fd 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts @@ -110,7 +110,6 @@ export function prestigeAugmentation(this: PlayerObject): void { this.factions = []; this.factionInvitations = []; - this.factionRumors.clear(); // Clear any pending invitation modals FactionInvitationEvents.emit({ type: "ClearAll" }); @@ -174,17 +173,22 @@ export function prestigeSourceFile(this: PlayerObject): void { export function receiveInvite(this: PlayerObject, factionName: FactionName): void { const faction = Factions[factionName]; - if (this.factionInvitations.includes(factionName) || faction.alreadyInvited || faction.isMember || faction.isBanned) + if (this.factionInvitations.includes(factionName) || faction.alreadyInvited || faction.isMember || faction.isBanned) { return; + } this.factionInvitations.push(factionName); - this.factionRumors.delete(factionName); faction.discovery = FactionDiscovery.known; } export function receiveRumor(this: PlayerObject, factionName: FactionName): void { const faction = Factions[factionName]; - if (faction.discovery === FactionDiscovery.unknown) faction.discovery = FactionDiscovery.rumored; - if (this.factionRumors.has(factionName) || faction.isMember || faction.isBanned || faction.alreadyInvited) return; + if (faction.discovery === FactionDiscovery.unknown) { + faction.discovery = FactionDiscovery.rumored; + } + if (this.factionRumors.has(factionName) || faction.isMember || faction.alreadyInvited) { + return; + } + this.factionRumors.add(factionName); } @@ -446,12 +450,11 @@ export function reapplyAllSourceFiles(this: PlayerObject): void { export function checkForFactionInvitations(this: PlayerObject): Faction[] { const invitedFactions = []; for (const faction of Object.values(Factions)) { - if (faction.isBanned) continue; if (faction.isMember) continue; if (faction.alreadyInvited) continue; // Handle invites const { inviteReqs, rumorReqs } = faction.getInfo(); - if (inviteReqs.isSatisfied(this)) invitedFactions.push(faction); + if (!faction.isBanned && inviteReqs.isSatisfied(this)) invitedFactions.push(faction); // Handle rumors if (this.factionRumors.has(faction.name)) continue; if (rumorReqs.isSatisfied(this)) this.receiveRumor(faction.name); diff --git a/src/Prestige.ts b/src/Prestige.ts index 73cf1307a..5e0d7025e 100644 --- a/src/Prestige.ts +++ b/src/Prestige.ts @@ -58,14 +58,11 @@ export function prestigeAugmentation(): void { initBitNodeMultipliers(); - // Maintain invites to factions with the 'keepOnInstall' flag, and rumors about others + // Maintain invites to factions with the 'keepOnInstall' flag const maintainInvites = new Set(); - const maintainRumors = new Set(); for (const facName of [...Player.factions, ...Player.factionInvitations]) { if (Factions[facName].getInfo().keep) { maintainInvites.add(facName); - } else { - maintainRumors.add(facName); } } @@ -193,9 +190,6 @@ export function prestigeAugmentation(): void { } } - // Hear rumors after all invites/bans - for (const factionName of maintainRumors) Player.receiveRumor(factionName); - resetPidCounter(); ProgramsSeen.clear(); InvitationsSeen.clear(); diff --git a/src/Sidebar/ui/SidebarRoot.tsx b/src/Sidebar/ui/SidebarRoot.tsx index b335108ea..4acc1634f 100644 --- a/src/Sidebar/ui/SidebarRoot.tsx +++ b/src/Sidebar/ui/SidebarRoot.tsx @@ -157,6 +157,7 @@ export function SidebarRoot(props: { page: Page }): React.ReactElement { const canOpenFactions = Player.factionInvitations.length > 0 || Player.factions.length > 0 || + Player.factionRumors.size > 0 || Player.augmentations.length > 0 || Player.queuedAugmentations.length > 0 || knowAboutBitverse(); diff --git a/src/utils/SaveDataMigrationUtils.ts b/src/utils/SaveDataMigrationUtils.ts index 92ba77340..af331cd8d 100644 --- a/src/utils/SaveDataMigrationUtils.ts +++ b/src/utils/SaveDataMigrationUtils.ts @@ -622,6 +622,9 @@ Error: ${e}`, initDarkwebServer(); } if (ver < 47) { + for (const faction of [...Player.factions, ...Player.factionInvitations]) { + Player.factionRumors.add(faction); + } showAPIBreaks("3.0.0", breakingChanges300); } }