Fix relevant linter errors and run formatter

This commit is contained in:
Staszek Welsh 2022-06-02 22:51:36 +01:00
parent b29c8e0039
commit 02b07bb332
9 changed files with 84 additions and 69 deletions

@ -13,7 +13,6 @@ import { CorporationUnlockUpgrade } from "./data/CorporationUnlockUpgrades";
import { CorporationUpgrade } from "./data/CorporationUpgrades";
import { Cities } from "../Locations/Cities";
import { EmployeePositions } from "./EmployeePositions";
import { Employee } from "./Employee";
import { ResearchMap } from "./ResearchMap";
import { isRelevantMaterial } from "./ui/Helpers";
@ -304,7 +303,7 @@ export function BuyBackShares(corporation: ICorporation, player: IPlayer, numSha
}
export function AssignJob(office: OfficeSpace, employeeName: string, job: string): void {
const employee = office.employees.find(e => e.name === employeeName);
const employee = office.employees.find((e) => e.name === employeeName);
if (!employee) throw new Error(`Could not find employee '${name}'.`);
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
@ -334,9 +333,13 @@ export function UpgradeOfficeSize(corp: ICorporation, office: OfficeSpace, size:
export function BuyCoffee(corp: ICorporation, office: OfficeSpace): boolean {
const cost = office.getCoffeeCost();
if (corp.funds < cost) { return false; }
if (corp.funds < cost) {
return false;
}
if (!office.setCoffee()) { return false; }
if (!office.setCoffee()) {
return false;
}
corp.funds -= cost;
return true;
@ -345,9 +348,13 @@ export function BuyCoffee(corp: ICorporation, office: OfficeSpace): boolean {
export function ThrowParty(corp: ICorporation, office: OfficeSpace, costPerEmployee: number): number {
const mult = 1 + costPerEmployee / 10e6;
const cost = costPerEmployee * office.employees.length;
if (corp.funds < cost) { return 0; }
if (corp.funds < cost) {
return 0;
}
if (!office.setParty(mult)) { return 0; }
if (!office.setParty(mult)) {
return 0;
}
corp.funds -= cost;
return mult;

@ -3,7 +3,6 @@ import { getRandomInt } from "../utils/helpers/getRandomInt";
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
import { EmployeePositions } from "./EmployeePositions";
import { ICorporation } from "./ICorporation";
import { OfficeSpace } from "./OfficeSpace";
import { IIndustry } from "./IIndustry";
interface IParams {
@ -57,7 +56,7 @@ export class Employee {
}
//Returns the amount the employee needs to be paid
process(marketCycles = 1, office: OfficeSpace): number {
process(marketCycles = 1): number {
const gain = 0.003 * marketCycles;
const det = gain * Math.random();
this.exp += gain;

@ -78,7 +78,9 @@ export class OfficeSpace {
}
// Update employee jobs and job counts
for (const employee of this.employees) { employee.pos = employee.nextPos; }
for (const employee of this.employees) {
employee.pos = employee.nextPos;
}
this.calculateTotalEmployees();
this.calculateNextEmployees();
@ -113,13 +115,13 @@ export class OfficeSpace {
let totalSalary = 0;
for (const employee of this.employees) {
const salary = employee.process(marketCycles, this);
const salary = employee.process(marketCycles);
totalSalary += salary;
if (this.autoCoffee) {
employee.ene = this.maxEne;
} else if (this.coffeeMult > 1) {
const mult = 1 + (this.coffeeMult - 1) * this.employees.length / this.coffeeEmployees;
const mult = 1 + ((this.coffeeMult - 1) * this.employees.length) / this.coffeeEmployees;
employee.ene *= mult;
} else {
employee.ene *= perfMult;
@ -129,7 +131,7 @@ export class OfficeSpace {
employee.mor = this.maxMor;
employee.hap = this.maxHap;
} else if (this.partyMult > 1) {
const mult = 1 + (this.partyMult - 1) * this.employees.length / this.partyEmployees;
const mult = 1 + ((this.partyMult - 1) * this.employees.length) / this.partyEmployees;
employee.mor *= mult;
employee.hap *= mult;
} else {

@ -128,24 +128,30 @@ export class Product {
// Make progress on this product based on current employee productivity
createProduct(marketCycles: number, employeeProd: typeof this["creationProd"]): void {
if (this.fin) { return; }
if (this.fin) {
return;
}
// Designing/Creating a Product is based mostly off Engineers
const opProd = employeeProd[EmployeePositions.Operations];
const engrProd = employeeProd[EmployeePositions.Engineer];
const mgmtProd = employeeProd[EmployeePositions.Management];
const total = opProd + engrProd + mgmtProd;
if (total <= 0) { return; }
if (total <= 0) {
return;
}
// Management is a multiplier for the production from Engineers
const mgmtFactor = 1 + mgmtProd / (1.2 * total);
const prodMult = (Math.pow(engrProd, 0.34) + Math.pow(opProd, 0.2)) * mgmtFactor;
const progress = Math.min(marketCycles * 0.01 * prodMult, 100 - this.prog);
if (progress <= 0) { return; }
if (progress <= 0) {
return;
}
this.prog += progress;
for (const pos of Object.keys(employeeProd)) {
this.creationProd[pos] += employeeProd[pos] * progress / 100;
this.creationProd[pos] += (employeeProd[pos] * progress) / 100;
}
}

@ -25,7 +25,7 @@ export function Industry(props: IProps): React.ReactElement {
return (
<Box display="flex">
<Box sx={{ width: "50%" }}>
<IndustryOverview rerender={props.rerender} currentCity={props.city} office={props.office} />
<IndustryOverview rerender={props.rerender} />
<IndustryOffice rerender={props.rerender} office={props.office} />
</Box>
<Box sx={{ width: "50%" }}>

@ -36,14 +36,6 @@ interface IProps {
rerender: () => void;
}
function countEmployee(employees: Employee[], job: string): number {
let n = 0;
for (let i = 0; i < employees.length; ++i) {
if (employees[i].pos === job) n++;
}
return n;
}
interface ISwitchProps {
manualMode: boolean;
switchMode: (f: (b: boolean) => boolean) => void;
@ -181,7 +173,7 @@ interface IAutoAssignProps {
rerender: () => void;
}
function EmployeeCount(props: { num: number, next: number }): React.ReactElement {
function EmployeeCount(props: { num: number; next: number }): React.ReactElement {
return (
<Typography display="flex" alignItems="center" justifyContent="flex-end">
{props.num === props.next ? null : props.num}
@ -192,9 +184,6 @@ function EmployeeCount(props: { num: number, next: number }): React.ReactElement
}
function AutoAssignJob(props: IAutoAssignProps): React.ReactElement {
const corp = useCorporation();
const division = useDivision();
const currJob = props.office.employeeJobs[props.job];
const nextJob = props.office.employeeNextJobs[props.job];
const nextUna = props.office.employeeNextJobs[EmployeePositions.Unassigned];
@ -319,9 +308,9 @@ function AutoManagement(props: IProps): React.ReactElement {
<Tooltip
title={
<Typography>
The base amount of material this office can produce. Does not include production multipliers
from upgrades and materials. This value is based off the productivity of your Operations,
Engineering, and Management employees
The base amount of material this office can produce. Does not include production multipliers from
upgrades and materials. This value is based off the productivity of your Operations, Engineering,
and Management employees
</Typography>
}
>
@ -473,8 +462,17 @@ export function IndustryOffice(props: IProps): React.ReactElement {
title={<Typography>Throw an office party to increase your employee's morale and happiness</Typography>}
>
<span>
<Button disabled={corp.funds < props.office.getCoffeeCost() || props.office.coffeeMult > 0} onClick={() => BuyCoffee(corp, props.office)}>
{props.office.coffeeMult > 0 ? "Buying coffee..." : <span>Buy Coffee - <MoneyCost money={props.office.getCoffeeCost()} corp={corp} /></span>}
<Button
disabled={corp.funds < props.office.getCoffeeCost() || props.office.coffeeMult > 0}
onClick={() => BuyCoffee(corp, props.office)}
>
{props.office.coffeeMult > 0 ? (
"Buying coffee..."
) : (
<span>
Buy Coffee - <MoneyCost money={props.office.getCoffeeCost()} corp={corp} />
</span>
)}
</Button>
</span>
</Tooltip>
@ -487,7 +485,10 @@ export function IndustryOffice(props: IProps): React.ReactElement {
title={<Typography>Throw an office party to increase your employee's morale and happiness</Typography>}
>
<span>
<Button disabled={corp.funds < 0 || props.office.partyMult > 0} onClick={() => setThrowPartyOpen(true)}>
<Button
disabled={corp.funds < 0 || props.office.partyMult > 0}
onClick={() => setThrowPartyOpen(true)}
>
{props.office.partyMult > 0 ? "Throwing Party..." : "Throw Party"}
</Button>
</span>

@ -2,7 +2,6 @@
// (top-left panel in the Industry UI)
import React, { useState } from "react";
import { OfficeSpace } from "../OfficeSpace";
import { Industries } from "../IndustryData";
import { HireAdVert } from "../Actions";
import { numeralWrapper } from "../../ui/numeralFormat";
@ -89,8 +88,6 @@ function MakeProductButton(): React.ReactElement {
}
interface IProps {
currentCity: string;
office: OfficeSpace;
rerender: () => void;
}
@ -218,14 +215,20 @@ export function IndustryOverview(props: IProps): React.ReactElement {
<Tooltip
title={
<Typography>
Hire AdVert.Inc to advertise your company. Each level of
this upgrade grants your company a static increase of 3 and 1 to its awareness and
popularity, respectively. It will then increase your company's awareness by 1%, and its popularity
by a random percentage between 1% and 3%. These effects are increased by other upgrades
that increase the power of your advertising.
Hire AdVert.Inc to advertise your company. Each level of this upgrade grants your company a static
increase of 3 and 1 to its awareness and popularity, respectively. It will then increase your company's
awareness by 1%, and its popularity by a random percentage between 1% and 3%. These effects are increased
by other upgrades that increase the power of your advertising.
</Typography>
}>
<Button disabled={division.getAdVertCost() > corp.funds} onClick={() => HireAdVert(corp, division)}>
}
>
<Button
disabled={division.getAdVertCost() > corp.funds}
onClick={function () {
HireAdVert(corp, division);
props.rerender();
}}
>
Hire AdVert -&nbsp; <MoneyCost money={division.getAdVertCost()} corp={corp} />
</Button>
</Tooltip>

@ -531,7 +531,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
bladeburner: NetscriptBladeburner(Player, workerScript),
codingcontract: NetscriptCodingContract(Player, workerScript),
sleeve: NetscriptSleeve(Player),
corporation: NetscriptCorporation(Player, workerScript),
corporation: NetscriptCorporation(Player),
stanek: NetscriptStanek(Player, workerScript, helper),
infiltration: NetscriptInfiltration(Player),
ui: NetscriptUserInterface(),

@ -1,6 +1,4 @@
import { WorkerScript } from "../Netscript/WorkerScript";
import { IPlayer } from "../PersonObjects/IPlayer";
import { netscriptDelay } from "../NetscriptEvaluator";
import { OfficeSpace } from "../Corporation/OfficeSpace";
import { Employee } from "../Corporation/Employee";
@ -60,7 +58,6 @@ import {
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades";
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
import { EmployeePositions } from "../Corporation/EmployeePositions";
import { calculateIntelligenceBonus } from "../PersonObjects/formulas/intelligence";
import { Industry } from "../Corporation/Industry";
import { IndustryResearchTrees, IndustryStartingCosts } from "../Corporation/IndustryData";
import { CorporationConstants } from "../Corporation/data/Constants";
@ -69,7 +66,7 @@ import { Factions } from "../Faction/Factions";
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper";
export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript): InternalAPI<NSCorporation> {
export function NetscriptCorporation(player: IPlayer): InternalAPI<NSCorporation> {
function createCorporation(corporationName: string, selfFund = true): boolean {
if (!player.canAccessCorporation() || player.hasCorporation()) return false;
if (!corporationName) return false;
@ -257,7 +254,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
function getMaterial(divisionName: string, cityName: string, materialName: string): Material {
const warehouse = getWarehouse(divisionName, cityName);
const matName = (materialName ).replace(/ /g, "");
const matName = materialName.replace(/ /g, "");
const material = warehouse.materials[matName];
if (material === undefined) throw new Error(`Invalid material name: '${materialName}'`);
return material;
@ -780,7 +777,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
const corporation = getCorporation();
const office = getOffice(divisionName, cityName);
return ThrowParty(corporation, office, costPerEmployee)
return ThrowParty(corporation, office, costPerEmployee);
},
buyCoffee:
(ctx: NetscriptContext) =>