diff --git a/src/Infiltration/ui/Game.tsx b/src/Infiltration/ui/Game.tsx index 8b6a1d109..beaf595c3 100644 --- a/src/Infiltration/ui/Game.tsx +++ b/src/Infiltration/ui/Game.tsx @@ -16,6 +16,7 @@ import Typography from "@mui/material/Typography"; interface IProps { StartingDifficulty: number; Difficulty: number; + Reward: number; MaxLevel: number; } @@ -112,6 +113,7 @@ export function Game(props: IProps): React.ReactElement { ); diff --git a/src/Infiltration/ui/InfiltrationRoot.tsx b/src/Infiltration/ui/InfiltrationRoot.tsx index c706eb9e8..54c78c019 100644 --- a/src/Infiltration/ui/InfiltrationRoot.tsx +++ b/src/Infiltration/ui/InfiltrationRoot.tsx @@ -4,18 +4,35 @@ import { Intro } from "./Intro"; import { Game } from "./Game"; import { Location } from "../../Locations/Location"; import { use } from "../../ui/Context"; +import { calculateSkill } from "../../PersonObjects/formulas/skill"; interface IProps { location: Location; } -function calcDifficulty(player: IPlayer, startingDifficulty: number): number { - const totalStats = player.strength + player.defense + player.dexterity + player.agility + player.charisma; - const difficulty = startingDifficulty - Math.pow(totalStats, 0.9) / 250 - player.intelligence / 1600; + +function calcRawDiff(player: IPlayer, stats: number, startingDifficulty: number): number { + const difficulty = startingDifficulty - Math.pow(stats, 0.9) / 250 - player.intelligence / 1600; if (difficulty < 0) return 0; if (difficulty > 3) return 3; return difficulty; } +function calcDifficulty(player: IPlayer, startingDifficulty: number): number { + const totalStats = player.strength + player.defense + player.dexterity + player.agility + player.charisma; + return calcRawDiff(player, totalStats, startingDifficulty); +} + +function calcReward(player: IPlayer, startingDifficulty: number): number { + const xpMult = 10 * 60 * 15; + const total = + calculateSkill(player.strength_exp_mult * xpMult, player.strength_mult) + + calculateSkill(player.defense_exp_mult * xpMult, player.defense_mult) + + calculateSkill(player.agility_exp_mult * xpMult, player.agility_mult) + + calculateSkill(player.dexterity_exp_mult * xpMult, player.dexterity_mult) + + calculateSkill(player.charisma_exp_mult * xpMult, player.charisma_mult); + return calcRawDiff(player, total, startingDifficulty); +} + export function InfiltrationRoot(props: IProps): React.ReactElement { const player = use.Player(); const router = use.Router(); @@ -24,6 +41,8 @@ export function InfiltrationRoot(props: IProps): React.ReactElement { if (props.location.infiltrationData === undefined) throw new Error("Trying to do infiltration on invalid location."); const startingDifficulty = props.location.infiltrationData.startingSecurityLevel; const difficulty = calcDifficulty(player, startingDifficulty); + const reward = calcReward(player, startingDifficulty); + console.log(`${difficulty} ${reward}`); function cancel(): void { router.toCity(); @@ -45,6 +64,7 @@ export function InfiltrationRoot(props: IProps): React.ReactElement { ); diff --git a/src/Infiltration/ui/Victory.tsx b/src/Infiltration/ui/Victory.tsx index 2fcbff419..de3e181f0 100644 --- a/src/Infiltration/ui/Victory.tsx +++ b/src/Infiltration/ui/Victory.tsx @@ -13,6 +13,7 @@ import Select, { SelectChangeEvent } from "@mui/material/Select"; interface IProps { StartingDifficulty: number; Difficulty: number; + Reward: number; MaxLevel: number; } @@ -28,14 +29,14 @@ export function Victory(props: IProps): React.ReactElement { const levelBonus = props.MaxLevel * Math.pow(1.01, props.MaxLevel); const repGain = - Math.pow(props.Difficulty + 1, 1.1) * + Math.pow(props.Reward + 1, 1.1) * Math.pow(props.StartingDifficulty, 1.2) * 30 * levelBonus * BitNodeMultipliers.InfiltrationRep; const moneyGain = - Math.pow(props.Difficulty + 1, 2) * + Math.pow(props.Reward + 1, 2) * Math.pow(props.StartingDifficulty, 3) * 3e3 * levelBonus * diff --git a/src/utils/helpers/formatTime.ts b/src/utils/helpers/formatTime.ts index 4fddfba6e..4044314dd 100644 --- a/src/utils/helpers/formatTime.ts +++ b/src/utils/helpers/formatTime.ts @@ -4,7 +4,6 @@ export function formatTime(fmt: string): string { try { return format(new Date(), fmt); } catch (err: any) { - console.error(err); return "format error"; } }