This commit is contained in:
Olivier Gagnon 2021-09-20 01:45:32 -04:00
parent 34313e8100
commit 8db57d7e81
14 changed files with 100 additions and 92 deletions

36
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,6 +1,7 @@
import { CONSTANTS } from "../Constants";
import { IPlayer } from "../PersonObjects/IPlayer";
import { IPlayerOrSleeve } from "../PersonObjects/IPlayerOrSleeve";
import { IRouter } from "../ui/Router";
export interface IConstructorParams {
hacking_success_weight?: number;
@ -85,11 +86,12 @@ export class Crime {
this.kills = params.kills ? params.kills : 0;
}
commit(p: IPlayer, div = 1, singParams: any = null): number {
commit(router: IRouter, p: IPlayer, div = 1, singParams: any = null): number {
if (div <= 0) {
div = 1;
}
p.startCrime(
router,
this.type,
this.hacking_exp / div,
this.strength_exp / div,

@ -104,13 +104,11 @@ export function FactionRoot(props: IProps): React.ReactElement {
}
function startFieldWork(faction: Faction): void {
player.startFactionFieldWork(faction);
router.toWork();
player.startFactionFieldWork(router, faction);
}
function startHackingContracts(faction: Faction): void {
player.startFactionHackWork(faction);
router.toWork();
player.startFactionHackWork(router, faction);
}
function startHackingMission(faction: Faction): void {
@ -119,8 +117,7 @@ export function FactionRoot(props: IProps): React.ReactElement {
}
function startSecurityWork(faction: Faction): void {
player.startFactionSecurityWork(faction);
router.toWork();
player.startFactionSecurityWork(router, faction);
}
function MainPage({ faction }: { faction: Faction }): React.ReactElement {

@ -168,9 +168,9 @@ export function CompanyLocation(props: IProps): React.ReactElement {
const pos = companyPosition;
if (pos instanceof CompanyPosition) {
if (pos.isPartTimeJob() || pos.isSoftwareConsultantJob() || pos.isBusinessConsultantJob()) {
p.startWorkPartTime(props.locName);
p.startWorkPartTime(router, props.locName);
} else {
p.startWork(props.locName);
p.startWork(router, props.locName);
}
router.toWork();
}

@ -47,7 +47,7 @@ export function GenericLocation({ loc }: IProps): React.ReactElement {
}
if (loc.types.includes(LocationType.Gym)) {
content.push(<GymLocation key={"gymlocation"} loc={loc} p={player} />);
content.push(<GymLocation key={"gymlocation"} router={router} loc={loc} p={player} />);
}
if (loc.types.includes(LocationType.Hospital)) {

@ -15,10 +15,12 @@ import { SpecialServerIps } from "../../Server/SpecialServerIps";
import { StdButton } from "../../ui/React/StdButton";
import { Money } from "../../ui/React/Money";
import { IRouter } from "../../ui/Router";
type IProps = {
loc: Location;
p: IPlayer;
router: IRouter;
};
export class GymLocation extends React.Component<IProps, any> {
@ -50,7 +52,7 @@ export class GymLocation extends React.Component<IProps, any> {
train(stat: string): void {
const loc = this.props.loc;
this.props.p.startClass(this.calculateCost(), loc.expMult, stat);
this.props.p.startClass(this.props.router, this.calculateCost(), loc.expMult, stat);
}
trainStrength(): void {

@ -18,96 +18,84 @@ export function SlumsLocation(): React.ReactElement {
if (!e.isTrusted) {
return;
}
Crimes.Shoplift.commit(player);
router.toWork();
Crimes.Shoplift.commit(router, player);
}
function robStore(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.RobStore.commit(player);
router.toWork();
Crimes.RobStore.commit(router, player);
}
function mug(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.Mug.commit(player);
router.toWork();
Crimes.Mug.commit(router, player);
}
function larceny(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.Larceny.commit(player);
router.toWork();
Crimes.Larceny.commit(router, player);
}
function dealDrugs(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.DealDrugs.commit(player);
router.toWork();
Crimes.DealDrugs.commit(router, player);
}
function bondForgery(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.BondForgery.commit(player);
router.toWork();
Crimes.BondForgery.commit(router, player);
}
function traffickArms(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.TraffickArms.commit(player);
router.toWork();
Crimes.TraffickArms.commit(router, player);
}
function homicide(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.Homicide.commit(player);
router.toWork();
Crimes.Homicide.commit(router, player);
}
function grandTheftAuto(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.GrandTheftAuto.commit(player);
router.toWork();
Crimes.GrandTheftAuto.commit(router, player);
}
function kidnap(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.Kidnap.commit(player);
router.toWork();
Crimes.Kidnap.commit(router, player);
}
function assassinate(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.Assassination.commit(player);
router.toWork();
Crimes.Assassination.commit(router, player);
}
function heist(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
Crimes.Heist.commit(player);
router.toWork();
Crimes.Heist.commit(router, player);
}
const shopliftChance = Crimes.Shoplift.successRate(player);

@ -34,8 +34,7 @@ export function UniversityLocation(props: IProps): React.ReactElement {
function take(stat: string): void {
const loc = props.loc;
player.startClass(calculateCost(), loc.expMult, stat);
router.toWork();
player.startClass(router, calculateCost(), loc.expMult, stat);
}
function study(): void {

@ -136,7 +136,8 @@ import { Interpreter } from "./JSInterpreter";
import { NetscriptPort } from "./NetscriptPort";
import { SleeveTaskType } from "./PersonObjects/Sleeve/SleeveTaskTypesEnum";
import { findSleevePurchasableAugs } from "./PersonObjects/Sleeve/SleeveHelpers";
import { Exploit } from "./Exploits/Exploit.ts";
import { Exploit } from "./Exploits/Exploit";
import { Router } from "./ui/GameRoot";
import { numeralWrapper } from "./ui/numeralFormat";
import { setTimeoutRef } from "./utils/SetTimeoutRef";
@ -2894,7 +2895,7 @@ function NetscriptFunctions(workerScript) {
workerScript.log("universityCourse", `Invalid class name: ${className}.`);
return false;
}
Player.startClass(costMult, expMult, task);
Player.startClass(Router, costMult, expMult, task);
workerScript.log("universityCourse", `Started ${task} at ${universityName}`);
return true;
},
@ -2971,19 +2972,19 @@ function NetscriptFunctions(workerScript) {
switch (stat.toLowerCase()) {
case "strength".toLowerCase():
case "str".toLowerCase():
Player.startClass(costMult, expMult, CONSTANTS.ClassGymStrength);
Player.startClass(Router, costMult, expMult, CONSTANTS.ClassGymStrength);
break;
case "defense".toLowerCase():
case "def".toLowerCase():
Player.startClass(costMult, expMult, CONSTANTS.ClassGymDefense);
Player.startClass(Router, costMult, expMult, CONSTANTS.ClassGymDefense);
break;
case "dexterity".toLowerCase():
case "dex".toLowerCase():
Player.startClass(costMult, expMult, CONSTANTS.ClassGymDexterity);
Player.startClass(Router, costMult, expMult, CONSTANTS.ClassGymDexterity);
break;
case "agility".toLowerCase():
case "agi".toLowerCase():
Player.startClass(costMult, expMult, CONSTANTS.ClassGymAgility);
Player.startClass(Router, costMult, expMult, CONSTANTS.ClassGymAgility);
break;
default:
workerScript.log("gymWorkout", `Invalid stat: ${stat}.`);
@ -3419,9 +3420,9 @@ function NetscriptFunctions(workerScript) {
}
if (companyPosition.isPartTimeJob()) {
Player.startWorkPartTime(companyName);
Player.startWorkPartTime(Router, companyName);
} else {
Player.startWork(companyName);
Player.startWork(Router, companyName);
}
workerScript.log("workForCompany", `Began working at '${Player.companyName}' as a '${companyPositionName}'`);
return true;
@ -3660,7 +3661,7 @@ function NetscriptFunctions(workerScript) {
workerScript.log("workForFaction", `Faction '${fac.name}' do not need help with hacking contracts.`);
return false;
}
Player.startFactionHackWork(fac);
Player.startFactionHackWork(Router, fac);
workerScript.log("workForFaction", `Started carrying out hacking contracts for '${fac.name}'`);
return true;
case "field":
@ -3670,7 +3671,7 @@ function NetscriptFunctions(workerScript) {
workerScript.log("workForFaction", `Faction '${fac.name}' do not need help with field missions.`);
return false;
}
Player.startFactionFieldWork(fac);
Player.startFactionFieldWork(Router, fac);
workerScript.log("workForFaction", `Started carrying out field missions for '${fac.name}'`);
return true;
case "security":
@ -3680,7 +3681,7 @@ function NetscriptFunctions(workerScript) {
workerScript.log("workForFaction", `Faction '${fac.name}' do not need help with security work.`);
return false;
}
Player.startFactionSecurityWork(fac);
Player.startFactionSecurityWork(Router, fac);
workerScript.log("workForFaction", `Started carrying out security work for '${fac.name}'`);
return true;
default:
@ -3781,7 +3782,7 @@ function NetscriptFunctions(workerScript) {
return false;
}
Player.startCreateProgramWork(p.name, p.create.time, p.create.level);
Player.startCreateProgramWork(Router, p.name, p.create.time, p.create.level);
workerScript.log("createProgram", `Began creating program: '${name}'`);
return true;
},
@ -3806,7 +3807,7 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeErrorMsg("commitCrime", `Invalid crime: '${crimeRoughName}'`);
}
workerScript.log("commitCrime", `Attempting to commit ${crime.name}...`);
return crime.commit(Player, 1, { workerscript: workerScript });
return crime.commit(Router, Player, 1, { workerscript: workerScript });
},
getCrimeChance: function (crimeRoughName) {
updateDynamicRam("getCrimeChance", getRamCost("getCrimeChance"));

@ -25,6 +25,7 @@ import { ICorporation } from "../Corporation/ICorporation";
import { IGang } from "../Gang/IGang";
import { IBladeburner } from "../Bladeburner/IBladeburner";
import { ICodingContractReward } from "../CodingContracts";
import { IRouter } from "../ui/Router";
export interface IPlayer {
// Class members
@ -200,9 +201,10 @@ export interface IPlayer {
setMoney(amt: number): void;
singularityStopWork(): void;
startBladeburner(p: any): void;
startClass(costMult: number, expMult: number, className: string): void;
startClass(router: IRouter, costMult: number, expMult: number, className: string): void;
startCorporation(corpName: string, additionalShares?: number): void;
startCrime(
router: IRouter,
crimeType: string,
hackExp: number,
strExp: number,
@ -214,13 +216,13 @@ export interface IPlayer {
time: number,
singParams: any,
): void;
startFactionFieldWork(faction: Faction): void;
startFactionHackWork(faction: Faction): void;
startFactionSecurityWork(faction: Faction): void;
startFactionFieldWork(router: IRouter, faction: Faction): void;
startFactionHackWork(router: IRouter, faction: Faction): void;
startFactionSecurityWork(router: IRouter, faction: Faction): void;
startFocusing(): void;
startGang(facName: string, isHacking: boolean): void;
startWork(companyName: string): void;
startWorkPartTime(companyName: string): void;
startWork(router: IRouter, companyName: string): void;
startWorkPartTime(router: IRouter, companyName: string): void;
takeDamage(amt: number): boolean;
travel(to: CityName): boolean;
giveExploit(exploit: Exploit): void;
@ -229,7 +231,7 @@ export interface IPlayer {
getCasinoWinnings(): number;
quitJob(company: string): void;
createHacknetServer(): void;
startCreateProgramWork(programName: string, time: number, reqLevel: number): void;
startCreateProgramWork(router: IRouter, programName: string, time: number, reqLevel: number): void;
queueAugmentation(augmentationName: string): void;
receiveInvite(factionName: string): void;
updateSkillLevels(): void;

@ -546,7 +546,7 @@ export function processWorkEarnings(numCycles = 1) {
}
/* Working for Company */
export function startWork(companyName) {
export function startWork(router, companyName) {
this.resetWorkStatus(CONSTANTS.WorkTypeCompany, companyName);
this.isWorking = true;
this.focus = true;
@ -563,6 +563,7 @@ export function startWork(companyName) {
this.workMoneyGainRate = this.getWorkMoneyGain();
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
router.toWork();
}
export function cancelationPenalty() {
@ -678,7 +679,7 @@ export function finishWork(cancelled, sing = false) {
this.resetWorkStatus();
}
export function startWorkPartTime(companyName) {
export function startWorkPartTime(router, companyName) {
this.resetWorkStatus(CONSTANTS.WorkTypeCompanyPartTime, companyName);
this.isWorking = true;
this.focus = true;
@ -695,6 +696,7 @@ export function startWorkPartTime(companyName) {
this.workMoneyGainRate = this.getWorkMoneyGain();
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
router.toWork();
}
export function workPartTime(numCycles) {
@ -785,7 +787,7 @@ export function stopFocusing() {
}
/* Working for Faction */
export function startFactionWork(faction) {
export function startFactionWork(router, faction) {
//Update reputation gain rate to account for faction favor
var favorMult = 1 + faction.favor / 100;
if (isNaN(favorMult)) {
@ -800,9 +802,10 @@ export function startFactionWork(faction) {
this.currentWorkFactionName = faction.name;
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer20Hours;
router.toWork();
}
export function startFactionHackWork(faction) {
export function startFactionHackWork(router, faction) {
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkHacking);
this.workHackExpGainRate = 0.15 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
@ -814,10 +817,10 @@ export function startFactionHackWork(faction) {
this.factionWorkType = CONSTANTS.FactionWorkHacking;
this.currentWorkFactionDescription = "carrying out hacking contracts";
this.startFactionWork(faction);
this.startFactionWork(router, faction);
}
export function startFactionFieldWork(faction) {
export function startFactionFieldWork(router, faction) {
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkField);
this.workHackExpGainRate = 0.1 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
@ -831,10 +834,10 @@ export function startFactionFieldWork(faction) {
this.factionWorkType = CONSTANTS.FactionWorkField;
this.currentWorkFactionDescription = "carrying out field missions";
this.startFactionWork(faction);
this.startFactionWork(router, faction);
}
export function startFactionSecurityWork(faction) {
export function startFactionSecurityWork(router, faction) {
this.resetWorkStatus(CONSTANTS.WorkTypeFaction, faction.name, CONSTANTS.FactionWorkSecurity);
this.workHackExpGainRate = 0.05 * this.hacking_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
@ -848,7 +851,7 @@ export function startFactionSecurityWork(faction) {
this.factionWorkType = CONSTANTS.FactionWorkSecurity;
this.currentWorkFactionDescription = "performing security detail";
this.startFactionWork(faction);
this.startFactionWork(router, faction);
}
export function workForFaction(numCycles) {
@ -1171,7 +1174,7 @@ export function getWorkRepGain() {
// }
/* Creating a Program */
export function startCreateProgramWork(programName, time, reqLevel) {
export function startCreateProgramWork(router, programName, time, reqLevel) {
this.resetWorkStatus();
this.isWorking = true;
this.focus = true;
@ -1203,6 +1206,7 @@ export function startCreateProgramWork(programName, time, reqLevel) {
}
this.createProgramName = programName;
router.toWork();
}
export function createProgramWork(numCycles) {
@ -1246,7 +1250,7 @@ export function finishCreateProgramWork(cancelled) {
}
/* Studying/Taking Classes */
export function startClass(costMult, expMult, className) {
export function startClass(router, costMult, expMult, className) {
this.resetWorkStatus();
this.isWorking = true;
this.focus = true;
@ -1317,6 +1321,7 @@ export function startClass(costMult, expMult, className) {
this.workDexExpGainRate = dexExp * this.dexterity_exp_mult * BitNodeMultipliers.ClassGymExpGain;
this.workAgiExpGainRate = agiExp * this.agility_exp_mult * BitNodeMultipliers.ClassGymExpGain;
this.workChaExpGainRate = chaExp * this.charisma_exp_mult * BitNodeMultipliers.ClassGymExpGain;
router.toWork();
}
export function takeClass(numCycles) {
@ -1385,7 +1390,19 @@ export function finishClass(sing = false) {
}
//The EXP and $ gains are hardcoded. Time is in ms
export function startCrime(crimeType, hackExp, strExp, defExp, dexExp, agiExp, chaExp, money, time, singParams = null) {
export function startCrime(
router,
crimeType,
hackExp,
strExp,
defExp,
dexExp,
agiExp,
chaExp,
money,
time,
singParams = null,
) {
this.crimeType = crimeType;
this.resetWorkStatus();
@ -1407,6 +1424,7 @@ export function startCrime(crimeType, hackExp, strExp, defExp, dexExp, agiExp, c
this.workMoneyGained = money * this.crime_money_mult * BitNodeMultipliers.CrimeMoney;
this.timeNeededToCompleteWork = time;
router.toWork();
}
export function commitCrime(numCycles) {

@ -37,8 +37,7 @@ export function ProgramsRoot(): React.ReactElement {
<Tooltip key={program.name} title={create.tooltip}>
<Button
onClick={() => {
player.startCreateProgramWork(program.name, create.time, create.level);
router.toWork();
player.startCreateProgramWork(router, program.name, create.time, create.level);
}}
>
{program.name}