more conversion

This commit is contained in:
Olivier Gagnon 2021-08-31 03:39:04 -04:00
parent 68885ceff5
commit a2379b21ec
24 changed files with 127 additions and 73 deletions

@ -3,6 +3,7 @@ import { getRandomInt } from "../../utils/helpers/getRandomInt";
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
import { createElement } from "../../utils/uiHelpers/createElement"; import { createElement } from "../../utils/uiHelpers/createElement";
import { EmployeePositions } from "./EmployeePositions"; import { EmployeePositions } from "./EmployeePositions";
import { ICorporation } from "./ICorporation";
import { numeralWrapper } from "../ui/numeralFormat"; import { numeralWrapper } from "../ui/numeralFormat";
import { formatNumber } from "../../utils/StringHelperFunctions"; import { formatNumber } from "../../utils/StringHelperFunctions";
@ -86,7 +87,7 @@ export class Employee {
return salary; return salary;
} }
calculateProductivity(corporation: any, industry: any): number { calculateProductivity(corporation: ICorporation, industry: any): number {
const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(), const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(),
effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(), effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(),
effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(), effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(),
@ -137,7 +138,7 @@ export class Employee {
} }
//'panel' is the DOM element on which to create the UI //'panel' is the DOM element on which to create the UI
createUI(panel: any, corporation: any, industry: any): void { createUI(panel: any, corporation: ICorporation, industry: any): void {
const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(), const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(),
effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(), effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(),
effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(), effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(),

@ -19,6 +19,7 @@ import { dialogBoxCreate } from "../../utils/DialogBox";
import { isString } from "../../utils/helpers/isString"; import { isString } from "../../utils/helpers/isString";
import { MaterialSizes } from "./MaterialSizes"; import { MaterialSizes } from "./MaterialSizes";
import { Warehouse } from "./Warehouse"; import { Warehouse } from "./Warehouse";
import { ICorporation } from "./ICorporation";
import { import {
IndustryUpgrade, IndustryUpgrade,
IndustryUpgrades } from "./IndustryUpgrades"; IndustryUpgrades } from "./IndustryUpgrades";
@ -401,7 +402,7 @@ export class Industry {
} }
} }
process(marketCycles=1, state: string, company: any): void { process(marketCycles=1, state: string, corporation: ICorporation): void {
this.state = state; this.state = state;
//At the start of a cycle, store and reset revenue/expenses //At the start of a cycle, store and reset revenue/expenses
@ -426,7 +427,7 @@ export class Industry {
let employeeSalary = 0; let employeeSalary = 0;
for (const officeLoc in this.offices) { for (const officeLoc in this.offices) {
if (this.offices[officeLoc] instanceof OfficeSpace) { if (this.offices[officeLoc] instanceof OfficeSpace) {
employeeSalary += this.offices[officeLoc].process(marketCycles, {industry:this, corporation:company}); employeeSalary += this.offices[officeLoc].process(marketCycles, {industry:this, corporation:corporation});
} }
} }
this.thisCycleExpenses = this.thisCycleExpenses.plus(employeeSalary); this.thisCycleExpenses = this.thisCycleExpenses.plus(employeeSalary);
@ -440,7 +441,7 @@ export class Industry {
this.popularity = Math.max(0, this.popularity); this.popularity = Math.max(0, this.popularity);
// Process Dreamsense gains // Process Dreamsense gains
const popularityGain = company.getDreamSenseGain(), awarenessGain = popularityGain * 4; const popularityGain = corporation.getDreamSenseGain(), awarenessGain = popularityGain * 4;
if (popularityGain > 0) { if (popularityGain > 0) {
this.popularity += (popularityGain * marketCycles); this.popularity += (popularityGain * marketCycles);
this.awareness += (awarenessGain * marketCycles); this.awareness += (awarenessGain * marketCycles);
@ -450,14 +451,14 @@ export class Industry {
} }
// Process production, purchase, and import/export of materials // Process production, purchase, and import/export of materials
let res = this.processMaterials(marketCycles, company); let res = this.processMaterials(marketCycles, corporation);
if (Array.isArray(res)) { if (Array.isArray(res)) {
this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]);
this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]);
} }
// Process creation, production & sale of products // Process creation, production & sale of products
res = this.processProducts(marketCycles, company); res = this.processProducts(marketCycles, corporation);
if (Array.isArray(res)) { if (Array.isArray(res)) {
this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]);
this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]);
@ -518,7 +519,7 @@ export class Industry {
} }
//Process production, purchase, and import/export of materials //Process production, purchase, and import/export of materials
processMaterials(marketCycles=1, company: any): [number, number] { processMaterials(marketCycles=1, corporation: ICorporation): [number, number] {
let revenue = 0, expenses = 0; let revenue = 0, expenses = 0;
this.calculateProductionFactors(); this.calculateProductionFactors();
@ -588,7 +589,7 @@ export class Industry {
//on the office's productivity //on the office's productivity
const maxProd = this.getOfficeProductivity(office) const maxProd = this.getOfficeProductivity(office)
* this.prodMult // Multiplier from materials * this.prodMult // Multiplier from materials
* company.getProductionMultiplier() * corporation.getProductionMultiplier()
* this.getProductionMultiplier(); // Multiplier from Research * this.getProductionMultiplier(); // Multiplier from Research
let prod; let prod;
@ -700,7 +701,7 @@ export class Industry {
const sqrtDenominator = ((mat.qlt + .001) const sqrtDenominator = ((mat.qlt + .001)
* marketFactor * marketFactor
* businessFactor * businessFactor
* company.getSalesMultiplier() * corporation.getSalesMultiplier()
* advertisingFactor * advertisingFactor
* this.getSalesMultiplier()); * this.getSalesMultiplier());
const denominator = Math.sqrt(sqrtNumerator / sqrtDenominator); const denominator = Math.sqrt(sqrtNumerator / sqrtDenominator);
@ -750,7 +751,7 @@ export class Industry {
* marketFactor * marketFactor
* markup * markup
* businessFactor * businessFactor
* company.getSalesMultiplier() * corporation.getSalesMultiplier()
* advertisingFactor * advertisingFactor
* this.getSalesMultiplier(); * this.getSalesMultiplier();
let sellAmt; let sellAmt;
@ -822,9 +823,9 @@ export class Industry {
if (amt === 0) { if (amt === 0) {
break; //None left break; //None left
} }
for (let foo = 0; foo < company.divisions.length; ++foo) { for (let foo = 0; foo < corporation.divisions.length; ++foo) {
if (company.divisions[foo].name === exp.ind) { if (corporation.divisions[foo].name === exp.ind) {
const expIndustry = company.divisions[foo]; const expIndustry = corporation.divisions[foo];
const expWarehouse = expIndustry.warehouses[exp.city]; const expWarehouse = expIndustry.warehouses[exp.city];
if (!(expWarehouse instanceof Warehouse)) { if (!(expWarehouse instanceof Warehouse)) {
console.error(`Invalid export! ${expIndustry.name} ${exp.city}`); console.error(`Invalid export! ${expIndustry.name} ${exp.city}`);
@ -872,7 +873,7 @@ export class Industry {
if (office instanceof OfficeSpace) { if (office instanceof OfficeSpace) {
this.sciResearch.qty += (.004 this.sciResearch.qty += (.004
* Math.pow(office.employeeProd[EmployeePositions.RandD], 0.5) * Math.pow(office.employeeProd[EmployeePositions.RandD], 0.5)
* company.getScientificResearchMultiplier() * corporation.getScientificResearchMultiplier()
* this.getScientificResearchMultiplier()); * this.getScientificResearchMultiplier());
} }
} }
@ -880,7 +881,7 @@ export class Industry {
} }
//Process production & sale of this industry's FINISHED products (including all of their stats) //Process production & sale of this industry's FINISHED products (including all of their stats)
processProducts(marketCycles=1, corporation: any): [number, number] { processProducts(marketCycles=1, corporation: ICorporation): [number, number] {
let revenue = 0; let revenue = 0;
const expenses = 0; const expenses = 0;
@ -926,7 +927,7 @@ export class Industry {
} }
//Processes FINISHED products //Processes FINISHED products
processProduct(marketCycles=1, product: Product, corporation: any): number { processProduct(marketCycles=1, product: Product, corporation: ICorporation): number {
let totalProfit = 0; let totalProfit = 0;
for (let i = 0; i < CorporationConstants.Cities.length; ++i) { for (let i = 0; i < CorporationConstants.Cities.length; ++i) {
const city = CorporationConstants.Cities[i], office = this.offices[city], warehouse = this.warehouses[city]; const city = CorporationConstants.Cities[i], office = this.offices[city], warehouse = this.warehouses[city];

@ -5,10 +5,11 @@ import { CorporationConstants } from "../data/Constants";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
popupId: string; popupId: string;
corp: any; corp: ICorporation;
player: IPlayer; player: IPlayer;
} }
@ -39,7 +40,7 @@ export function BribeFactionPopup(props: IProps): React.ReactElement {
return "ERROR: Invalid value(s) entered"; return "ERROR: Invalid value(s) entered";
} else if (props.corp.funds.lt(money)) { } else if (props.corp.funds.lt(money)) {
return "ERROR: You do not have this much money to bribe with"; return "ERROR: You do not have this much money to bribe with";
} else if (props.corp.stock > props.corp.numShares) { } else if (stock > props.corp.numShares) {
return "ERROR: You do not have this many shares to bribe with"; return "ERROR: You do not have this many shares to bribe with";
} else { } else {
return "You will gain " + numeralWrapper.formatReputation(repGain(money, stock)) + return "You will gain " + numeralWrapper.formatReputation(repGain(money, stock)) +

@ -3,11 +3,12 @@ import { IPlayer } from "../../PersonObjects/IPlayer";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
player: IPlayer; player: IPlayer;
popupId: string; popupId: string;
corp: any; corp: ICorporation;
} }
// Create a popup that lets the player buyback shares // Create a popup that lets the player buyback shares
@ -39,7 +40,7 @@ export function BuybackSharesPopup(props: IProps): React.ReactElement {
if (isNaN(props.corp.issuedShares)) { if (isNaN(props.corp.issuedShares)) {
console.warn("Corporation issuedShares is NaN: " + props.corp.issuedShares); console.warn("Corporation issuedShares is NaN: " + props.corp.issuedShares);
console.warn("Converting to number now"); console.warn("Converting to number now");
const res = parseInt(props.corp.issuedShares); const res = props.corp.issuedShares;
if (isNaN(res)) { if (isNaN(res)) {
props.corp.issuedShares = 0; props.corp.issuedShares = 0;
} else { } else {
@ -49,7 +50,7 @@ export function BuybackSharesPopup(props: IProps): React.ReactElement {
props.corp.issuedShares -= shares; props.corp.issuedShares -= shares;
props.player.loseMoney(shares * buybackPrice); props.player.loseMoney(shares * buybackPrice);
removePopup(props.popupId); removePopup(props.popupId);
props.corp.rerender(); props.corp.rerender(props.player);
} }
} }

@ -1,11 +1,14 @@
import React from 'react'; import React from 'react';
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
product: any; product: any;
industry: any; industry: any;
corp: any; corp: ICorporation;
popupId: string; popupId: string;
player: IPlayer;
} }
// Create a popup that lets the player discontinue a product // Create a popup that lets the player discontinue a product
@ -13,7 +16,7 @@ export function DiscontinueProductPopup(props: IProps): React.ReactElement {
function discontinue(): void { function discontinue(): void {
props.industry.discontinueProduct(props.product); props.industry.discontinueProduct(props.product);
removePopup(props.popupId); removePopup(props.popupId);
props.corp.rerender(); props.corp.rerender(props.player);
} }
return (<> return (<>

@ -5,10 +5,11 @@ import { CorporationConstants } from "../data/Constants";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { OfficeSpace } from "../OfficeSpace"; import { OfficeSpace } from "../OfficeSpace";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
popupId: string; popupId: string;
corp: any; corp: ICorporation;
division: IDivision; division: IDivision;
cityStateSetter: (city: string) => void; cityStateSetter: (city: string) => void;
} }

@ -1,10 +1,11 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
mat: any; mat: any;
corp: any; corp: ICorporation;
popupId: string; popupId: string;
} }

@ -2,10 +2,13 @@ import React from 'react';
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { CorporationConstants } from "../data/Constants"; import { CorporationConstants } from "../data/Constants";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
corp: any; corp: ICorporation;
popupId: string; popupId: string;
player: IPlayer;
} }
// Create a popup that lets the player manage exports // Create a popup that lets the player manage exports
@ -40,7 +43,7 @@ export function FindInvestorsPopup(props: IProps): React.ReactElement {
props.corp.fundingRound++; props.corp.fundingRound++;
props.corp.addFunds(funding); props.corp.addFunds(funding);
props.corp.numShares -= investShares; props.corp.numShares -= investShares;
props.corp.rerender(); props.corp.rerender(props.player);
removePopup(props.popupId); removePopup(props.popupId);
} }
return (<> return (<>

@ -2,10 +2,13 @@ import React, { useState } from 'react';
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
corp: any; corp: ICorporation;
popupId: string; popupId: string;
player: IPlayer;
} }
// Create a popup that lets the player manage exports // Create a popup that lets the player manage exports
@ -29,7 +32,7 @@ export function GoPublicPopup(props: IProps): React.ReactElement {
props.corp.issuedShares = numShares; props.corp.issuedShares = numShares;
props.corp.numShares -= numShares; props.corp.numShares -= numShares;
props.corp.addFunds(numShares * initialSharePrice); props.corp.addFunds(numShares * initialSharePrice);
props.corp.rerender(); props.corp.rerender(props.player);
dialogBoxCreate(`You took your ${props.corp.name} public and earned ` + dialogBoxCreate(`You took your ${props.corp.name} public and earned ` +
`${numeralWrapper.formatMoney(numShares * initialSharePrice)} in your IPO`); `${numeralWrapper.formatMoney(numShares * initialSharePrice)} in your IPO`);
removePopup(props.popupId); removePopup(props.popupId);

@ -7,11 +7,13 @@ import { IndustryOverview } from "./IndustryOverview";
import { IndustryWarehouse } from "./IndustryWarehouse"; import { IndustryWarehouse } from "./IndustryWarehouse";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { CorporationRouting } from "./Routing"; import { CorporationRouting } from "./Routing";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
routing: CorporationRouting; routing: CorporationRouting;
corp: ICorporation; corp: ICorporation;
currentCity: string; currentCity: string;
player: IPlayer;
} }
export function Industry(props: IProps): React.ReactElement { export function Industry(props: IProps): React.ReactElement {
@ -19,16 +21,19 @@ export function Industry(props: IProps): React.ReactElement {
<div> <div>
<div className={"cmpy-mgmt-industry-left-panel"}> <div className={"cmpy-mgmt-industry-left-panel"}>
<IndustryOverview <IndustryOverview
player={props.player}
routing={props.routing} routing={props.routing}
corp={props.corp} corp={props.corp}
currentCity={props.currentCity} /> currentCity={props.currentCity} />
<IndustryOffice <IndustryOffice
player={props.player}
routing={props.routing} routing={props.routing}
corp={props.corp} corp={props.corp}
currentCity={props.currentCity} /> currentCity={props.currentCity} />
</div> </div>
<div className={"cmpy-mgmt-industry-right-panel"}> <div className={"cmpy-mgmt-industry-right-panel"}>
<IndustryWarehouse <IndustryWarehouse
player={props.player}
corp={props.corp} corp={props.corp}
routing={props.routing} routing={props.routing}
currentCity={props.currentCity} /> currentCity={props.currentCity} />

@ -12,11 +12,14 @@ import { getSelectText } from "../../../utils/uiHelpers/getSelectData
import { createPopup } from "../../ui/React/createPopup"; import { createPopup } from "../../ui/React/createPopup";
import { UpgradeOfficeSizePopup } from "./UpgradeOfficeSizePopup"; import { UpgradeOfficeSizePopup } from "./UpgradeOfficeSizePopup";
import { ThrowPartyPopup } from "./ThrowPartyPopup"; import { ThrowPartyPopup } from "./ThrowPartyPopup";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
routing: any; routing: any;
corp: any; corp: ICorporation;
currentCity: string; currentCity: string;
player: IPlayer;
} }
export function IndustryOffice(props: IProps): React.ReactElement { export function IndustryOffice(props: IProps): React.ReactElement {
@ -132,7 +135,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
function switchModeOnClick(): void { function switchModeOnClick(): void {
setEmployeeManualAssignMode(true); setEmployeeManualAssignMode(true);
props.corp.rerender(); props.corp.rerender(props.player);
} }
// Calculate average morale, happiness, and energy. Also salary // Calculate average morale, happiness, and energy. Also salary
@ -189,7 +192,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
office.assignEmployeeToJob(to); office.assignEmployeeToJob(to);
office.calculateEmployeeProductivity({ corporation: props.corp, industry:division }); office.calculateEmployeeProductivity({ corporation: props.corp, industry:division });
props.corp.rerender(); props.corp.rerender(props.player);
} }
function unassignEmployee(from: string): void { function unassignEmployee(from: string): void {
@ -233,7 +236,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
office.unassignEmployeeFromJob(from); office.unassignEmployeeFromJob(from);
office.calculateEmployeeProductivity({ corporation: props.corp, industry:division }); office.calculateEmployeeProductivity({ corporation: props.corp, industry:division });
props.corp.rerender(); props.corp.rerender(props.player);
} }
const positionHeaderStyle = { const positionHeaderStyle = {
@ -245,61 +248,61 @@ export function IndustryOffice(props: IProps): React.ReactElement {
function operationAssignButtonOnClick(): void { function operationAssignButtonOnClick(): void {
assignEmployee(EmployeePositions.Operations); assignEmployee(EmployeePositions.Operations);
props.corp.rerender(); props.corp.rerender(props.player);
} }
function operationUnassignButtonOnClick(): void { function operationUnassignButtonOnClick(): void {
unassignEmployee(EmployeePositions.Operations); unassignEmployee(EmployeePositions.Operations);
props.corp.rerender(); props.corp.rerender(props.player);
} }
const operationUnassignButtonClass = numOperations > 0 ? "std-button" : "a-link-button-inactive"; const operationUnassignButtonClass = numOperations > 0 ? "std-button" : "a-link-button-inactive";
function engineerAssignButtonOnClick(): void { function engineerAssignButtonOnClick(): void {
assignEmployee(EmployeePositions.Engineer); assignEmployee(EmployeePositions.Engineer);
props.corp.rerender(); props.corp.rerender(props.player);
} }
function engineerUnassignButtonOnClick(): void { function engineerUnassignButtonOnClick(): void {
unassignEmployee(EmployeePositions.Engineer); unassignEmployee(EmployeePositions.Engineer);
props.corp.rerender(); props.corp.rerender(props.player);
} }
const engineerUnassignButtonClass = numEngineers > 0 ? "std-button" : "a-link-button-inactive"; const engineerUnassignButtonClass = numEngineers > 0 ? "std-button" : "a-link-button-inactive";
function businessAssignButtonOnClick(): void { function businessAssignButtonOnClick(): void {
assignEmployee(EmployeePositions.Business); assignEmployee(EmployeePositions.Business);
props.corp.rerender(); props.corp.rerender(props.player);
} }
function businessUnassignButtonOnClick(): void { function businessUnassignButtonOnClick(): void {
unassignEmployee(EmployeePositions.Business); unassignEmployee(EmployeePositions.Business);
props.corp.rerender(); props.corp.rerender(props.player);
} }
const businessUnassignButtonClass = numBusiness > 0 ? "std-button" : "a-link-button-inactive"; const businessUnassignButtonClass = numBusiness > 0 ? "std-button" : "a-link-button-inactive";
function managementAssignButtonOnClick(): void { function managementAssignButtonOnClick(): void {
assignEmployee(EmployeePositions.Management); assignEmployee(EmployeePositions.Management);
props.corp.rerender(); props.corp.rerender(props.player);
} }
function managementUnassignButtonOnClick(): void { function managementUnassignButtonOnClick(): void {
unassignEmployee(EmployeePositions.Management); unassignEmployee(EmployeePositions.Management);
props.corp.rerender(); props.corp.rerender(props.player);
} }
const managementUnassignButtonClass = numManagement > 0 ? "std-button" : "a-link-button-inactive"; const managementUnassignButtonClass = numManagement > 0 ? "std-button" : "a-link-button-inactive";
function rndAssignButtonOnClick(): void { function rndAssignButtonOnClick(): void {
assignEmployee(EmployeePositions.RandD); assignEmployee(EmployeePositions.RandD);
props.corp.rerender(); props.corp.rerender(props.player);
} }
function rndUnassignButtonOnClick(): void { function rndUnassignButtonOnClick(): void {
unassignEmployee(EmployeePositions.RandD); unassignEmployee(EmployeePositions.RandD);
props.corp.rerender(); props.corp.rerender(props.player);
} }
const rndUnassignButtonClass = numResearch > 0 ? "std-button" : "a-link-button-inactive"; const rndUnassignButtonClass = numResearch > 0 ? "std-button" : "a-link-button-inactive";
function trainingAssignButtonOnClick(): void { function trainingAssignButtonOnClick(): void {
assignEmployee(EmployeePositions.Training); assignEmployee(EmployeePositions.Training);
props.corp.rerender(); props.corp.rerender(props.player);
} }
function trainingUnassignButtonOnClick(): void { function trainingUnassignButtonOnClick(): void {
unassignEmployee(EmployeePositions.Training); unassignEmployee(EmployeePositions.Training);
props.corp.rerender(); props.corp.rerender(props.player);
} }
const trainingUnassignButtonClass = numTraining > 0 ? "std-button" : "a-link-button-inactive"; const trainingUnassignButtonClass = numTraining > 0 ? "std-button" : "a-link-button-inactive";
@ -433,7 +436,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
function switchModeOnClick(): void { function switchModeOnClick(): void {
setEmployeeManualAssignMode(false); setEmployeeManualAssignMode(false);
props.corp.rerender(); props.corp.rerender(props.player);
} }
const employeeInfoDivStyle = { const employeeInfoDivStyle = {
@ -457,7 +460,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
} }
} }
corp.rerender(); corp.rerender(props.player);
} }
// Employee Positions Selector // Employee Positions Selector
@ -477,7 +480,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
const pos = getSelectText(e.target); const pos = getSelectText(e.target);
employee.pos = pos; employee.pos = pos;
resetEmployeeCount(); resetEmployeeCount();
corp.rerender(); corp.rerender(props.player);
} }
// Numeraljs formatter // Numeraljs formatter
@ -570,7 +573,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
function autohireEmployeeButtonOnClick(): void { function autohireEmployeeButtonOnClick(): void {
if (office.atCapacity()) return; if (office.atCapacity()) return;
office.hireRandomEmployee(); office.hireRandomEmployee();
props.corp.rerender(); props.corp.rerender(props.player);
} }
function openUpgradeOfficeSizePopup(): void { function openUpgradeOfficeSizePopup(): void {
@ -579,6 +582,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
office: office, office: office,
corp: props.corp, corp: props.corp,
popupId: popupId, popupId: popupId,
player: props.player,
}); });
} }

@ -11,11 +11,14 @@ import { createProgressBarText } from "../../../utils/helpers/createProgressB
import { MakeProductPopup } from "./MakeProductPopup"; import { MakeProductPopup } from "./MakeProductPopup";
import { ResearchPopup } from "./ResearchPopup"; import { ResearchPopup } from "./ResearchPopup";
import { createPopup } from "../../ui/React/createPopup"; import { createPopup } from "../../ui/React/createPopup";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
routing: any; routing: any;
corp: any; corp: ICorporation;
currentCity: string; currentCity: string;
player: IPlayer;
} }
export function IndustryOverview(props: IProps): React.ReactElement { export function IndustryOverview(props: IProps): React.ReactElement {
@ -249,7 +252,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
office: office, office: office,
}); });
// corp.displayDivisionContent(division, city); // corp.displayDivisionContent(division, city);
corp.rerender(); corp.rerender(props.player);
} }
} }

@ -21,12 +21,15 @@ import { dialogBoxCreate } from "../../../utils/DialogBox";
import { createPopup } from "../../ui/React/createPopup"; import { createPopup } from "../../ui/React/createPopup";
import { isString } from "../../../utils/helpers/isString"; import { isString } from "../../../utils/helpers/isString";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProductProps { interface IProductProps {
corp: any; corp: ICorporation;
division: any; division: any;
city: string; city: string;
product: any; product: any;
player: IPlayer;
} }
// Creates the UI for a single Product type // Creates the UI for a single Product type
@ -101,6 +104,7 @@ function ProductComponent(props: IProductProps): React.ReactElement {
industry: division, industry: division,
corp: props.corp, corp: props.corp,
popupId: popupId, popupId: popupId,
player: props.player,
}); });
} }
@ -404,6 +408,7 @@ interface IProps {
corp: any; corp: any;
routing: any; routing: any;
currentCity: string; currentCity: string;
player: IPlayer;
} }
export function IndustryWarehouse(props: IProps): React.ReactElement { export function IndustryWarehouse(props: IProps): React.ReactElement {
@ -439,7 +444,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
++warehouse.level; ++warehouse.level;
warehouse.updateSize(corp, division); warehouse.updateSize(corp, division);
corp.funds = corp.funds.minus(sizeUpgradeCost); corp.funds = corp.funds.minus(sizeUpgradeCost);
corp.rerender(); corp.rerender(props.player);
} }
// Industry material Requirements // Industry material Requirements
@ -503,7 +508,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
const smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox"; const smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox";
function smartSupplyOnChange(e: React.ChangeEvent<HTMLInputElement>): void { function smartSupplyOnChange(e: React.ChangeEvent<HTMLInputElement>): void {
warehouse.smartSupplyEnabled = e.target.checked; warehouse.smartSupplyEnabled = e.target.checked;
corp.rerender(); corp.rerender(props.player);
} }
// Create React components for materials // Create React components for materials
@ -529,6 +534,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
for (const productName in division.products) { for (const productName in division.products) {
if (division.products[productName] instanceof Product) { if (division.products[productName] instanceof Product) {
products.push(<ProductComponent products.push(<ProductComponent
player={props.player}
city={props.currentCity} city={props.currentCity}
corp={corp} corp={corp}
division={division} division={division}
@ -600,7 +606,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
size: CorporationConstants.WarehouseInitialSize, size: CorporationConstants.WarehouseInitialSize,
}); });
props.corp.funds = props.corp.funds.minus(CorporationConstants.WarehouseInitialCost); props.corp.funds = props.corp.funds.minus(CorporationConstants.WarehouseInitialCost);
props.corp.rerender(); props.corp.rerender(props.player);
} }
} }

@ -2,10 +2,11 @@ import React, { useState } from 'react';
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { CorporationConstants } from "../data/Constants"; import { CorporationConstants } from "../data/Constants";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
popupId: string; popupId: string;
corp: any; corp: ICorporation;
} }
// Create a popup that lets the player issue & manage dividends // Create a popup that lets the player issue & manage dividends

@ -4,9 +4,10 @@ import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { getRandomInt } from "../../../utils/helpers/getRandomInt"; import { getRandomInt } from "../../../utils/helpers/getRandomInt";
import { CorporationConstants } from "../data/Constants"; import { CorporationConstants } from "../data/Constants";
import { ICorporation } from "../ICorporation";
interface IEffectTextProps { interface IEffectTextProps {
corp: any; corp: ICorporation;
shares: number | null; shares: number | null;
} }

@ -3,11 +3,15 @@ import React from "react";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { CorporationUpgrade } from "../data/CorporationUpgrades";
interface IProps { interface IProps {
upgradeData: number[]; upgradeData: CorporationUpgrade;
upgradeLevel: number; upgradeLevel: number;
corp: any; corp: ICorporation;
player: IPlayer;
} }
export function LevelableUpgrade(props: IProps): React.ReactElement { export function LevelableUpgrade(props: IProps): React.ReactElement {
@ -26,7 +30,7 @@ export function LevelableUpgrade(props: IProps): React.ReactElement {
dialogBoxCreate("Insufficient funds"); dialogBoxCreate("Insufficient funds");
} else { } else {
corp.upgrade(data); corp.upgrade(data);
corp.rerender(); corp.rerender(props.player);
} }
} }

@ -3,11 +3,12 @@ import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { Industries } from "../IndustryData"; import { Industries } from "../IndustryData";
import { Product } from "../Product"; import { Product } from "../Product";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
popupText: string; popupText: string;
division: any; division: any;
corp: any; corp: ICorporation;
popupId: string; popupId: string;
} }

@ -6,9 +6,10 @@ import {
IndustryStartingCosts, IndustryStartingCosts,
IndustryDescriptions } from "../IndustryData"; IndustryDescriptions } from "../IndustryData";
import { Industry } from "../Industry"; import { Industry } from "../Industry";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
corp: any; corp: ICorporation;
popupId: string; popupId: string;
routing: any; routing: any;
} }

@ -174,6 +174,7 @@ export function Overview(props: IProps): React.ReactElement {
function openFindInvestorsPopup(): void { function openFindInvestorsPopup(): void {
const popupId = "cmpy-mgmt-find-investors-popup"; const popupId = "cmpy-mgmt-find-investors-popup";
createPopup(popupId, FindInvestorsPopup, { createPopup(popupId, FindInvestorsPopup, {
player: props.player,
popupId: popupId, popupId: popupId,
corp: props.corp, corp: props.corp,
}); });
@ -182,6 +183,7 @@ export function Overview(props: IProps): React.ReactElement {
function openGoPublicPopup(): void { function openGoPublicPopup(): void {
const popupId = "cmpy-mgmt-go-public-popup"; const popupId = "cmpy-mgmt-go-public-popup";
createPopup(popupId, GoPublicPopup, { createPopup(popupId, GoPublicPopup, {
player: props.player,
popupId: popupId, popupId: popupId,
corp: props.corp, corp: props.corp,
}); });
@ -323,6 +325,7 @@ export function Overview(props: IProps): React.ReactElement {
Object.values(CorporationUnlockUpgrades).forEach((unlockData) => { Object.values(CorporationUnlockUpgrades).forEach((unlockData) => {
if (props.corp.unlockUpgrades[unlockData[0]] === 0) { if (props.corp.unlockUpgrades[unlockData[0]] === 0) {
unlockUpgrades.push(<UnlockUpgrade unlockUpgrades.push(<UnlockUpgrade
player={props.player}
corp={props.corp} corp={props.corp}
upgradeData={unlockData} upgradeData={unlockData}
key={unlockData[0]} key={unlockData[0]}
@ -351,6 +354,7 @@ export function Overview(props: IProps): React.ReactElement {
<h1 className={"cmpy-mgmt-upgrade-header"}> Upgrades </h1> <h1 className={"cmpy-mgmt-upgrade-header"}> Upgrades </h1>
{ {
levelableUpgradeProps.map((data: any) => <LevelableUpgrade levelableUpgradeProps.map((data: any) => <LevelableUpgrade
player={props.player}
corp={props.corp} corp={props.corp}
upgradeData={data.upgradeData} upgradeData={data.upgradeData}
upgradeLevel={data.upgradeLevel} upgradeLevel={data.upgradeLevel}

@ -1,6 +1,7 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { ICorporation } from "../ICorporation";
function initialPrice(mat: any): string { function initialPrice(mat: any): string {
let val = mat.sCost ? mat.sCost : ''; let val = mat.sCost ? mat.sCost : '';
@ -14,7 +15,7 @@ function initialPrice(mat: any): string {
interface IProps { interface IProps {
mat: any; mat: any;
corp: any; corp: ICorporation;
popupId: string; popupId: string;
} }

@ -4,9 +4,10 @@ import { dialogBoxCreate } from "../../../utils/DialogBox";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { CorporationConstants } from "../data/Constants"; import { CorporationConstants } from "../data/Constants";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
corp: any; corp: ICorporation;
player: IPlayer; player: IPlayer;
popupId: string; popupId: string;
} }
@ -49,7 +50,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
props.corp.numShares -= shares; props.corp.numShares -= shares;
if (isNaN(props.corp.issuedShares)) { if (isNaN(props.corp.issuedShares)) {
console.error(`Corporation issuedShares is NaN: ${props.corp.issuedShares}`); console.error(`Corporation issuedShares is NaN: ${props.corp.issuedShares}`);
const res = parseInt(props.corp.issuedShares); const res = props.corp.issuedShares;
if (isNaN(res)) { if (isNaN(res)) {
props.corp.issuedShares = 0; props.corp.issuedShares = 0;
} else { } else {
@ -68,7 +69,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
`The corporation's stock price fell to ${numeralWrapper.formatMoney(props.corp.sharePrice)} ` + `The corporation's stock price fell to ${numeralWrapper.formatMoney(props.corp.sharePrice)} ` +
`as a result of dilution.`); `as a result of dilution.`);
props.corp.rerender(); props.corp.rerender(props.player);
} }
} }

@ -3,10 +3,11 @@ import { removePopup } from "../../ui/React/createPopup";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { IOfficeSpace } from "../IOfficeSpace"; import { IOfficeSpace } from "../IOfficeSpace";
import { ICorporation } from "../ICorporation";
interface IProps { interface IProps {
office: IOfficeSpace; office: IOfficeSpace;
corp: any; corp: ICorporation;
popupId: string; popupId: string;
} }

@ -4,10 +4,13 @@ import React from "react";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { CorporationUnlockUpgrade } from "../data/CorporationUnlockUpgrades"; import { CorporationUnlockUpgrade } from "../data/CorporationUnlockUpgrades";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
upgradeData: CorporationUnlockUpgrade; upgradeData: CorporationUnlockUpgrade;
corp: any; corp: ICorporation;
player: IPlayer;
} }
export function UnlockUpgrade(props: IProps): React.ReactElement { export function UnlockUpgrade(props: IProps): React.ReactElement {
@ -20,7 +23,7 @@ export function UnlockUpgrade(props: IProps): React.ReactElement {
dialogBoxCreate("Insufficient funds"); dialogBoxCreate("Insufficient funds");
} else { } else {
corp.unlock(data); corp.unlock(data);
corp.rerender(); corp.rerender(props.player);
} }
} }

@ -4,11 +4,14 @@ import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { CorporationConstants } from "../data/Constants"; import { CorporationConstants } from "../data/Constants";
import { IOfficeSpace } from "../IOfficeSpace"; import { IOfficeSpace } from "../IOfficeSpace";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
office: IOfficeSpace; office: IOfficeSpace;
corp: any; corp: ICorporation;
popupId: string; popupId: string;
player: IPlayer;
} }
export function UpgradeOfficeSizePopup(props: IProps): React.ReactElement { export function UpgradeOfficeSizePopup(props: IProps): React.ReactElement {
@ -46,7 +49,7 @@ export function UpgradeOfficeSizePopup(props: IProps): React.ReactElement {
props.office.size += size; props.office.size += size;
props.corp.funds = props.corp.funds.minus(cost); props.corp.funds = props.corp.funds.minus(cost);
dialogBoxCreate("Office space increased! It can now hold " + props.office.size + " employees"); dialogBoxCreate("Office space increased! It can now hold " + props.office.size + " employees");
props.corp.rerender(); props.corp.rerender(props.player);
} }
removePopup(props.popupId); removePopup(props.popupId);
} }