make infil reward more consistent.

This commit is contained in:
Olivier Gagnon 2021-12-03 15:11:31 -05:00
parent 68cff084ff
commit e6b263e6ec
4 changed files with 28 additions and 6 deletions

@ -16,6 +16,7 @@ import Typography from "@mui/material/Typography";
interface IProps { interface IProps {
StartingDifficulty: number; StartingDifficulty: number;
Difficulty: number; Difficulty: number;
Reward: number;
MaxLevel: number; MaxLevel: number;
} }
@ -112,6 +113,7 @@ export function Game(props: IProps): React.ReactElement {
<Victory <Victory
StartingDifficulty={props.StartingDifficulty} StartingDifficulty={props.StartingDifficulty}
Difficulty={props.Difficulty} Difficulty={props.Difficulty}
Reward={props.Reward}
MaxLevel={props.MaxLevel} MaxLevel={props.MaxLevel}
/> />
); );

@ -4,18 +4,35 @@ import { Intro } from "./Intro";
import { Game } from "./Game"; import { Game } from "./Game";
import { Location } from "../../Locations/Location"; import { Location } from "../../Locations/Location";
import { use } from "../../ui/Context"; import { use } from "../../ui/Context";
import { calculateSkill } from "../../PersonObjects/formulas/skill";
interface IProps { interface IProps {
location: Location; location: Location;
} }
function calcDifficulty(player: IPlayer, startingDifficulty: number): number {
const totalStats = player.strength + player.defense + player.dexterity + player.agility + player.charisma; function calcRawDiff(player: IPlayer, stats: number, startingDifficulty: number): number {
const difficulty = startingDifficulty - Math.pow(totalStats, 0.9) / 250 - player.intelligence / 1600; const difficulty = startingDifficulty - Math.pow(stats, 0.9) / 250 - player.intelligence / 1600;
if (difficulty < 0) return 0; if (difficulty < 0) return 0;
if (difficulty > 3) return 3; if (difficulty > 3) return 3;
return difficulty; 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 { export function InfiltrationRoot(props: IProps): React.ReactElement {
const player = use.Player(); const player = use.Player();
const router = use.Router(); 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."); if (props.location.infiltrationData === undefined) throw new Error("Trying to do infiltration on invalid location.");
const startingDifficulty = props.location.infiltrationData.startingSecurityLevel; const startingDifficulty = props.location.infiltrationData.startingSecurityLevel;
const difficulty = calcDifficulty(player, startingDifficulty); const difficulty = calcDifficulty(player, startingDifficulty);
const reward = calcReward(player, startingDifficulty);
console.log(`${difficulty} ${reward}`);
function cancel(): void { function cancel(): void {
router.toCity(); router.toCity();
@ -45,6 +64,7 @@ export function InfiltrationRoot(props: IProps): React.ReactElement {
<Game <Game
StartingDifficulty={startingDifficulty} StartingDifficulty={startingDifficulty}
Difficulty={difficulty} Difficulty={difficulty}
Reward={reward}
MaxLevel={props.location.infiltrationData.maxClearanceLevel} MaxLevel={props.location.infiltrationData.maxClearanceLevel}
/> />
); );

@ -13,6 +13,7 @@ import Select, { SelectChangeEvent } from "@mui/material/Select";
interface IProps { interface IProps {
StartingDifficulty: number; StartingDifficulty: number;
Difficulty: number; Difficulty: number;
Reward: number;
MaxLevel: 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 levelBonus = props.MaxLevel * Math.pow(1.01, props.MaxLevel);
const repGain = const repGain =
Math.pow(props.Difficulty + 1, 1.1) * Math.pow(props.Reward + 1, 1.1) *
Math.pow(props.StartingDifficulty, 1.2) * Math.pow(props.StartingDifficulty, 1.2) *
30 * 30 *
levelBonus * levelBonus *
BitNodeMultipliers.InfiltrationRep; BitNodeMultipliers.InfiltrationRep;
const moneyGain = const moneyGain =
Math.pow(props.Difficulty + 1, 2) * Math.pow(props.Reward + 1, 2) *
Math.pow(props.StartingDifficulty, 3) * Math.pow(props.StartingDifficulty, 3) *
3e3 * 3e3 *
levelBonus * levelBonus *

@ -4,7 +4,6 @@ export function formatTime(fmt: string): string {
try { try {
return format(new Date(), fmt); return format(new Date(), fmt);
} catch (err: any) { } catch (err: any) {
console.error(err);
return "format error"; return "format error";
} }
} }