Finish removing player passing

This commit is contained in:
Snarling
2022-09-17 21:09:15 -04:00
parent c864fd7edf
commit 21a2d49de7
23 changed files with 112 additions and 203 deletions
+17 -17
View File
@@ -1,30 +1,30 @@
import { IPlayer } from "../../PersonObjects/IPlayer";
import { Player } from "../../Player";
import { calculateSkill } from "../../PersonObjects/formulas/skill";
function calculateRawDiff(player: IPlayer, stats: number, startingDifficulty: number): number {
const difficulty = startingDifficulty - Math.pow(stats, 0.9) / 250 - player.skills.intelligence / 1600;
function calculateRawDiff(stats: number, startingDifficulty: number): number {
const difficulty = startingDifficulty - Math.pow(stats, 0.9) / 250 - Player.skills.intelligence / 1600;
if (difficulty < 0) return 0;
if (difficulty > 3) return 3;
return difficulty;
}
export function calculateDifficulty(player: IPlayer, startingSecurityLevel: number): number {
export function calculateDifficulty(startingSecurityLevel: number): number {
const totalStats =
player.skills.strength +
player.skills.defense +
player.skills.dexterity +
player.skills.agility +
player.skills.charisma;
return calculateRawDiff(player, totalStats, startingSecurityLevel);
Player.skills.strength +
Player.skills.defense +
Player.skills.dexterity +
Player.skills.agility +
Player.skills.charisma;
return calculateRawDiff(totalStats, startingSecurityLevel);
}
export function calculateReward(player: IPlayer, startingSecurityLevel: number): number {
export function calculateReward(startingSecurityLevel: number): number {
const xpMult = 10 * 60 * 15;
const total =
calculateSkill(player.mults.strength_exp * xpMult, player.mults.strength) +
calculateSkill(player.mults.defense_exp * xpMult, player.mults.defense) +
calculateSkill(player.mults.agility_exp * xpMult, player.mults.agility) +
calculateSkill(player.mults.dexterity_exp * xpMult, player.mults.dexterity) +
calculateSkill(player.mults.charisma_exp * xpMult, player.mults.charisma);
return calculateRawDiff(player, total, startingSecurityLevel);
calculateSkill(Player.mults.strength_exp * xpMult, Player.mults.strength) +
calculateSkill(Player.mults.defense_exp * xpMult, Player.mults.defense) +
calculateSkill(Player.mults.agility_exp * xpMult, Player.mults.agility) +
calculateSkill(Player.mults.dexterity_exp * xpMult, Player.mults.dexterity) +
calculateSkill(Player.mults.charisma_exp * xpMult, Player.mults.charisma);
return calculateRawDiff(total, startingSecurityLevel);
}
+7 -17
View File
@@ -1,15 +1,10 @@
import { IPlayer } from "../../PersonObjects/IPlayer";
import { Player } from "../../Player";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
import { LocationsMetadata } from "../../Locations/data/LocationsMetadata";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { Faction } from "../../Faction/Faction";
export function calculateSellInformationCashReward(
player: IPlayer,
reward: number,
maxLevel: number,
difficulty: number,
): number {
export function calculateSellInformationCashReward(reward: number, maxLevel: number, difficulty: number): number {
const levelBonus = maxLevel * Math.pow(1.01, maxLevel);
return (
@@ -17,17 +12,12 @@ export function calculateSellInformationCashReward(
Math.pow(difficulty, 3) *
3e3 *
levelBonus *
(player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 1.5 : 1) *
(Player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 1.5 : 1) *
BitNodeMultipliers.InfiltrationMoney
);
}
export function calculateTradeInformationRepReward(
player: IPlayer,
reward: number,
maxLevel: number,
difficulty: number,
): number {
export function calculateTradeInformationRepReward(reward: number, maxLevel: number, difficulty: number): number {
const levelBonus = maxLevel * Math.pow(1.01, maxLevel);
return (
@@ -35,12 +25,12 @@ export function calculateTradeInformationRepReward(
Math.pow(difficulty, 1.2) *
30 *
levelBonus *
(player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 1.5 : 1) *
(Player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 1.5 : 1) *
BitNodeMultipliers.InfiltrationRep
);
}
export function calculateInfiltratorsRepReward(player: IPlayer, faction: Faction, difficulty: number): number {
export function calculateInfiltratorsRepReward(faction: Faction, difficulty: number): number {
const maxStartingSecurityLevel = LocationsMetadata.reduce((acc, data): number => {
const startingSecurityLevel = data.infiltrationData?.startingSecurityLevel || 0;
return acc > startingSecurityLevel ? acc : startingSecurityLevel;
@@ -48,6 +38,6 @@ export function calculateInfiltratorsRepReward(player: IPlayer, faction: Faction
const baseRepGain = (difficulty / maxStartingSecurityLevel) * 5000;
return (
baseRepGain * (player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 2 : 1) * (1 + faction.favor / 100)
baseRepGain * (Player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 2 : 1) * (1 + faction.favor / 100)
);
}
+2 -3
View File
@@ -1,7 +1,6 @@
import React, { useState } from "react";
import { Location } from "../../Locations/Location";
import { Router } from "../../ui/GameRoot";
import { Player } from "../../Player";
import { calculateDifficulty, calculateReward } from "../formulas/game";
import { Game } from "./Game";
import { Intro } from "./Intro";
@@ -14,8 +13,8 @@ export function InfiltrationRoot(props: IProps): React.ReactElement {
if (props.location.infiltrationData === undefined) throw new Error("Trying to do infiltration on invalid location.");
const startingSecurityLevel = props.location.infiltrationData.startingSecurityLevel;
const difficulty = calculateDifficulty(Player, startingSecurityLevel);
const reward = calculateReward(Player, startingSecurityLevel);
const difficulty = calculateDifficulty(startingSecurityLevel);
const reward = calculateReward(startingSecurityLevel);
function cancel(): void {
Router.toCity();
+3 -3
View File
@@ -30,9 +30,9 @@ export function Victory(props: IProps): React.ReactElement {
}
const soa = Factions[FactionNames.ShadowsOfAnarchy];
const repGain = calculateTradeInformationRepReward(Player, props.Reward, props.MaxLevel, props.StartingDifficulty);
const moneyGain = calculateSellInformationCashReward(Player, props.Reward, props.MaxLevel, props.StartingDifficulty);
const infiltrationRepGain = calculateInfiltratorsRepReward(Player, soa, props.StartingDifficulty);
const repGain = calculateTradeInformationRepReward(props.Reward, props.MaxLevel, props.StartingDifficulty);
const moneyGain = calculateSellInformationCashReward(props.Reward, props.MaxLevel, props.StartingDifficulty);
const infiltrationRepGain = calculateInfiltratorsRepReward(soa, props.StartingDifficulty);
const isMemberOfInfiltrators = Player.factions.includes(FactionNames.ShadowsOfAnarchy);