UI: Infiltration rewards default to the faction you're currently working for (#1114)

* Better infiltration victory faction default
* Better condition for "none" default
* Fix default faction type.
This commit is contained in:
LJ 2024-02-28 17:37:27 -07:00 committed by GitHub
parent 6288eec6d7
commit 4c7f192645
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -17,6 +17,7 @@ import {
calculateTradeInformationRepReward, calculateTradeInformationRepReward,
} from "../formulas/victory"; } from "../formulas/victory";
import { getEnumHelper } from "../../utils/EnumHelper"; import { getEnumHelper } from "../../utils/EnumHelper";
import { isFactionWork } from "../../Work/FactionWork";
interface IProps { interface IProps {
StartingDifficulty: number; StartingDifficulty: number;
@ -26,7 +27,8 @@ interface IProps {
} }
export function Victory(props: IProps): React.ReactElement { export function Victory(props: IProps): React.ReactElement {
const [factionName, setFactionName] = useState("none"); const defaultFaction = isFactionWork(Player.currentWork) ? Player.currentWork.factionName : "none";
const [factionName, setFactionName] = useState(defaultFaction);
function quitInfiltration(): void { function quitInfiltration(): void {
handleInfiltrators(); handleInfiltrators();
@ -79,9 +81,11 @@ export function Victory(props: IProps): React.ReactElement {
<Box sx={{ width: "fit-content" }}> <Box sx={{ width: "fit-content" }}>
<Box sx={{ width: "100%" }}> <Box sx={{ width: "100%" }}>
<Select value={factionName} onChange={changeDropdown} sx={{ mr: 1 }}> <Select value={factionName} onChange={changeDropdown} sx={{ mr: 1 }}>
<MenuItem key={"none"} value={"none"}> {defaultFaction === "none" && (
{"none"} <MenuItem key={"none"} value={"none"}>
</MenuItem> {"none"}
</MenuItem>
)}
{Player.factions {Player.factions
.filter((f) => Factions[f].getInfo().offersWork()) .filter((f) => Factions[f].getInfo().offersWork())
.map((f) => ( .map((f) => (