mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
No more use of any in Corporations.
This commit is contained in:
parent
a2379b21ec
commit
7c9c4d3f4d
@ -14,7 +14,6 @@ import { IPlayer } from "../PersonObjects/I
|
||||
|
||||
import { Page, routing } from "../ui/navigationTracking";
|
||||
|
||||
|
||||
import { dialogBoxCreate } from "../../utils/DialogBox";
|
||||
import { Reviver,
|
||||
Generic_toJSON,
|
||||
|
@ -6,6 +6,8 @@ import { EmployeePositions } from "./EmployeePositions";
|
||||
import { ICorporation } from "./ICorporation";
|
||||
import { numeralWrapper } from "../ui/numeralFormat";
|
||||
import { formatNumber } from "../../utils/StringHelperFunctions";
|
||||
import { OfficeSpace } from "./OfficeSpace";
|
||||
import { IIndustry } from "./IIndustry";
|
||||
|
||||
interface IParams {
|
||||
name?: string;
|
||||
@ -57,7 +59,7 @@ export class Employee {
|
||||
}
|
||||
|
||||
//Returns the amount the employee needs to be paid
|
||||
process(marketCycles = 1, office: any): number {
|
||||
process(marketCycles = 1, office: OfficeSpace): number {
|
||||
const gain = 0.003 * marketCycles,
|
||||
det = gain * Math.random();
|
||||
this.exp += gain;
|
||||
@ -87,7 +89,7 @@ export class Employee {
|
||||
return salary;
|
||||
}
|
||||
|
||||
calculateProductivity(corporation: ICorporation, industry: any): number {
|
||||
calculateProductivity(corporation: ICorporation, industry: IIndustry): number {
|
||||
const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(),
|
||||
effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(),
|
||||
effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(),
|
||||
@ -138,7 +140,7 @@ export class Employee {
|
||||
}
|
||||
|
||||
//'panel' is the DOM element on which to create the UI
|
||||
createUI(panel: any, corporation: ICorporation, industry: any): void {
|
||||
createUI(panel: HTMLElement, corporation: ICorporation, industry: IIndustry): void {
|
||||
const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(),
|
||||
effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(),
|
||||
effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(),
|
||||
|
5
src/Corporation/Export.ts
Normal file
5
src/Corporation/Export.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface Export {
|
||||
ind: string;
|
||||
city: string;
|
||||
amt: string;
|
||||
}
|
78
src/Corporation/IIndustry.ts
Normal file
78
src/Corporation/IIndustry.ts
Normal file
@ -0,0 +1,78 @@
|
||||
import { Material } from "./Material";
|
||||
import { Warehouse } from "./Warehouse";
|
||||
import { ICorporation } from "./ICorporation";
|
||||
import { OfficeSpace } from "./OfficeSpace";
|
||||
import { Product } from "./Product";
|
||||
import { IndustryUpgrade } from "./IndustryUpgrades";
|
||||
|
||||
export interface IIndustry {
|
||||
name: string;
|
||||
type: string;
|
||||
sciResearch: Material;
|
||||
researched: any;
|
||||
reqMats: any;
|
||||
|
||||
prodMats: string[];
|
||||
|
||||
products: any;
|
||||
makesProducts: boolean;
|
||||
|
||||
awareness: number;
|
||||
popularity: number;
|
||||
startingCost: number;
|
||||
|
||||
reFac: number;
|
||||
sciFac: number;
|
||||
hwFac: number;
|
||||
robFac: number;
|
||||
aiFac: number;
|
||||
advFac: number;
|
||||
|
||||
prodMult: number;
|
||||
|
||||
// Decimal
|
||||
lastCycleRevenue: any;
|
||||
lastCycleExpenses: any;
|
||||
thisCycleRevenue: any;
|
||||
thisCycleExpenses: any;
|
||||
|
||||
upgrades: number[];
|
||||
|
||||
state: string;
|
||||
newInd: boolean;
|
||||
warehouses: any;
|
||||
offices: any;
|
||||
|
||||
|
||||
init(): void;
|
||||
getProductDescriptionText(): string;
|
||||
getMaximumNumberProducts(): number;
|
||||
hasMaximumNumberProducts(): boolean;
|
||||
calculateProductionFactors(): void;
|
||||
updateWarehouseSizeUsed(warehouse: Warehouse): void;
|
||||
process(marketCycles: number, state: string, corporation: ICorporation): void;
|
||||
processMaterialMarket(): void;
|
||||
processProductMarket(marketCycles: number): void;
|
||||
processMaterials(marketCycles: number, corporation: ICorporation): [number, number];
|
||||
processProducts(marketCycles: number, corporation: ICorporation): [number, number];
|
||||
processProduct(marketCycles: number, product: Product, corporation: ICorporation): number;
|
||||
discontinueProduct(product: Product): void;
|
||||
upgrade(upgrade: IndustryUpgrade, refs: {corporation: any; office: OfficeSpace}): void;
|
||||
getOfficeProductivity(office: OfficeSpace, params?: any): number;
|
||||
getBusinessFactor(office: OfficeSpace): number;
|
||||
getAdvertisingFactors(): [number, number, number, number];
|
||||
getMarketFactor(mat: {dmd: number; cmp: number}): number;
|
||||
hasResearch(name: string): boolean;
|
||||
updateResearchTree(): void;
|
||||
getAdvertisingMultiplier(): number;
|
||||
getEmployeeChaMultiplier(): number;
|
||||
getEmployeeCreMultiplier(): number;
|
||||
getEmployeeEffMultiplier(): number;
|
||||
getEmployeeIntMultiplier(): number;
|
||||
getProductionMultiplier(): number;
|
||||
getProductProductionMultiplier(): number;
|
||||
getSalesMultiplier(): number;
|
||||
getScientificResearchMultiplier(): number;
|
||||
getStorageMultiplier(): number;
|
||||
toJSON(): any;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import { Generic_fromJSON,
|
||||
Generic_toJSON,
|
||||
Reviver } from "../../utils/JSONReviver";
|
||||
import { Export } from "./Export";
|
||||
|
||||
interface IConstructorParams {
|
||||
name?: string;
|
||||
@ -43,7 +44,7 @@ export class Material {
|
||||
imp = 0;
|
||||
|
||||
// Exports of this material to another warehouse/industry
|
||||
exp: any[] = [];
|
||||
exp: Export[] = [];
|
||||
|
||||
// Total amount of this material exported in the last cycle
|
||||
totalExp = 0;
|
||||
@ -52,7 +53,7 @@ export class Material {
|
||||
bCost = 0;
|
||||
|
||||
// Cost / sec to sell this material
|
||||
sCost = 0;
|
||||
sCost: string | number = 0;
|
||||
|
||||
// Flags to keep track of whether production and/or sale of this material is limited
|
||||
// [Whether production/sale is limited, limit amount]
|
||||
|
@ -14,6 +14,9 @@ import { removeElementById } from "../../utils/uiHelpers/removeElementById";
|
||||
import { createElement } from "../../utils/uiHelpers/createElement";
|
||||
import { numeralWrapper } from "../ui/numeralFormat";
|
||||
import { Employee } from "./Employee";
|
||||
import { IIndustry } from "./IIndustry";
|
||||
import { ICorporation } from './ICorporation';
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
|
||||
interface IParams {
|
||||
loc?: string;
|
||||
@ -58,7 +61,7 @@ export class OfficeSpace {
|
||||
return (this.employees.length) >= this.size;
|
||||
}
|
||||
|
||||
process(marketCycles = 1, parentRefs: any): number {
|
||||
process(marketCycles = 1, parentRefs: {industry: IIndustry; corporation: ICorporation}): number {
|
||||
const industry = parentRefs.industry;
|
||||
|
||||
// HRBuddy AutoRecruitment and training
|
||||
@ -85,9 +88,9 @@ export class OfficeSpace {
|
||||
|
||||
// Calculate changes in Morale/Happiness/Energy for Employees
|
||||
let perfMult=1; //Multiplier for employee morale/happiness/energy based on company performance
|
||||
if (industry.funds < 0 && industry.lastCycleRevenue < 0) {
|
||||
if (parentRefs.corporation.funds < 0 && industry.lastCycleRevenue < 0) {
|
||||
perfMult = Math.pow(0.99, marketCycles);
|
||||
} else if (industry.funds > 0 && industry.lastCycleRevenue > 0) {
|
||||
} else if (parentRefs.corporation.funds > 0 && industry.lastCycleRevenue > 0) {
|
||||
perfMult = Math.pow(1.01, marketCycles);
|
||||
}
|
||||
|
||||
@ -122,7 +125,7 @@ export class OfficeSpace {
|
||||
return salaryPaid;
|
||||
}
|
||||
|
||||
calculateEmployeeProductivity(parentRefs: any): void {
|
||||
calculateEmployeeProductivity(parentRefs: {corporation: ICorporation; industry: IIndustry}): void {
|
||||
const company = parentRefs.corporation, industry = parentRefs.industry;
|
||||
|
||||
//Reset
|
||||
@ -141,7 +144,7 @@ export class OfficeSpace {
|
||||
}
|
||||
|
||||
//Takes care of UI as well
|
||||
findEmployees(parentRefs: any): void {
|
||||
findEmployees(player: IPlayer, parentRefs: {corporation: ICorporation}): void {
|
||||
if (this.atCapacity()) { return; }
|
||||
if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;}
|
||||
|
||||
@ -197,7 +200,7 @@ export class OfficeSpace {
|
||||
"Efficiency: " + formatNumber(employee.eff, 1) + "<br>" +
|
||||
"Salary: " + numeralWrapper.format(employee.sal, '$0.000a') + " \ s<br>",
|
||||
clickListener: () => {
|
||||
office.hireEmployee(employee, parentRefs);
|
||||
office.hireEmployee(player, employee, parentRefs);
|
||||
removeElementById("cmpy-mgmt-hire-employee-popup");
|
||||
return false;
|
||||
},
|
||||
@ -224,8 +227,8 @@ export class OfficeSpace {
|
||||
createPopup("cmpy-mgmt-hire-employee-popup", elems);
|
||||
}
|
||||
|
||||
hireEmployee(employee: Employee, parentRefs: any): void {
|
||||
const company = parentRefs.corporation;
|
||||
hireEmployee(player: IPlayer, employee: Employee, parentRefs: {corporation: ICorporation}): void {
|
||||
const corporation = parentRefs.corporation;
|
||||
const yesBtn = yesNoTxtInpBoxGetYesButton(),
|
||||
noBtn = yesNoTxtInpBoxGetNoButton();
|
||||
yesBtn.innerHTML = "Hire";
|
||||
@ -240,7 +243,7 @@ export class OfficeSpace {
|
||||
}
|
||||
employee.name = name;
|
||||
this.employees.push(employee);
|
||||
company.rerender();
|
||||
corporation.rerender(player);
|
||||
return yesNoTxtInpBoxClose();
|
||||
});
|
||||
noBtn.addEventListener("click", () => {
|
||||
@ -285,7 +288,7 @@ export class OfficeSpace {
|
||||
}
|
||||
|
||||
//Finds the first unassigned employee and assigns its to the specified job
|
||||
assignEmployeeToJob(job: any): boolean {
|
||||
assignEmployeeToJob(job: string): boolean {
|
||||
for (let i = 0; i < this.employees.length; ++i) {
|
||||
if (this.employees[i].pos === EmployeePositions.Unassigned) {
|
||||
this.employees[i].pos = job;
|
||||
@ -296,7 +299,7 @@ export class OfficeSpace {
|
||||
}
|
||||
|
||||
//Finds the first employee with the given job and unassigns it
|
||||
unassignEmployeeFromJob(job: any): boolean {
|
||||
unassignEmployeeFromJob(job: string): boolean {
|
||||
for (let i = 0; i < this.employees.length; ++i) {
|
||||
if (this.employees[i].pos === job) {
|
||||
this.employees[i].pos = EmployeePositions.Unassigned;
|
||||
|
@ -1,11 +1,13 @@
|
||||
import React from 'react';
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { Product } from "../Product";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
|
||||
interface IProps {
|
||||
product: any;
|
||||
industry: any;
|
||||
product: Product;
|
||||
industry: IIndustry;
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
player: IPlayer;
|
||||
|
@ -2,9 +2,12 @@ import React, { useState } from 'react';
|
||||
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { Material } from "../Material";
|
||||
import { Export } from "../Export";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
|
||||
interface IProps {
|
||||
mat: any;
|
||||
mat: Material;
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
}
|
||||
@ -64,7 +67,7 @@ export function ExportPopup(props: IProps): React.ReactElement {
|
||||
removePopup(props.popupId);
|
||||
}
|
||||
|
||||
function removeExport(exp: any): void {
|
||||
function removeExport(exp: Export): void {
|
||||
for (let i = 0; i < props.mat.exp.length; ++i) {
|
||||
if(props.mat.exp[i].ind !== exp.ind ||
|
||||
props.mat.exp[i].city !== exp.city ||
|
||||
@ -75,7 +78,7 @@ export function ExportPopup(props: IProps): React.ReactElement {
|
||||
rerender();
|
||||
}
|
||||
|
||||
const currentDivision = props.corp.divisions.find((division: any) => division.name === industry);
|
||||
const currentDivision = props.corp.divisions.find((division: IIndustry) => division.name === industry);
|
||||
|
||||
return (<>
|
||||
<p>
|
||||
@ -85,12 +88,12 @@ amount to 'MAX' to export all of the materials in this warehouse.
|
||||
</p>
|
||||
<select className="dropdown" onChange={onIndustryChange} defaultValue={industry}>
|
||||
{
|
||||
props.corp.divisions.map((division: any) => <option key={division.name} value={division.name}>{division.name}</option>)
|
||||
props.corp.divisions.map((division: IIndustry) => <option key={division.name} value={division.name}>{division.name}</option>)
|
||||
}
|
||||
</select>
|
||||
<select className="dropdown" onChange={onCityChange} defaultValue={city}>
|
||||
{
|
||||
currentDivision && Object.keys(currentDivision.warehouses).map((cityName: any) => {
|
||||
currentDivision && Object.keys(currentDivision.warehouses).map((cityName: string) => {
|
||||
if(currentDivision.warehouses[cityName] === 0) return;
|
||||
return (<option key={cityName} value={cityName}>{cityName}</option>);
|
||||
})
|
||||
@ -103,7 +106,7 @@ Below is a list of all current exports of this material from this warehouse.
|
||||
Clicking on one of the exports below will REMOVE that export.
|
||||
</p>
|
||||
{
|
||||
props.mat.exp.map((exp: any, index: number) => <div key={index} className="cmpy-mgmt-existing-export" onClick={() => removeExport(exp)}>
|
||||
props.mat.exp.map((exp: Export, index: number) => <div key={index} className="cmpy-mgmt-existing-export" onClick={() => removeExport(exp)}>
|
||||
Industry: {exp.ind}<br />
|
||||
City: {exp.city}<br />
|
||||
Amount/s: {exp.amt}
|
||||
|
@ -14,9 +14,10 @@ import { UpgradeOfficeSizePopup } from "./UpgradeOfficeSizePopup";
|
||||
import { ThrowPartyPopup } from "./ThrowPartyPopup";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { CorporationRouting } from "./Routing";
|
||||
|
||||
interface IProps {
|
||||
routing: any;
|
||||
routing: CorporationRouting;
|
||||
corp: ICorporation;
|
||||
currentCity: string;
|
||||
player: IPlayer;
|
||||
@ -130,6 +131,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
|
||||
function renderAutomaticEmployeeManagement(): React.ReactElement {
|
||||
const division = props.routing.currentDivision; // Validated in constructor
|
||||
if(division === null) return(<></>);
|
||||
const office = division.offices[props.currentCity]; // Validated in constructor
|
||||
const vechain = (props.corp.unlockUpgrades[4] === 1); // Has Vechain upgrade
|
||||
|
||||
@ -432,6 +434,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
function renderManualEmployeeManagement(): React.ReactElement {
|
||||
const corp = props.corp;
|
||||
const division = props.routing.currentDivision; // Validated in constructor
|
||||
if(division === null) return (<></>);
|
||||
const office = division.offices[props.currentCity]; // Validated in constructor
|
||||
|
||||
function switchModeOnClick(): void {
|
||||
@ -542,6 +545,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
|
||||
const corp = props.corp;
|
||||
const division = props.routing.currentDivision; // Validated in constructor
|
||||
if(division === null) return (<></>);
|
||||
const office = division.offices[props.currentCity]; // Validated in constructor
|
||||
|
||||
const buttonStyle = {
|
||||
@ -560,7 +564,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function hireEmployeeButtonOnClick(): void {
|
||||
office.findEmployees({ corporation: corp, industry: division });
|
||||
office.findEmployees(props.player, { corporation: corp, industry: division });
|
||||
}
|
||||
|
||||
// Autohire employee button
|
||||
|
@ -13,9 +13,10 @@ import { ResearchPopup } from "./ResearchPopup";
|
||||
import { createPopup } from "../../ui/React/createPopup";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { CorporationRouting } from "./Routing";
|
||||
|
||||
interface IProps {
|
||||
routing: any;
|
||||
routing: CorporationRouting;
|
||||
corp: ICorporation;
|
||||
currentCity: string;
|
||||
player: IPlayer;
|
||||
@ -24,7 +25,7 @@ interface IProps {
|
||||
export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
function renderMakeProductButton(): React.ReactElement {
|
||||
const division = props.routing.currentDivision; // Validated inside render()
|
||||
|
||||
if(division === null) return (<></>);
|
||||
let createProductButtonText = "";
|
||||
let createProductPopupText = "";
|
||||
switch(division.type) {
|
||||
@ -83,6 +84,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function openMakeProductPopup(): void {
|
||||
if(division === null) return;
|
||||
const popupId = "cmpy-mgmt-create-product-popup";
|
||||
createPopup(popupId, MakeProductPopup, {
|
||||
popupText: createProductPopupText,
|
||||
@ -108,7 +110,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
function renderText(): React.ReactElement {
|
||||
const corp = props.corp;
|
||||
const division = props.routing.currentDivision; // Validated inside render()
|
||||
|
||||
if(division === null) return (<></>);
|
||||
const vechain = (corp.unlockUpgrades[4] === 1);
|
||||
const profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber();
|
||||
|
||||
@ -129,6 +131,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
const profitStr = `Profit: ${numeralWrapper.formatMoney(profit)} / s`;
|
||||
|
||||
function productionMultHelpTipOnClick(): void {
|
||||
if(division === null) return;
|
||||
// Wrapper for createProgressBarText()
|
||||
// Converts the industry's "effectiveness factors"
|
||||
// into a graphic (string) depicting how high that effectiveness is
|
||||
@ -158,6 +161,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function openResearchPopup(): void {
|
||||
if(division === null) return;
|
||||
const popupId = "corporation-research-popup-box";
|
||||
createPopup(popupId, ResearchPopup, {
|
||||
industry: division,
|
||||
@ -217,6 +221,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
function renderUpgrades(): React.ReactElement[] {
|
||||
const corp = props.corp;
|
||||
const division = props.routing.currentDivision; // Validated inside render()
|
||||
if(division === null) return ([<></>]);
|
||||
const office = division.offices[props.currentCity];
|
||||
if (!(office instanceof OfficeSpace)) {
|
||||
throw new Error(`Current City (${props.currentCity}) for UI does not have an OfficeSpace object`);
|
||||
@ -243,6 +248,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onClick(): void {
|
||||
if(division === null) return;
|
||||
if (corp.funds.lt(cost)) {
|
||||
dialogBoxCreate("Insufficient funds");
|
||||
} else {
|
||||
@ -266,7 +272,13 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
function renderUpgrade(props: any): React.ReactElement {
|
||||
interface IRenderUpgradeProps {
|
||||
onClick: () => void;
|
||||
text: string;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
function renderUpgrade(props: IRenderUpgradeProps): React.ReactElement {
|
||||
return (
|
||||
<div className={"cmpy-mgmt-upgrade-div tooltip"} onClick={props.onClick} key={props.text}>
|
||||
{props.text}
|
||||
|
@ -21,14 +21,16 @@ import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { createPopup } from "../../ui/React/createPopup";
|
||||
|
||||
import { isString } from "../../../utils/helpers/isString";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { CorporationRouting } from "./Routing";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
|
||||
interface IProductProps {
|
||||
corp: ICorporation;
|
||||
division: any;
|
||||
division: IIndustry;
|
||||
city: string;
|
||||
product: any;
|
||||
product: Product;
|
||||
player: IPlayer;
|
||||
}
|
||||
|
||||
@ -69,7 +71,7 @@ function ProductComponent(props: IProductProps): React.ReactElement {
|
||||
if (isString(product.sCost)) {
|
||||
sellButtonText += (" @ " + product.sCost);
|
||||
} else {
|
||||
sellButtonText += (" @ " + numeralWrapper.format(product.sCost, "$0.000a"));
|
||||
sellButtonText += (" @ " + numeralWrapper.formatMoney(product.sCost as number));
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,11 +230,11 @@ function ProductComponent(props: IProductProps): React.ReactElement {
|
||||
}
|
||||
|
||||
interface IMaterialProps {
|
||||
corp: any;
|
||||
division: any;
|
||||
warehouse: any;
|
||||
corp: ICorporation;
|
||||
division: IIndustry;
|
||||
warehouse: Warehouse;
|
||||
city: string;
|
||||
mat: any;
|
||||
mat: Material;
|
||||
}
|
||||
|
||||
// Creates the UI for a single Material type
|
||||
@ -299,10 +301,10 @@ function MaterialComponent(props: IMaterialProps): React.ReactElement {
|
||||
sellButtonText += " @ " + numeralWrapper.formatMoney(mat.bCost + markupLimit);
|
||||
} else if (mat.sCost) {
|
||||
if (isString(mat.sCost)) {
|
||||
const sCost = mat.sCost.replace(/MP/g, mat.bCost);
|
||||
const sCost = (mat.sCost as string).replace(/MP/g, mat.bCost+'');
|
||||
sellButtonText += " @ " + numeralWrapper.formatMoney(eval(sCost));
|
||||
} else {
|
||||
sellButtonText += " @ " + numeralWrapper.formatMoney(mat.sCost);
|
||||
sellButtonText += " @ " + numeralWrapper.formatMoney(mat.sCost as number);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -405,8 +407,8 @@ function MaterialComponent(props: IMaterialProps): React.ReactElement {
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
corp: any;
|
||||
routing: any;
|
||||
corp: ICorporation;
|
||||
routing: CorporationRouting;
|
||||
currentCity: string;
|
||||
player: IPlayer;
|
||||
}
|
||||
@ -414,7 +416,7 @@ interface IProps {
|
||||
export function IndustryWarehouse(props: IProps): React.ReactElement {
|
||||
// Returns a boolean indicating whether the given material is relevant for the
|
||||
// current industry.
|
||||
function isRelevantMaterial(matName: string, division: any): boolean {
|
||||
function isRelevantMaterial(matName: string, division: IIndustry): boolean {
|
||||
// Materials that affect Production multiplier
|
||||
const prodMultiplierMats = ["Hardware", "Robots", "AICores", "RealEstate"];
|
||||
|
||||
@ -428,6 +430,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
|
||||
function renderWarehouseUI(): React.ReactElement {
|
||||
const corp = props.corp;
|
||||
const division = props.routing.currentDivision; // Validated in render()
|
||||
if(division === null) return (<></>);
|
||||
const warehouse = division.warehouses[props.currentCity]; // Validated in render()
|
||||
|
||||
// General Storage information at the top
|
||||
@ -595,7 +598,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
|
||||
}
|
||||
const warehouse = division.warehouses[props.currentCity];
|
||||
|
||||
function purchaseWarehouse(division: any, city: string): void {
|
||||
function purchaseWarehouse(division: IIndustry, city: string): void {
|
||||
if (props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)) {
|
||||
dialogBoxCreate("You do not have enough funds to do this!");
|
||||
} else {
|
||||
|
@ -40,7 +40,7 @@ function EffectText(props: IEffectTextProps): React.ReactElement {
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
corp: any;
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
import React, { useState } from 'react';
|
||||
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { Product } from "../Product";
|
||||
|
||||
interface IProps {
|
||||
product: any;
|
||||
city: any;
|
||||
product: Product;
|
||||
city: string;
|
||||
popupId: string;
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,11 @@ import { removePopup } from "../../ui/React/createPopup";
|
||||
import { Industries } from "../IndustryData";
|
||||
import { Product } from "../Product";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
|
||||
interface IProps {
|
||||
popupText: string;
|
||||
division: any;
|
||||
division: IIndustry;
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
import React, { useState } from 'react';
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { Material } from "../Material";
|
||||
|
||||
interface IMarketTA2Props {
|
||||
industry: any;
|
||||
mat: any;
|
||||
industry: IIndustry;
|
||||
mat: Material;
|
||||
}
|
||||
|
||||
function MarketTA2(props: IMarketTA2Props): React.ReactElement {
|
||||
@ -70,9 +73,9 @@ function MarketTA2(props: IMarketTA2Props): React.ReactElement {
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
mat: any;
|
||||
industry: any;
|
||||
corp: any;
|
||||
mat: Material;
|
||||
industry: IIndustry;
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
}
|
||||
|
||||
|
@ -7,17 +7,19 @@ import {
|
||||
IndustryDescriptions } from "../IndustryData";
|
||||
import { Industry } from "../Industry";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { CorporationRouting } from "./Routing";
|
||||
|
||||
interface IProps {
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
routing: any;
|
||||
routing: CorporationRouting;
|
||||
}
|
||||
// Create a popup that lets the player create a new industry.
|
||||
// This is created when the player clicks the "Expand into new Industry" header tab
|
||||
export function NewIndustryPopup(props: IProps): React.ReactElement {
|
||||
const allIndustries = Object.keys(Industries).sort();
|
||||
const possibleIndustries = allIndustries.filter((industryType: string) => props.corp.divisions.find((division: any) => division.type === industryType) === undefined).sort();
|
||||
const possibleIndustries = allIndustries.filter((industryType: string) => props.corp.divisions.find((division: IIndustry) => division.type === industryType) === undefined).sort();
|
||||
const [industry, setIndustry] = useState(possibleIndustries.length > 0 ? possibleIndustries[0] : '');
|
||||
const [name, setName] = useState('');
|
||||
|
||||
|
@ -12,7 +12,9 @@ import { GoPublicPopup } from "./GoPublicPopup";
|
||||
|
||||
import { CorporationConstants } from "../data/Constants";
|
||||
import { CorporationUnlockUpgrades } from "../data/CorporationUnlockUpgrades";
|
||||
import { CorporationUpgrades } from "../data/CorporationUpgrades";
|
||||
import {
|
||||
CorporationUpgrade,
|
||||
CorporationUpgrades } from "../data/CorporationUpgrades";
|
||||
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
@ -26,9 +28,21 @@ interface IProps {
|
||||
player: IPlayer;
|
||||
}
|
||||
|
||||
interface GeneralBtns {
|
||||
bribeFactions: React.ReactElement;
|
||||
getStarterGuide: React.ReactElement;
|
||||
}
|
||||
|
||||
export function Overview(props: IProps): React.ReactElement {
|
||||
// Generic Function for Creating a button
|
||||
function createButton(props: any): React.ReactElement {
|
||||
interface ICreateButtonProps {
|
||||
text: string
|
||||
class?: string;
|
||||
display?: string;
|
||||
tooltip?: string;
|
||||
onClick?: (event: React.MouseEvent) => void;
|
||||
}
|
||||
function createButton(props: ICreateButtonProps): React.ReactElement {
|
||||
let className = props.class ? props.class : "std-button";
|
||||
const displayStyle = props.display ? props.display : "block";
|
||||
const hasTooltip = (props.tooltip != null);
|
||||
@ -117,11 +131,10 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
function renderButtons(): React.ReactElement {
|
||||
// Create a "Getting Started Guide" button that lets player view the
|
||||
// handbook and adds it to the players home computer
|
||||
const getStarterGuideOnClick = props.corp.getStarterGuide.bind(props.corp);
|
||||
const getStarterGuideBtn = createButton({
|
||||
class: "a-link-button",
|
||||
display: "inline-block",
|
||||
onClick: getStarterGuideOnClick,
|
||||
onClick: () => props.corp.getStarterGuide(props.player),
|
||||
text: "Getting Started Guide",
|
||||
tooltip: "Get a copy of and read 'The Complete Handbook for Creating a Successful Corporation.' " +
|
||||
"This is a .lit file that guides you through the beginning of setting up a Corporation and " +
|
||||
@ -166,10 +179,10 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
|
||||
|
||||
// Render the buttons for when your Corporation is still private
|
||||
function renderPrivateButtons(generalBtns: any): React.ReactElement {
|
||||
function renderPrivateButtons(generalBtns: GeneralBtns): React.ReactElement {
|
||||
const fundingAvailable = (props.corp.fundingRound < 4);
|
||||
const findInvestorsClassName = fundingAvailable ? "std-button" : "a-link-button-inactive";
|
||||
const findInvestorsTooltip = fundingAvailable ? "Search for private investors who will give you startup funding in exchangefor equity (stock shares) in your company" : null;
|
||||
const findInvestorsTooltip = fundingAvailable ? "Search for private investors who will give you startup funding in exchangefor equity (stock shares) in your company" : undefined;
|
||||
|
||||
function openFindInvestorsPopup(): void {
|
||||
const popupId = "cmpy-mgmt-find-investors-popup";
|
||||
@ -192,7 +205,6 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
const findInvestorsBtn = createButton({
|
||||
class: findInvestorsClassName,
|
||||
onClick: openFindInvestorsPopup,
|
||||
style: "inline-block",
|
||||
text: "Find Investors",
|
||||
tooltip: findInvestorsTooltip,
|
||||
display: "inline-block",
|
||||
@ -200,7 +212,6 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
const goPublicBtn = createButton({
|
||||
class: "std-button",
|
||||
onClick: openGoPublicPopup,
|
||||
style: "inline-block",
|
||||
display: "inline-block",
|
||||
text: "Go Public",
|
||||
tooltip: "Become a publicly traded and owned entity. Going public " +
|
||||
@ -221,7 +232,7 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
// Render the buttons for when your Corporation has gone public
|
||||
function renderPublicButtons(generalBtns: any): React.ReactElement {
|
||||
function renderPublicButtons(generalBtns: GeneralBtns): React.ReactElement {
|
||||
const corp = props.corp;
|
||||
|
||||
const sellSharesOnCd = (corp.shareSaleCooldown > 0);
|
||||
@ -234,7 +245,7 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
const sellSharesBtn = createButton({
|
||||
class: sellSharesClass,
|
||||
display: "inline-block",
|
||||
onClick: function(event: MouseEvent) {
|
||||
onClick: function(event: React.MouseEvent) {
|
||||
if(!event.isTrusted) return;
|
||||
const popupId = "cmpy-mgmt-sell-shares-popup";
|
||||
createPopup(popupId, SellSharesPopup, {
|
||||
@ -333,8 +344,13 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
}
|
||||
});
|
||||
|
||||
interface UpgradeData {
|
||||
upgradeData: CorporationUpgrade;
|
||||
upgradeLevel: number;
|
||||
}
|
||||
|
||||
// Create an array of properties of all unlocks
|
||||
const levelableUpgradeProps = [];
|
||||
const levelableUpgradeProps: UpgradeData[] = [];
|
||||
for (let i = 0; i < props.corp.upgrades.length; ++i) {
|
||||
const upgradeData = CorporationUpgrades[i];
|
||||
const level = props.corp.upgrades[i];
|
||||
@ -353,7 +369,7 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
|
||||
<h1 className={"cmpy-mgmt-upgrade-header"}> Upgrades </h1>
|
||||
{
|
||||
levelableUpgradeProps.map((data: any) => <LevelableUpgrade
|
||||
levelableUpgradeProps.map((data: UpgradeData) => <LevelableUpgrade
|
||||
player={props.player}
|
||||
corp={props.corp}
|
||||
upgradeData={data.upgradeData}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import React, { useState } from 'react';
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { Product } from "../Product";
|
||||
|
||||
interface IProps {
|
||||
product: any;
|
||||
industry: any;
|
||||
product: Product;
|
||||
industry: IIndustry;
|
||||
popupId: string;
|
||||
}
|
||||
|
||||
@ -16,7 +18,7 @@ function MarketTA2(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
setValue(event.target.value);
|
||||
setValue(parseFloat(event.target.value));
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +27,7 @@ function MarketTA2(props: IProps): React.ReactElement {
|
||||
rerender();
|
||||
}
|
||||
|
||||
const sCost = parseFloat(value);
|
||||
const sCost = value;
|
||||
let markup = 1;
|
||||
if (sCost > props.product.pCost) {
|
||||
if ((sCost - props.product.pCost) > markupLimit) {
|
||||
|
@ -2,11 +2,15 @@ import React, { useState } from 'react';
|
||||
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { MaterialSizes } from "../MaterialSizes";
|
||||
import { Warehouse } from "../Warehouse";
|
||||
import { Material } from "../Material";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
|
||||
interface IBulkPurchaseTextProps {
|
||||
warehouse: any;
|
||||
mat: any;
|
||||
warehouse: Warehouse;
|
||||
mat: Material;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
@ -28,10 +32,10 @@ function BulkPurchaseText(props: IBulkPurchaseTextProps): React.ReactElement {
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
mat: any;
|
||||
industry: any;
|
||||
warehouse: any;
|
||||
corp: any;
|
||||
mat: Material;
|
||||
industry: IIndustry;
|
||||
warehouse: Warehouse;
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
}
|
||||
|
||||
@ -89,10 +93,11 @@ export function PurchaseMaterialPopup(props: IProps): React.ReactElement {
|
||||
const [buyAmt, setBuyAmt] = useState(props.mat.buy ? props.mat.buy : null);
|
||||
|
||||
function purchaseMaterial(): void {
|
||||
if (isNaN(parseFloat(buyAmt))) {
|
||||
if(buyAmt === null) return;
|
||||
if (isNaN(buyAmt)) {
|
||||
dialogBoxCreate("Invalid amount");
|
||||
} else {
|
||||
props.mat.buy = parseFloat(buyAmt);
|
||||
props.mat.buy = buyAmt;
|
||||
if (isNaN(props.mat.buy)) props.mat.buy = 0;
|
||||
removePopup(props.popupId);
|
||||
}
|
||||
@ -108,7 +113,7 @@ export function PurchaseMaterialPopup(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
setBuyAmt(event.target.value);
|
||||
setBuyAmt(parseFloat(event.target.value));
|
||||
}
|
||||
|
||||
return (<>
|
||||
|
@ -6,9 +6,10 @@ import { IndustryResearchTrees } from "../IndustryData";
|
||||
import { CorporationConstants } from "../data/Constants";
|
||||
import { ResearchMap } from "../ResearchMap";
|
||||
import { Treant } from 'treant-js';
|
||||
import { IIndustry } from "../IIndustry";
|
||||
|
||||
interface IProps {
|
||||
industry: any;
|
||||
industry: IIndustry;
|
||||
popupId: string;
|
||||
}
|
||||
|
||||
|
@ -1,33 +1,9 @@
|
||||
import { IMap } from "../../types";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
|
||||
export const overviewPage = "Overview";
|
||||
|
||||
// Interfaces for whatever's required to sanitize routing with Corporation Data
|
||||
interface IOfficeSpace {
|
||||
loc: string;
|
||||
cost: number;
|
||||
size: number;
|
||||
comf: number;
|
||||
beau: number;
|
||||
tier: any;
|
||||
minEne: number;
|
||||
maxEne: number;
|
||||
minHap: number;
|
||||
maxHap: number;
|
||||
maxMor: number;
|
||||
employees: any;
|
||||
employeeProd: any;
|
||||
}
|
||||
|
||||
interface IDivision {
|
||||
name: string;
|
||||
offices: IMap<IOfficeSpace>;
|
||||
}
|
||||
|
||||
interface ICorporation {
|
||||
divisions: IDivision[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps track of what content is currently being displayed for the Corporation UI
|
||||
*/
|
||||
@ -39,7 +15,7 @@ export class CorporationRouting {
|
||||
|
||||
// Stores a reference to the Division instance that the routing is currently on
|
||||
// This will be null if routing is on the overview page
|
||||
currentDivision: IDivision | null = null;
|
||||
currentDivision: IIndustry | null = null;
|
||||
|
||||
constructor(corp: ICorporation) {
|
||||
this.corp = corp;
|
||||
|
@ -2,9 +2,10 @@ import React, { useState } from 'react';
|
||||
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { Material } from "../Material";
|
||||
|
||||
function initialPrice(mat: any): string {
|
||||
let val = mat.sCost ? mat.sCost : '';
|
||||
function initialPrice(mat: Material): string {
|
||||
let val = mat.sCost ? mat.sCost+'' : '';
|
||||
if (mat.marketTa2) {
|
||||
val += " (Market-TA.II)";
|
||||
} else if (mat.marketTa1) {
|
||||
@ -14,7 +15,7 @@ function initialPrice(mat: any): string {
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
mat: any;
|
||||
mat: Material;
|
||||
corp: ICorporation;
|
||||
popupId: string;
|
||||
}
|
||||
@ -31,7 +32,7 @@ export function SellMaterialPopup(props: IProps): React.ReactElement {
|
||||
if(qty === '') qty = '0';
|
||||
let cost = p.replace(/\s+/g, '');
|
||||
cost = cost.replace(/[^-()\d/*+.MP]/g, ''); //Sanitize cost
|
||||
let temp = cost.replace(/MP/g, props.mat.bCost);
|
||||
let temp = cost.replace(/MP/g, props.mat.bCost+'');
|
||||
try {
|
||||
temp = eval(temp);
|
||||
} catch(e) {
|
||||
|
@ -2,9 +2,10 @@ import React, { useState } from 'react';
|
||||
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { Cities } from "../../Locations/Cities";
|
||||
import { Product } from "../Product";
|
||||
|
||||
function initialPrice(product: any): string {
|
||||
let val = product.sCost ? product.sCost : '';
|
||||
function initialPrice(product: Product): string {
|
||||
let val = product.sCost ? product.sCost+'' : '';
|
||||
if (product.marketTa2) {
|
||||
val += " (Market-TA.II)";
|
||||
} else if (product.marketTa1) {
|
||||
@ -14,7 +15,7 @@ function initialPrice(product: any): string {
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
product: any;
|
||||
product: Product;
|
||||
city: string;
|
||||
popupId: string;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
|
||||
else setShares(Math.round(parseFloat(event.target.value)));
|
||||
}
|
||||
|
||||
function ProfitIndicator(props: {shares: number | null; corp: any}): React.ReactElement {
|
||||
function ProfitIndicator(props: {shares: number | null; corp: ICorporation}): React.ReactElement {
|
||||
if(props.shares === null) return (<></>);
|
||||
if (isNaN(props.shares) || props.shares <= 0) {
|
||||
return (<>ERROR: Invalid value entered for number of shares to sell</>);
|
||||
|
@ -57,7 +57,7 @@ export function UpgradeOfficeSizePopup(props: IProps): React.ReactElement {
|
||||
interface IUpgradeButton {
|
||||
cost: number;
|
||||
size: number;
|
||||
corp: any;
|
||||
corp: ICorporation;
|
||||
}
|
||||
|
||||
function UpgradeSizeButton(props: IUpgradeButton): React.ReactElement {
|
||||
|
Loading…
Reference in New Issue
Block a user