FACTIONS: Add "Rumors" system for learning about faction join requirements (#888)

This commit is contained in:
Jesse Clark
2023-11-02 07:20:24 -07:00
committed by GitHub
parent 023f32bce3
commit fdcb8306d9
27 changed files with 1049 additions and 601 deletions
+83 -8
View File
@@ -5,19 +5,25 @@ import {
AccordionDetails,
Button,
FormControl,
FormControlLabel,
IconButton,
InputLabel,
MenuItem,
Select,
SelectChangeEvent,
Typography,
RadioGroup,
Radio,
} from "@mui/material";
import Tooltip from "@mui/material/Tooltip";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import ReplyAllIcon from "@mui/icons-material/ReplyAll";
import ReplyIcon from "@mui/icons-material/Reply";
import ChatIcon from "@mui/icons-material/Chat";
import ChatBubbleIcon from "@mui/icons-material/ChatBubble";
import { Player } from "@player";
import { FactionName } from "@enums";
import { FactionName, FactionDiscovery } from "@enums";
import { Adjuster } from "./Adjuster";
import { Factions } from "../../Faction/Factions";
import { getRecordValues } from "../../Types/Record";
@@ -27,18 +33,41 @@ const bigNumber = 1e12;
export function FactionsDev(): React.ReactElement {
const [factionName, setFactionName] = useState(FactionName.Illuminati);
const [factionDiscovery, setFactionDiscovery] = useState(Factions[FactionName.Illuminati].discovery);
function setFactionDropdown(event: SelectChangeEvent): void {
if (!getEnumHelper("FactionName").isMember(event.target.value)) return;
setFactionName(event.target.value);
setFactionDiscovery(Factions[event.target.value].discovery);
}
function receiveInvite(): void {
Player.receiveInvite(factionName);
Factions[factionName].alreadyInvited = true;
}
function receiveAllInvites(): void {
Object.values(FactionName).forEach((faction) => Player.receiveInvite(faction));
Object.values(FactionName).forEach((faction) => {
Player.receiveInvite(faction);
Factions[factionName].alreadyInvited = true;
});
}
function receiveRumor(): void {
Player.receiveRumor(factionName);
setFactionDiscovery(Factions[factionName].discovery);
}
function receiveAllRumors(): void {
Object.values(FactionName).forEach((faction) => Player.receiveRumor(faction));
}
function resetAllDiscovery(): void {
Object.values(Factions).forEach((faction) => {
faction.discovery = FactionDiscovery.unknown;
});
Player.factionRumors.length = 0;
setFactionDiscovery(Factions[factionName].discovery);
}
function modifyFactionRep(modifier: number): (x: number) => void {
@@ -93,6 +122,12 @@ export function FactionsDev(): React.ReactElement {
}
}
function setDiscovery(event: React.ChangeEvent<HTMLInputElement>, value: string): void {
const disco = value as FactionDiscovery;
Factions[factionName].discovery = disco;
setFactionDiscovery(disco);
}
return (
<Accordion TransitionProps={{ unmountOnExit: true }}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
@@ -115,12 +150,16 @@ export function FactionsDev(): React.ReactElement {
value={factionName}
startAdornment={
<>
<IconButton onClick={receiveAllInvites} size="large" arial-label="receive-all-invitation">
<ReplyAllIcon />
</IconButton>
<IconButton onClick={receiveInvite} size="large" arial-label="receive-one-invitation">
<ReplyIcon />
</IconButton>
<Tooltip title={`Hear rumor about ${factionName}`}>
<IconButton onClick={receiveRumor} size="large">
<ChatIcon />
</IconButton>
</Tooltip>
<Tooltip title={`Receive invitation to ${factionName}`}>
<IconButton onClick={receiveInvite} size="large">
<ReplyIcon />
</IconButton>
</Tooltip>
</>
}
>
@@ -133,6 +172,20 @@ export function FactionsDev(): React.ReactElement {
</FormControl>
</td>
</tr>
<tr>
<td>
<Typography>Discovery:</Typography>
</td>
<td>
<FormControl>
<RadioGroup onChange={setDiscovery} value={factionDiscovery} row>
{Object.entries(FactionDiscovery).map(([discoveryLabel, discovery]) => (
<FormControlLabel key={discovery} value={discovery} label={discoveryLabel} control={<Radio />} />
))}
</RadioGroup>
</FormControl>
</td>
</tr>
<tr>
<td>
<Typography>Reputation:</Typography>
@@ -163,6 +216,28 @@ export function FactionsDev(): React.ReactElement {
/>
</td>
</tr>
<tr>
<td>
<Typography>All Factions:</Typography>
</td>
<td>
<Tooltip title="Forget all discovery">
<Button onClick={resetAllDiscovery} size="large">
<ChatBubbleIcon />
</Button>
</Tooltip>
<Tooltip title="Hear all rumors">
<Button onClick={receiveAllRumors} size="large">
<ChatIcon />
</Button>
</Tooltip>
<Tooltip title="Receive all invitations">
<Button onClick={receiveAllInvites} size="large">
<ReplyAllIcon />
</Button>
</Tooltip>
</td>
</tr>
<tr>
<td>
<Typography>All Reputation:</Typography>