fix getPossibleInfiltrations not returning enough info and fix donation saying Invalid input before unlocking

This commit is contained in:
Olivier Gagnon 2022-07-21 15:32:54 -04:00
parent 5c551348ed
commit 7f20dc2ee8
3 changed files with 21 additions and 6 deletions

@ -56,7 +56,7 @@ export function DonateOption(props: IProps): React.ReactElement {
} }
function Status(): React.ReactElement { function Status(): React.ReactElement {
if (donateAmt === null) return <></>; if (isNaN(donateAmt)) return <></>;
if (!canDonate()) { if (!canDonate()) {
if (props.p.money < donateAmt) return <Typography>Insufficient funds</Typography>; if (props.p.money < donateAmt) return <Typography>Insufficient funds</Typography>;
return <Typography>Invalid donate amount entered!</Typography>; return <Typography>Invalid donate amount entered!</Typography>;

@ -1,6 +1,10 @@
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { Infiltration as IInfiltration, InfiltrationLocation } from "../ScriptEditor/NetscriptDefinitions"; import {
Infiltration as IInfiltration,
InfiltrationLocation,
PossibleInfiltrationLocation,
} from "../ScriptEditor/NetscriptDefinitions";
import { Location } from "../Locations/Location"; import { Location } from "../Locations/Location";
import { Locations } from "../Locations/Locations"; import { Locations } from "../Locations/Locations";
import { calculateDifficulty, calculateReward } from "../Infiltration/formulas/game"; import { calculateDifficulty, calculateReward } from "../Infiltration/formulas/game";
@ -31,7 +35,7 @@ export function NetscriptInfiltration(player: IPlayer): InternalAPI<IInfiltratio
const reward = calculateReward(player, startingSecurityLevel); const reward = calculateReward(player, startingSecurityLevel);
const maxLevel = location.infiltrationData.maxClearanceLevel; const maxLevel = location.infiltrationData.maxClearanceLevel;
return { return {
location: location, location: JSON.parse(JSON.stringify(location)),
reward: { reward: {
tradeRep: calculateTradeInformationRepReward(player, reward, maxLevel, difficulty), tradeRep: calculateTradeInformationRepReward(player, reward, maxLevel, difficulty),
sellCash: calculateSellInformationCashReward(player, reward, maxLevel, difficulty), sellCash: calculateSellInformationCashReward(player, reward, maxLevel, difficulty),
@ -41,8 +45,11 @@ export function NetscriptInfiltration(player: IPlayer): InternalAPI<IInfiltratio
}; };
}; };
return { return {
getPossibleLocations: () => (): string[] => { getPossibleLocations: () => (): PossibleInfiltrationLocation[] => {
return getLocationsWithInfiltrations.map((l) => l.name); return getLocationsWithInfiltrations.map((l) => ({
city: l.city ?? "",
name: String(l.name),
}));
}, },
getInfiltration: getInfiltration:
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>

@ -1,3 +1,11 @@
/**
* @public
*/
export interface PossibleInfiltrationLocation[] {
city: string;
name: string;
}
/** /**
* Coding contract data will differ depending on coding contract. * Coding contract data will differ depending on coding contract.
* @public * @public
@ -4289,7 +4297,7 @@ interface Infiltration {
* *
* @returns all locations that can be infiltrated. * @returns all locations that can be infiltrated.
*/ */
getPossibleLocations(): string[]; getPossibleLocations(): PossibleInfiltrationLocation[];
/** /**
* Get all infiltrations with difficulty, location and rewards. * Get all infiltrations with difficulty, location and rewards.
* @remarks * @remarks