MISC: Rework faction rumor (#2569)

This commit is contained in:
catloversg
2026-03-17 01:49:46 +07:00
committed by GitHub
parent ade79c0f65
commit f916daf252
6 changed files with 33 additions and 24 deletions

View File

@@ -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

View File

@@ -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 ? (
<Tooltip
title={
<>
@@ -130,13 +140,11 @@ const FactionElement = (props: FactionElementProps): React.ReactElement => {
</>
}
>
<span style={{ overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }}>
{props.faction.name}
</span>
<span style={getStylesForFactionName(props.faction)}>{props.faction.name}</span>
</Tooltip>
) : (
<Tooltip title={"Rumored Faction"}>
<span style={{ overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }}>
<span style={getStylesForFactionName(props.faction)}>
<CorruptibleText content={props.faction.name} spoiler={false} />
</span>
</Tooltip>
@@ -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 (
<Container disableGutters maxWidth="lg" sx={{ mx: 0, mb: 10 }}>

View File

@@ -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);

View File

@@ -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<FactionName>();
const maintainRumors = new Set<FactionName>();
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();

View File

@@ -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();

View File

@@ -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);
}
}