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 {
StartingDifficulty: number;
Difficulty: number;
Reward: number;
MaxLevel: number;
}
@ -112,6 +113,7 @@ export function Game(props: IProps): React.ReactElement {
<Victory
StartingDifficulty={props.StartingDifficulty}
Difficulty={props.Difficulty}
Reward={props.Reward}
MaxLevel={props.MaxLevel}
/>
);

@ -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 {
<Game
StartingDifficulty={startingDifficulty}
Difficulty={difficulty}
Reward={reward}
MaxLevel={props.location.infiltrationData.maxClearanceLevel}
/>
);

@ -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 *

@ -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";
}
}