merge dev

This commit is contained in:
Olivier Gagnon
2021-10-26 23:11:47 -04:00
82 changed files with 1280 additions and 793 deletions
@@ -2,7 +2,6 @@ import { Factions } from "../../Faction/Factions";
import { Faction } from "../../Faction/Faction";
import { Gang } from "../../Gang/Gang";
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
import { IPlayer } from "../IPlayer";
// Amount of negative karma needed to manage a gang in BitNodes other than 2
@@ -16,7 +15,7 @@ export function canAccessGang(this: IPlayer): boolean {
return false;
}
return this.karma <= BitNodeMultipliers.GangKarmaRequirement * GangKarmaRequirement;
return this.karma <= GangKarmaRequirement;
}
export function getGangFaction(this: IPlayer): Faction {
@@ -59,6 +59,7 @@ import { Money } from "../../ui/React/Money";
import React from "react";
import { serverMetadata } from "../../Server/data/servers";
import { SnackbarEvents } from "../../ui/React/Snackbar";
export function init(this: IPlayer): void {
/* Initialize Player's home computer */
@@ -629,6 +630,7 @@ export function work(this: IPlayer, numCycles: number): boolean {
this.timeWorked += CONSTANTS._idleSpeed * numCycles;
this.workRepGainRate = this.getWorkRepGain();
this.workMoneyGainRate = this.getWorkMoneyGain();
this.processWorkEarnings(numCycles);
const comp = Companies[this.companyName];
@@ -1697,13 +1699,7 @@ export function regenerateHp(this: IPlayer, amt: number): void {
export function hospitalize(this: IPlayer): number {
const cost = getHospitalizationCost(this);
if (Settings.SuppressHospitalizationPopup === false) {
dialogBoxCreate(
<>
You were in critical condition! You were taken to the hospital where luckily they were able to save your life.
You were charged&nbsp;
<Money money={cost} />
</>,
);
SnackbarEvents.emit(`You've been Hospitalized for ${numeralWrapper.formatMoney(cost)}`, "warning");
}
this.loseMoney(cost);
@@ -1785,6 +1781,7 @@ export function applyForJob(this: IPlayer, entryPosType: CompanyPosition, sing =
}
this.jobs[company.name] = pos.name;
if (!this.focus && this.isWorking && this.companyName !== this.location) this.resetWorkStatus();
this.companyName = this.location;
if (!sing) {
+5 -5
View File
@@ -143,8 +143,8 @@ export class Sleeve extends Person {
* Commit crimes
*/
commitCrime(p: IPlayer, crimeKey: string): boolean {
const crime: Crime | null = Crimes[crimeKey];
if (!(crime instanceof Crime)) {
const crime: Crime | null = Crimes[crimeKey] || Object.values(Crimes).find((crime) => crime.name === crimeKey);
if (!crime) {
return false;
}
@@ -164,7 +164,7 @@ export class Sleeve extends Person {
this.currentTaskLocation = String(this.gainRatesForTask.money);
this.crimeType = crimeKey;
this.crimeType = crime.name;
this.currentTaskMaxTime = crime.time;
this.currentTask = SleeveTaskType.Crime;
return true;
@@ -179,8 +179,8 @@ export class Sleeve extends Person {
if (this.currentTask === SleeveTaskType.Crime) {
// For crimes, all experience and money is gained at the end
if (this.currentTaskTime >= this.currentTaskMaxTime) {
const crime: Crime | null = Crimes[this.crimeType];
if (!(crime instanceof Crime)) {
const crime: Crime | undefined = Object.values(Crimes).find((crime) => crime.name === this.crimeType);
if (!crime) {
console.error(`Invalid data stored in sleeve.crimeType: ${this.crimeType}`);
this.resetTaskStatus();
return retValue;
+6 -3
View File
@@ -104,14 +104,17 @@ export function SleeveElem(props: IProps): React.ReactElement {
);
break;
}
case SleeveTaskType.Crime:
case SleeveTaskType.Crime: {
const crime = Object.values(Crimes).find((crime) => crime.name === props.sleeve.crimeType);
if (!crime) throw new Error("crime should not be undefined");
desc = (
<>
This sleeve is currently attempting to {Crimes[props.sleeve.crimeType].type} (Success Rate:{" "}
{numeralWrapper.formatPercentage(Crimes[props.sleeve.crimeType].successRate(props.sleeve))}).
This sleeve is currently attempting to {crime.type} (Success Rate:{" "}
{numeralWrapper.formatPercentage(crime.successRate(props.sleeve))}).
</>
);
break;
}
case SleeveTaskType.Class:
desc = <>This sleeve is currently studying/taking a course at {props.sleeve.currentTaskLocation}.</>;
break;
+1 -1
View File
@@ -122,7 +122,7 @@ const tasks: {
};
},
"Commit Crime": (): ITaskDetails => {
return { first: Object.keys(Crimes), second: () => ["------"] };
return { first: Object.values(Crimes).map((crime) => crime.name), second: () => ["------"] };
},
"Take University Course": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
let universities: string[] = [];