mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
more conversion
This commit is contained in:
parent
a760ede129
commit
21008ba65a
@ -12,7 +12,6 @@ import { MaterialSizes } from "./MaterialSizes";
|
|||||||
import { Product } from "./Product";
|
import { Product } from "./Product";
|
||||||
import { ResearchMap } from "./ResearchMap";
|
import { ResearchMap } from "./ResearchMap";
|
||||||
import { Warehouse } from "./Warehouse";
|
import { Warehouse } from "./Warehouse";
|
||||||
import { Employee } from "./Employee";
|
|
||||||
import { OfficeSpace } from "./OfficeSpace";
|
import { OfficeSpace } from "./OfficeSpace";
|
||||||
|
|
||||||
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
||||||
@ -34,21 +33,16 @@ import { appendLineBreaks } from "../../utils/uiHelp
|
|||||||
import { createElement } from "../../utils/uiHelpers/createElement";
|
import { createElement } from "../../utils/uiHelpers/createElement";
|
||||||
import { createPopup } from "../../utils/uiHelpers/createPopup";
|
import { createPopup } from "../../utils/uiHelpers/createPopup";
|
||||||
import { createPopupCloseButton } from "../../utils/uiHelpers/createPopupCloseButton";
|
import { createPopupCloseButton } from "../../utils/uiHelpers/createPopupCloseButton";
|
||||||
import { formatNumber, generateRandomString } from "../../utils/StringHelperFunctions";
|
import { formatNumber } from "../../utils/StringHelperFunctions";
|
||||||
import { getRandomInt } from "../../utils/helpers/getRandomInt";
|
import { getRandomInt } from "../../utils/helpers/getRandomInt";
|
||||||
import { isString } from "../../utils/helpers/isString";
|
import { isString } from "../../utils/helpers/isString";
|
||||||
import { KEY } from "../../utils/helpers/keyCodes";
|
import { KEY } from "../../utils/helpers/keyCodes";
|
||||||
import { removeElement } from "../../utils/uiHelpers/removeElement";
|
import { removeElement } from "../../utils/uiHelpers/removeElement";
|
||||||
import { removeElementById } from "../../utils/uiHelpers/removeElementById";
|
import { removeElementById } from "../../utils/uiHelpers/removeElementById";
|
||||||
import { yesNoBoxCreate,
|
import { yesNoBoxCreate,
|
||||||
yesNoTxtInpBoxCreate,
|
|
||||||
yesNoBoxGetYesButton,
|
yesNoBoxGetYesButton,
|
||||||
yesNoBoxGetNoButton,
|
yesNoBoxGetNoButton,
|
||||||
yesNoTxtInpBoxGetYesButton,
|
yesNoBoxClose } from "../../utils/YesNoBox";
|
||||||
yesNoTxtInpBoxGetNoButton,
|
|
||||||
yesNoTxtInpBoxGetInput,
|
|
||||||
yesNoBoxClose,
|
|
||||||
yesNoTxtInpBoxClose } from "../../utils/YesNoBox";
|
|
||||||
|
|
||||||
// UI Related Imports
|
// UI Related Imports
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@ -1455,13 +1449,6 @@ Industry.fromJSON = function(value) {
|
|||||||
|
|
||||||
Reviver.constructors.Industry = Industry;
|
Reviver.constructors.Industry = Industry;
|
||||||
|
|
||||||
var OfficeSpaceTiers = {
|
|
||||||
Basic: "Basic",
|
|
||||||
Enhanced: "Enhanced",
|
|
||||||
Luxurious: "Luxurious",
|
|
||||||
Extravagant: "Extravagant",
|
|
||||||
}
|
|
||||||
|
|
||||||
function Corporation(params={}) {
|
function Corporation(params={}) {
|
||||||
this.name = params.name ? params.name : "The Corporation";
|
this.name = params.name ? params.name : "The Corporation";
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ export class Employee {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Returns the amount the employee needs to be paid
|
//Returns the amount the employee needs to be paid
|
||||||
process(marketCycles = 1, office: any) {
|
process(marketCycles = 1, office: any): number {
|
||||||
const gain = 0.003 * marketCycles,
|
const gain = 0.003 * marketCycles,
|
||||||
det = gain * Math.random();
|
det = gain * Math.random();
|
||||||
this.exp += gain;
|
this.exp += gain;
|
||||||
@ -127,7 +127,7 @@ export class Employee {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Process benefits from having an office party thrown
|
//Process benefits from having an office party thrown
|
||||||
throwParty(money: number) {
|
throwParty(money: number): number {
|
||||||
const mult = 1 + (money / 10e6);
|
const mult = 1 + (money / 10e6);
|
||||||
this.mor *= mult;
|
this.mor *= mult;
|
||||||
this.mor = Math.min(100, this.mor);
|
this.mor = Math.min(100, this.mor);
|
||||||
@ -137,7 +137,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) {
|
createUI(panel: any, corporation: any, 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(),
|
||||||
|
@ -3,14 +3,10 @@ import { CorporationConstants } from "./data/Constants";
|
|||||||
import { getRandomInt } from "../../utils/helpers/getRandomInt";
|
import { getRandomInt } from "../../utils/helpers/getRandomInt";
|
||||||
import { formatNumber, generateRandomString } from "../../utils/StringHelperFunctions";
|
import { formatNumber, generateRandomString } from "../../utils/StringHelperFunctions";
|
||||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
|
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
|
||||||
import { yesNoBoxCreate,
|
import { yesNoTxtInpBoxCreate,
|
||||||
yesNoTxtInpBoxCreate,
|
|
||||||
yesNoBoxGetYesButton,
|
|
||||||
yesNoBoxGetNoButton,
|
|
||||||
yesNoTxtInpBoxGetYesButton,
|
yesNoTxtInpBoxGetYesButton,
|
||||||
yesNoTxtInpBoxGetNoButton,
|
yesNoTxtInpBoxGetNoButton,
|
||||||
yesNoTxtInpBoxGetInput,
|
yesNoTxtInpBoxGetInput,
|
||||||
yesNoBoxClose,
|
|
||||||
yesNoTxtInpBoxClose } from "../../utils/YesNoBox";
|
yesNoTxtInpBoxClose } from "../../utils/YesNoBox";
|
||||||
import { dialogBoxCreate } from "../../utils/DialogBox";
|
import { dialogBoxCreate } from "../../utils/DialogBox";
|
||||||
import { createPopup } from "../../utils/uiHelpers/createPopup";
|
import { createPopup } from "../../utils/uiHelpers/createPopup";
|
||||||
@ -126,7 +122,7 @@ export class OfficeSpace {
|
|||||||
return salaryPaid;
|
return salaryPaid;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateEmployeeProductivity(parentRefs: any) {
|
calculateEmployeeProductivity(parentRefs: any): void {
|
||||||
const company = parentRefs.corporation, industry = parentRefs.industry;
|
const company = parentRefs.corporation, industry = parentRefs.industry;
|
||||||
|
|
||||||
//Reset
|
//Reset
|
||||||
@ -145,7 +141,7 @@ export class OfficeSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Takes care of UI as well
|
//Takes care of UI as well
|
||||||
findEmployees(parentRefs: any) {
|
findEmployees(parentRefs: any): void {
|
||||||
if (this.atCapacity()) { return; }
|
if (this.atCapacity()) { return; }
|
||||||
if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;}
|
if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;}
|
||||||
|
|
||||||
@ -191,7 +187,7 @@ export class OfficeSpace {
|
|||||||
innerHTML: "Select one of the following candidates for hire:",
|
innerHTML: "Select one of the following candidates for hire:",
|
||||||
});
|
});
|
||||||
|
|
||||||
const createEmpDiv = function(employee: any, office: any) {
|
function createEmpDiv(employee: any, office: any): HTMLElement {
|
||||||
const div = createElement("div", {
|
const div = createElement("div", {
|
||||||
class:"cmpy-mgmt-find-employee-option",
|
class:"cmpy-mgmt-find-employee-option",
|
||||||
innerHTML: "Intelligence: " + formatNumber(employee.int, 1) + "<br>" +
|
innerHTML: "Intelligence: " + formatNumber(employee.int, 1) + "<br>" +
|
||||||
@ -207,7 +203,7 @@ export class OfficeSpace {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
return div;
|
return div;
|
||||||
};
|
}
|
||||||
|
|
||||||
const cancelBtn = createElement("a", {
|
const cancelBtn = createElement("a", {
|
||||||
class:"a-link-button",
|
class:"a-link-button",
|
||||||
@ -228,7 +224,7 @@ export class OfficeSpace {
|
|||||||
createPopup("cmpy-mgmt-hire-employee-popup", elems);
|
createPopup("cmpy-mgmt-hire-employee-popup", elems);
|
||||||
}
|
}
|
||||||
|
|
||||||
hireEmployee(employee: Employee, parentRefs: any) {
|
hireEmployee(employee: Employee, parentRefs: any): void {
|
||||||
const company = parentRefs.corporation;
|
const company = parentRefs.corporation;
|
||||||
const yesBtn = yesNoTxtInpBoxGetYesButton(),
|
const yesBtn = yesNoTxtInpBoxGetYesButton(),
|
||||||
noBtn = yesNoTxtInpBoxGetNoButton();
|
noBtn = yesNoTxtInpBoxGetNoButton();
|
||||||
|
@ -25,6 +25,10 @@ export function BribeFactionPopup(props: IProps): React.ReactElement {
|
|||||||
setStock(parseFloat(event.target.value));
|
setStock(parseFloat(event.target.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeFaction(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
|
setSelectedFaction(event.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
function repGain(money: number, stock: number): number {
|
function repGain(money: number, stock: number): number {
|
||||||
return (money + (stock * props.corp.sharePrice)) / CorporationConstants.BribeToRepRatio;
|
return (money + (stock * props.corp.sharePrice)) / CorporationConstants.BribeToRepRatio;
|
||||||
}
|
}
|
||||||
@ -45,7 +49,7 @@ export function BribeFactionPopup(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bribe(money: number, stock: number) {
|
function bribe(money: number, stock: number): void {
|
||||||
const fac = Factions[selectedFaction];
|
const fac = Factions[selectedFaction];
|
||||||
if (fac == null) {
|
if (fac == null) {
|
||||||
dialogBoxCreate("ERROR: You must select a faction to bribe");
|
dialogBoxCreate("ERROR: You must select a faction to bribe");
|
||||||
@ -66,7 +70,7 @@ export function BribeFactionPopup(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
<p>You can use Corporation funds or stock shares to bribe Faction Leaders in exchange for faction reputation.</p>
|
<p>You can use Corporation funds or stock shares to bribe Faction Leaders in exchange for faction reputation.</p>
|
||||||
<select className="dropdown" style={{margin: "3px"}} defaultValue={selectedFaction}>
|
<select className="dropdown" style={{margin: "3px"}} defaultValue={selectedFaction} onChange={changeFaction}>
|
||||||
{
|
{
|
||||||
props.player.factions.map((name: string) => {
|
props.player.factions.map((name: string) => {
|
||||||
const info = Factions[name].getInfo();
|
const info = Factions[name].getInfo();
|
||||||
|
@ -3,12 +3,11 @@ 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 { createElement } from "../../../utils/uiHelpers/createElement";
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
player: IPlayer,
|
player: IPlayer;
|
||||||
popupId: string,
|
popupId: string;
|
||||||
corp: any,
|
corp: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a popup that lets the player buyback shares
|
// Create a popup that lets the player buyback shares
|
||||||
@ -24,7 +23,7 @@ export function BuybackSharesPopup(props: IProps): React.ReactElement {
|
|||||||
const currentStockPrice = props.corp.sharePrice;
|
const currentStockPrice = props.corp.sharePrice;
|
||||||
const buybackPrice = currentStockPrice * 1.1;
|
const buybackPrice = currentStockPrice * 1.1;
|
||||||
|
|
||||||
function buy() {
|
function buy(): void {
|
||||||
if(shares === null) return;
|
if(shares === null) return;
|
||||||
const tempStockPrice = props.corp.sharePrice;
|
const tempStockPrice = props.corp.sharePrice;
|
||||||
const buybackPrice = tempStockPrice * 1.1;
|
const buybackPrice = tempStockPrice * 1.1;
|
||||||
@ -66,7 +65,7 @@ export function BuybackSharesPopup(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
|
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||||
if (event.keyCode === 13) buy();
|
if (event.keyCode === 13) buy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ interface IProps {
|
|||||||
export function CityTabs(props: IProps): React.ReactElement {
|
export function CityTabs(props: IProps): React.ReactElement {
|
||||||
const division = props.routing.currentDivision;
|
const division = props.routing.currentDivision;
|
||||||
|
|
||||||
function openExpandNewCityModal() {
|
function openExpandNewCityModal(): void {
|
||||||
const popupId = "cmpy-mgmt-expand-city-popup";
|
const popupId = "cmpy-mgmt-expand-city-popup";
|
||||||
createPopup(popupId, ExpandNewCityPopup, {
|
createPopup(popupId, ExpandNewCityPopup, {
|
||||||
popupId: popupId,
|
popupId: popupId,
|
||||||
|
@ -4,13 +4,7 @@ import { Corporation,
|
|||||||
Industry,
|
Industry,
|
||||||
Warehouse,
|
Warehouse,
|
||||||
DividendMaxPercentage,
|
DividendMaxPercentage,
|
||||||
IssueNewSharesCooldown,
|
IssueNewSharesCooldown } from "../Corporation";
|
||||||
OfficeInitialCost,
|
|
||||||
OfficeInitialSize,
|
|
||||||
SellSharesCooldown,
|
|
||||||
WarehouseInitialCost,
|
|
||||||
WarehouseInitialSize,
|
|
||||||
BribeToRepRatio } from "../Corporation";
|
|
||||||
import { OfficeSpace } from "../OfficeSpace";
|
import { OfficeSpace } from "../OfficeSpace";
|
||||||
|
|
||||||
import { Industries,
|
import { Industries,
|
||||||
@ -22,9 +16,6 @@ import { MaterialSizes } from "../MaterialSizes";
|
|||||||
|
|
||||||
import { Product } from "../Product";
|
import { Product } from "../Product";
|
||||||
|
|
||||||
import { Player } from "../../Player";
|
|
||||||
|
|
||||||
import { Factions } from "../../Faction/Factions";
|
|
||||||
import { Cities } from "../../Locations/Cities";
|
import { Cities } from "../../Locations/Cities";
|
||||||
|
|
||||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||||
|
@ -10,7 +10,7 @@ interface IProps {
|
|||||||
|
|
||||||
// Create a popup that lets the player discontinue a product
|
// Create a popup that lets the player discontinue a product
|
||||||
export function DiscontinueProductPopup(props: IProps): React.ReactElement {
|
export function DiscontinueProductPopup(props: IProps): React.ReactElement {
|
||||||
function discontinue() {
|
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();
|
||||||
|
@ -12,7 +12,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function HeaderTabs(props: IProps): React.ReactElement {
|
export function HeaderTabs(props: IProps): React.ReactElement {
|
||||||
function overviewOnClick() {
|
function overviewOnClick(): void {
|
||||||
props.routing.routeToOverviewPage();
|
props.routing.routeToOverviewPage();
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
const [numUnassigned, setNumUnassigned] = useState(0);
|
const [numUnassigned, setNumUnassigned] = useState(0);
|
||||||
const [numTraining, setNumTraining] = useState(0);
|
const [numTraining, setNumTraining] = useState(0);
|
||||||
|
|
||||||
function resetEmployeeCount() {
|
function resetEmployeeCount(): void {
|
||||||
setNumEmployees(0);
|
setNumEmployees(0);
|
||||||
setNumOperations(0);
|
setNumOperations(0);
|
||||||
setNumEngineers(0);
|
setNumEngineers(0);
|
||||||
@ -45,7 +45,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
setNumTraining(0);
|
setNumTraining(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateEmployeeCount() {
|
function updateEmployeeCount(): void {
|
||||||
const division = props.routing.currentDivision;
|
const division = props.routing.currentDivision;
|
||||||
if (division == null) {
|
if (division == null) {
|
||||||
throw new Error(`Routing does not hold reference to the current Industry`);
|
throw new Error(`Routing does not hold reference to the current Industry`);
|
||||||
@ -116,7 +116,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
updateEmployeeCount();
|
updateEmployeeCount();
|
||||||
|
|
||||||
// Renders the "Employee Management" section of the Office UI
|
// Renders the "Employee Management" section of the Office UI
|
||||||
function renderEmployeeManagement() {
|
function renderEmployeeManagement(): React.ReactElement {
|
||||||
updateEmployeeCount();
|
updateEmployeeCount();
|
||||||
|
|
||||||
if (employeeManualAssignMode) {
|
if (employeeManualAssignMode) {
|
||||||
@ -126,12 +126,12 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderAutomaticEmployeeManagement() {
|
function renderAutomaticEmployeeManagement(): React.ReactElement {
|
||||||
const division = props.routing.currentDivision; // Validated in constructor
|
const division = props.routing.currentDivision; // Validated in constructor
|
||||||
const office = division.offices[props.currentCity]; // Validated in constructor
|
const office = division.offices[props.currentCity]; // Validated in constructor
|
||||||
const vechain = (props.corp.unlockUpgrades[4] === 1); // Has Vechain upgrade
|
const vechain = (props.corp.unlockUpgrades[4] === 1); // Has Vechain upgrade
|
||||||
|
|
||||||
const switchModeOnClick = () => {
|
function switchModeOnClick(): void {
|
||||||
setEmployeeManualAssignMode(true);
|
setEmployeeManualAssignMode(true);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions for (re-)assigning employees to different positions
|
// Helper functions for (re-)assigning employees to different positions
|
||||||
function assignEmployee(to: string) {
|
function assignEmployee(to: string): void {
|
||||||
if (numUnassigned <= 0) {
|
if (numUnassigned <= 0) {
|
||||||
console.warn("Cannot assign employee. No unassigned employees available");
|
console.warn("Cannot assign employee. No unassigned employees available");
|
||||||
return;
|
return;
|
||||||
@ -193,8 +193,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
function unassignEmployee(from: string) {
|
function unassignEmployee(from: string): void {
|
||||||
function logWarning(pos: string) {
|
function logWarning(pos: string): void {
|
||||||
console.warn(`Cannot unassign from ${pos} because there is nobody assigned to that position`);
|
console.warn(`Cannot unassign from ${pos} because there is nobody assigned to that position`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,61 +244,61 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
const assignButtonClass = numUnassigned > 0 ? "std-button" : "a-link-button-inactive";
|
const assignButtonClass = numUnassigned > 0 ? "std-button" : "a-link-button-inactive";
|
||||||
|
|
||||||
const operationAssignButtonOnClick = () => {
|
function operationAssignButtonOnClick(): void {
|
||||||
assignEmployee(EmployeePositions.Operations);
|
assignEmployee(EmployeePositions.Operations);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const operationUnassignButtonOnClick = () => {
|
function operationUnassignButtonOnClick(): void {
|
||||||
unassignEmployee(EmployeePositions.Operations);
|
unassignEmployee(EmployeePositions.Operations);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const operationUnassignButtonClass = numOperations > 0 ? "std-button" : "a-link-button-inactive";
|
const operationUnassignButtonClass = numOperations > 0 ? "std-button" : "a-link-button-inactive";
|
||||||
|
|
||||||
const engineerAssignButtonOnClick = () => {
|
function engineerAssignButtonOnClick(): void {
|
||||||
assignEmployee(EmployeePositions.Engineer);
|
assignEmployee(EmployeePositions.Engineer);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const engineerUnassignButtonOnClick = () => {
|
function engineerUnassignButtonOnClick(): void {
|
||||||
unassignEmployee(EmployeePositions.Engineer);
|
unassignEmployee(EmployeePositions.Engineer);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const engineerUnassignButtonClass = numEngineers > 0 ? "std-button" : "a-link-button-inactive";
|
const engineerUnassignButtonClass = numEngineers > 0 ? "std-button" : "a-link-button-inactive";
|
||||||
|
|
||||||
const businessAssignButtonOnClick = () => {
|
function businessAssignButtonOnClick(): void {
|
||||||
assignEmployee(EmployeePositions.Business);
|
assignEmployee(EmployeePositions.Business);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const businessUnassignButtonOnClick = () => {
|
function businessUnassignButtonOnClick(): void {
|
||||||
unassignEmployee(EmployeePositions.Business);
|
unassignEmployee(EmployeePositions.Business);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const businessUnassignButtonClass = numBusiness > 0 ? "std-button" : "a-link-button-inactive";
|
const businessUnassignButtonClass = numBusiness > 0 ? "std-button" : "a-link-button-inactive";
|
||||||
|
|
||||||
const managementAssignButtonOnClick = () => {
|
function managementAssignButtonOnClick(): void {
|
||||||
assignEmployee(EmployeePositions.Management);
|
assignEmployee(EmployeePositions.Management);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const managementUnassignButtonOnClick = () => {
|
function managementUnassignButtonOnClick(): void {
|
||||||
unassignEmployee(EmployeePositions.Management);
|
unassignEmployee(EmployeePositions.Management);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const managementUnassignButtonClass = numManagement > 0 ? "std-button" : "a-link-button-inactive";
|
const managementUnassignButtonClass = numManagement > 0 ? "std-button" : "a-link-button-inactive";
|
||||||
|
|
||||||
const rndAssignButtonOnClick = () => {
|
function rndAssignButtonOnClick(): void {
|
||||||
assignEmployee(EmployeePositions.RandD);
|
assignEmployee(EmployeePositions.RandD);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const rndUnassignButtonOnClick = () => {
|
function rndUnassignButtonOnClick(): void {
|
||||||
unassignEmployee(EmployeePositions.RandD);
|
unassignEmployee(EmployeePositions.RandD);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const rndUnassignButtonClass = numResearch > 0 ? "std-button" : "a-link-button-inactive";
|
const rndUnassignButtonClass = numResearch > 0 ? "std-button" : "a-link-button-inactive";
|
||||||
|
|
||||||
const trainingAssignButtonOnClick = () => {
|
function trainingAssignButtonOnClick(): void {
|
||||||
assignEmployee(EmployeePositions.Training);
|
assignEmployee(EmployeePositions.Training);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
const trainingUnassignButtonOnClick = () => {
|
function trainingUnassignButtonOnClick(): void {
|
||||||
unassignEmployee(EmployeePositions.Training);
|
unassignEmployee(EmployeePositions.Training);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
@ -427,12 +427,12 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderManualEmployeeManagement() {
|
function renderManualEmployeeManagement(): React.ReactElement {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
const division = props.routing.currentDivision; // Validated in constructor
|
const division = props.routing.currentDivision; // Validated in constructor
|
||||||
const office = division.offices[props.currentCity]; // Validated in constructor
|
const office = division.offices[props.currentCity]; // Validated in constructor
|
||||||
|
|
||||||
const switchModeOnClick = () => {
|
function switchModeOnClick(): void {
|
||||||
setEmployeeManualAssignMode(false);
|
setEmployeeManualAssignMode(false);
|
||||||
props.corp.rerender();
|
props.corp.rerender();
|
||||||
}
|
}
|
||||||
@ -449,7 +449,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
employees.push(<option key={office.employees[i].name}>{office.employees[i].name}</option>)
|
employees.push(<option key={office.employees[i].name}>{office.employees[i].name}</option>)
|
||||||
}
|
}
|
||||||
|
|
||||||
const employeeSelectorOnChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
function employeeSelectorOnChange(e: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
const name = getSelectText(e.target);
|
const name = getSelectText(e.target);
|
||||||
for (let i = 0; i < office.employees.length; ++i) {
|
for (let i = 0; i < office.employees.length; ++i) {
|
||||||
if (name === office.employees[i].name) {
|
if (name === office.employees[i].name) {
|
||||||
@ -473,7 +473,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function employeePositionSelectorOnChange(e: React.ChangeEvent<HTMLSelectElement>) {
|
function employeePositionSelectorOnChange(e: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
if(employee === null) return;
|
if(employee === null) return;
|
||||||
const pos = getSelectText(e.target);
|
const pos = getSelectText(e.target);
|
||||||
employee.pos = pos;
|
employee.pos = pos;
|
||||||
@ -557,7 +557,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const hireEmployeeButtonOnClick = () => {
|
function hireEmployeeButtonOnClick(): void {
|
||||||
office.findEmployees({ corporation: corp, industry: division });
|
office.findEmployees({ corporation: corp, industry: division });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function IndustryOverview(props: IProps): React.ReactElement {
|
export function IndustryOverview(props: IProps): React.ReactElement {
|
||||||
function renderMakeProductButton() {
|
function renderMakeProductButton(): React.ReactElement {
|
||||||
const division = props.routing.currentDivision; // Validated inside render()
|
const division = props.routing.currentDivision; // Validated inside render()
|
||||||
|
|
||||||
let createProductButtonText = "";
|
let createProductButtonText = "";
|
||||||
@ -59,7 +59,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
|||||||
default:
|
default:
|
||||||
createProductButtonText = "Create Product";
|
createProductButtonText = "Create Product";
|
||||||
createProductPopupText = "Create a new product!";
|
createProductPopupText = "Create a new product!";
|
||||||
return "";
|
return (<></>);
|
||||||
}
|
}
|
||||||
createProductPopupText += "<br><br>To begin developing a product, " +
|
createProductPopupText += "<br><br>To begin developing a product, " +
|
||||||
"first choose the city in which it will be designed. The stats of your employees " +
|
"first choose the city in which it will be designed. The stats of your employees " +
|
||||||
@ -90,7 +90,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderText() {
|
function renderText(): React.ReactElement {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
const division = props.routing.currentDivision; // Validated inside render()
|
const division = props.routing.currentDivision; // Validated inside render()
|
||||||
|
|
||||||
@ -113,11 +113,11 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
|||||||
const expenses = `Expenses: ${numeralWrapper.formatMoney(division.lastCycleExpenses.toNumber())} /s`;
|
const expenses = `Expenses: ${numeralWrapper.formatMoney(division.lastCycleExpenses.toNumber())} /s`;
|
||||||
const profitStr = `Profit: ${numeralWrapper.formatMoney(profit)} / s`;
|
const profitStr = `Profit: ${numeralWrapper.formatMoney(profit)} / s`;
|
||||||
|
|
||||||
const productionMultHelpTipOnClick = () => {
|
function productionMultHelpTipOnClick(): void {
|
||||||
// Wrapper for createProgressBarText()
|
// Wrapper for createProgressBarText()
|
||||||
// Converts the industry's "effectiveness factors"
|
// Converts the industry's "effectiveness factors"
|
||||||
// into a graphic (string) depicting how high that effectiveness is
|
// into a graphic (string) depicting how high that effectiveness is
|
||||||
function convertEffectFacToGraphic(fac: number) {
|
function convertEffectFacToGraphic(fac: number): string {
|
||||||
return createProgressBarText({
|
return createProgressBarText({
|
||||||
progress: fac,
|
progress: fac,
|
||||||
totalTicks: 20,
|
totalTicks: 20,
|
||||||
@ -191,7 +191,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderUpgrades() {
|
function renderUpgrades(): React.ReactElement[] {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
const division = props.routing.currentDivision; // Validated inside render()
|
const division = props.routing.currentDivision; // Validated inside render()
|
||||||
const office = division.offices[props.currentCity];
|
const office = division.offices[props.currentCity];
|
||||||
@ -219,7 +219,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClick = () => {
|
function onClick(): void {
|
||||||
if (corp.funds.lt(cost)) {
|
if (corp.funds.lt(cost)) {
|
||||||
dialogBoxCreate("Insufficient funds");
|
dialogBoxCreate("Insufficient funds");
|
||||||
} else {
|
} else {
|
||||||
@ -243,7 +243,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
|||||||
return upgrades;
|
return upgrades;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderUpgrade(props: any) {
|
function renderUpgrade(props: any): React.ReactElement {
|
||||||
return (
|
return (
|
||||||
<div className={"cmpy-mgmt-upgrade-div tooltip"} onClick={props.onClick} key={props.text}>
|
<div className={"cmpy-mgmt-upgrade-div tooltip"} onClick={props.onClick} key={props.text}>
|
||||||
{props.text}
|
{props.text}
|
||||||
|
@ -24,7 +24,7 @@ interface IProductProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates the UI for a single Product type
|
// Creates the UI for a single Product type
|
||||||
function ProductComponent(props: IProductProps) {
|
function ProductComponent(props: IProductProps): React.ReactElement {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
const division = props.division;
|
const division = props.division;
|
||||||
const city = props.city;
|
const city = props.city;
|
||||||
@ -73,7 +73,7 @@ function ProductComponent(props: IProductProps) {
|
|||||||
}
|
}
|
||||||
const limitProductionButtonOnClick = eventHandler.createLimitProductProdutionPopup.bind(eventHandler, product, city);
|
const limitProductionButtonOnClick = eventHandler.createLimitProductProdutionPopup.bind(eventHandler, product, city);
|
||||||
|
|
||||||
function openDiscontinueProductPopup() {
|
function openDiscontinueProductPopup(): void {
|
||||||
const popupId = "cmpy-mgmt-discontinue-product-popup";
|
const popupId = "cmpy-mgmt-discontinue-product-popup";
|
||||||
createPopup(popupId, DiscontinueProductPopup, {
|
createPopup(popupId, DiscontinueProductPopup, {
|
||||||
product: product,
|
product: product,
|
||||||
@ -206,7 +206,7 @@ interface IMaterialProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates the UI for a single Material type
|
// Creates the UI for a single Material type
|
||||||
function MaterialComponent(props: IMaterialProps) {
|
function MaterialComponent(props: IMaterialProps): React.ReactElement {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
const division = props.division;
|
const division = props.division;
|
||||||
const warehouse = props.warehouse;
|
const warehouse = props.warehouse;
|
||||||
@ -351,7 +351,7 @@ interface IProps {
|
|||||||
eventHandler: any;
|
eventHandler: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function IndustryWarehouse(props: IProps) {
|
export function IndustryWarehouse(props: IProps): React.ReactElement {
|
||||||
// Returns a boolean indicating whether the given material is relevant for the
|
// Returns a boolean indicating whether the given material is relevant for the
|
||||||
// current industry.
|
// current industry.
|
||||||
function isRelevantMaterial(matName: string, division: any): boolean {
|
function isRelevantMaterial(matName: string, division: any): boolean {
|
||||||
@ -365,7 +365,7 @@ export function IndustryWarehouse(props: IProps) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderWarehouseUI() {
|
function renderWarehouseUI(): React.ReactElement {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
const division = props.routing.currentDivision; // Validated in render()
|
const division = props.routing.currentDivision; // Validated in render()
|
||||||
const warehouse = division.warehouses[props.currentCity]; // Validated in render()
|
const warehouse = division.warehouses[props.currentCity]; // Validated in render()
|
||||||
@ -380,12 +380,11 @@ export function IndustryWarehouse(props: IProps) {
|
|||||||
const sizeUpgradeCost = CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
const sizeUpgradeCost = CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
||||||
const canAffordUpgrade = (corp.funds.gt(sizeUpgradeCost));
|
const canAffordUpgrade = (corp.funds.gt(sizeUpgradeCost));
|
||||||
const upgradeWarehouseClass = canAffordUpgrade ? "std-button" : "a-link-button-inactive";
|
const upgradeWarehouseClass = canAffordUpgrade ? "std-button" : "a-link-button-inactive";
|
||||||
const upgradeWarehouseOnClick = () => {
|
function upgradeWarehouseOnClick(): void {
|
||||||
++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();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Industry material Requirements
|
// Industry material Requirements
|
||||||
@ -447,7 +446,7 @@ export function IndustryWarehouse(props: IProps) {
|
|||||||
|
|
||||||
// Smart Supply Checkbox
|
// Smart Supply Checkbox
|
||||||
const smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox";
|
const smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox";
|
||||||
const smartSupplyOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
function smartSupplyOnChange(e: React.ChangeEvent<HTMLInputElement>): void {
|
||||||
warehouse.smartSupplyEnabled = e.target.checked;
|
warehouse.smartSupplyEnabled = e.target.checked;
|
||||||
corp.rerender();
|
corp.rerender();
|
||||||
}
|
}
|
||||||
@ -537,7 +536,7 @@ export function IndustryWarehouse(props: IProps) {
|
|||||||
}
|
}
|
||||||
const warehouse = division.warehouses[props.currentCity];
|
const warehouse = division.warehouses[props.currentCity];
|
||||||
|
|
||||||
function purchaseWarehouse(division: any, city: string) {
|
function purchaseWarehouse(division: any, city: string): void {
|
||||||
if (props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)) {
|
if (props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)) {
|
||||||
dialogBoxCreate("You do not have enough funds to do this!");
|
dialogBoxCreate("You do not have enough funds to do this!");
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,7 +20,7 @@ export function LevelableUpgrade(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
const text = `${data[4]} - ${numeralWrapper.formatMoney(cost)}`
|
const text = `${data[4]} - ${numeralWrapper.formatMoney(cost)}`
|
||||||
const tooltip = data[5];
|
const tooltip = data[5];
|
||||||
function onClick() {
|
function onClick(): void {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
if (corp.funds.lt(cost)) {
|
if (corp.funds.lt(cost)) {
|
||||||
dialogBoxCreate("Insufficient funds");
|
dialogBoxCreate("Insufficient funds");
|
||||||
|
@ -32,7 +32,7 @@ export function MainPanel(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderOverviewPage() {
|
function renderOverviewPage(): React.ReactElement {
|
||||||
return (
|
return (
|
||||||
<div id="cmpy-mgmt-panel">
|
<div id="cmpy-mgmt-panel">
|
||||||
<Overview {...props} />
|
<Overview {...props} />
|
||||||
@ -40,7 +40,7 @@ export function MainPanel(props: IProps): React.ReactElement {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDivisionPage() {
|
function renderDivisionPage(): React.ReactElement {
|
||||||
// Note: Division is the same thing as Industry...I wasn't consistent with naming
|
// Note: Division is the same thing as Industry...I wasn't consistent with naming
|
||||||
const division = props.routing.currentDivision;
|
const division = props.routing.currentDivision;
|
||||||
if (division == null) {
|
if (division == null) {
|
||||||
|
@ -24,7 +24,7 @@ interface IProps {
|
|||||||
|
|
||||||
export function Overview(props: IProps): React.ReactElement {
|
export function Overview(props: IProps): React.ReactElement {
|
||||||
// Generic Function for Creating a button
|
// Generic Function for Creating a button
|
||||||
function createButton(props: any) {
|
function createButton(props: any): React.ReactElement {
|
||||||
let className = props.class ? props.class : "std-button";
|
let className = props.class ? props.class : "std-button";
|
||||||
const displayStyle = props.display ? props.display : "block";
|
const displayStyle = props.display ? props.display : "block";
|
||||||
const hasTooltip = (props.tooltip != null);
|
const hasTooltip = (props.tooltip != null);
|
||||||
@ -46,7 +46,7 @@ export function Overview(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string with general information about Corporation
|
// Returns a string with general information about Corporation
|
||||||
function getOverviewText() {
|
function getOverviewText(): string {
|
||||||
// Formatted text for profit
|
// Formatted text for profit
|
||||||
const profit = props.corp.revenue.minus(props.corp.expenses).toNumber(),
|
const profit = props.corp.revenue.minus(props.corp.expenses).toNumber(),
|
||||||
profitStr = profit >= 0 ? numeralWrapper.formatMoney(profit) : "-" + numeralWrapper.format(-1 * profit, "$0.000a");
|
profitStr = profit >= 0 ? numeralWrapper.formatMoney(profit) : "-" + numeralWrapper.format(-1 * profit, "$0.000a");
|
||||||
@ -110,7 +110,7 @@ export function Overview(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
// Render the buttons that lie below the overview text.
|
// Render the buttons that lie below the overview text.
|
||||||
// These are mainly for things such as managing finances/stock
|
// These are mainly for things such as managing finances/stock
|
||||||
function renderButtons() {
|
function renderButtons(): React.ReactElement {
|
||||||
// Create a "Getting Started Guide" button that lets player view the
|
// Create a "Getting Started Guide" button that lets player view the
|
||||||
// handbook and adds it to the players home computer
|
// handbook and adds it to the players home computer
|
||||||
const getStarterGuideOnClick = props.corp.getStarterGuide.bind(props.corp);
|
const getStarterGuideOnClick = props.corp.getStarterGuide.bind(props.corp);
|
||||||
@ -124,7 +124,7 @@ export function Overview(props: IProps): React.ReactElement {
|
|||||||
"provides some tips/pointers for helping you get started with managing it.",
|
"provides some tips/pointers for helping you get started with managing it.",
|
||||||
});
|
});
|
||||||
|
|
||||||
function openBribeFactionPopup() {
|
function openBribeFactionPopup(): void {
|
||||||
const popupId = "corp-bribe-popup";
|
const popupId = "corp-bribe-popup";
|
||||||
createPopup(popupId, BribeFactionPopup, {
|
createPopup(popupId, BribeFactionPopup, {
|
||||||
player: props.player,
|
player: props.player,
|
||||||
@ -162,7 +162,7 @@ export function Overview(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
|
|
||||||
// Render the buttons for when your Corporation is still private
|
// Render the buttons for when your Corporation is still private
|
||||||
function renderPrivateButtons(generalBtns: any) {
|
function renderPrivateButtons(generalBtns: any): React.ReactElement {
|
||||||
const fundingAvailable = (props.corp.fundingRound < 4);
|
const fundingAvailable = (props.corp.fundingRound < 4);
|
||||||
const findInvestorsClassName = fundingAvailable ? "std-button" : "a-link-button-inactive";
|
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" : null;
|
||||||
@ -202,7 +202,7 @@ export function Overview(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the buttons for when your Corporation has gone public
|
// Render the buttons for when your Corporation has gone public
|
||||||
function renderPublicButtons(generalBtns: any) {
|
function renderPublicButtons(generalBtns: any): React.ReactElement {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
|
|
||||||
const sellSharesOnCd = (corp.shareSaleCooldown > 0);
|
const sellSharesOnCd = (corp.shareSaleCooldown > 0);
|
||||||
@ -228,7 +228,7 @@ export function Overview(props: IProps): React.ReactElement {
|
|||||||
tooltip: sellSharesTooltip,
|
tooltip: sellSharesTooltip,
|
||||||
});
|
});
|
||||||
|
|
||||||
function openBuybackSharesPopup() {
|
function openBuybackSharesPopup(): void {
|
||||||
const popupId = "corp-buyback-shares-popup";
|
const popupId = "corp-buyback-shares-popup";
|
||||||
createPopup(popupId, BuybackSharesPopup, {
|
createPopup(popupId, BuybackSharesPopup, {
|
||||||
player: props.player,
|
player: props.player,
|
||||||
@ -281,9 +281,9 @@ export function Overview(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render the UI for Corporation upgrades
|
// Render the UI for Corporation upgrades
|
||||||
function renderUpgrades() {
|
function renderUpgrades(): React.ReactElement {
|
||||||
// Don't show upgrades
|
// Don't show upgrades
|
||||||
if (props.corp.divisions.length <= 0) { return; }
|
if (props.corp.divisions.length <= 0) { return (<></>); }
|
||||||
|
|
||||||
// Create an array of all Unlocks
|
// Create an array of all Unlocks
|
||||||
const unlockUpgrades: React.ReactElement[] = [];
|
const unlockUpgrades: React.ReactElement[] = [];
|
||||||
|
@ -4,7 +4,6 @@ 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 { createElement } from "../../../utils/uiHelpers/createElement";
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
corp: any;
|
corp: any;
|
||||||
@ -22,7 +21,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
|
|||||||
else setShares(Math.round(parseFloat(event.target.value)));
|
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: any}): React.ReactElement {
|
||||||
if(props.shares === null) return (<></>);
|
if(props.shares === null) return (<></>);
|
||||||
if (isNaN(props.shares) || props.shares <= 0) {
|
if (isNaN(props.shares) || props.shares <= 0) {
|
||||||
return (<>ERROR: Invalid value entered for number of shares to sell</>);
|
return (<>ERROR: Invalid value entered for number of shares to sell</>);
|
||||||
@ -35,7 +34,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sell() {
|
function sell(): void {
|
||||||
if(shares === null) return;
|
if(shares === null) return;
|
||||||
if (isNaN(shares) || shares <= 0) {
|
if (isNaN(shares) || shares <= 0) {
|
||||||
dialogBoxCreate("ERROR: Invalid value for number of shares");
|
dialogBoxCreate("ERROR: Invalid value for number of shares");
|
||||||
@ -50,7 +49,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}`);
|
||||||
var res = parseInt(props.corp.issuedShares);
|
const res = parseInt(props.corp.issuedShares);
|
||||||
if (isNaN(res)) {
|
if (isNaN(res)) {
|
||||||
props.corp.issuedShares = 0;
|
props.corp.issuedShares = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -74,7 +73,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
|
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||||
if (event.keyCode === 13) sell();
|
if (event.keyCode === 13) sell();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export function ThrowPartyPopup(props: IProps): React.ReactElement {
|
|||||||
setCost(parseFloat(event.target.value));
|
setCost(parseFloat(event.target.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
function throwParty() {
|
function throwParty(): void {
|
||||||
if (cost === null || isNaN(cost) || cost < 0) {
|
if (cost === null || isNaN(cost) || cost < 0) {
|
||||||
dialogBoxCreate("Invalid value entered");
|
dialogBoxCreate("Invalid value entered");
|
||||||
} else {
|
} else {
|
||||||
@ -37,14 +37,14 @@ export function ThrowPartyPopup(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function EffectText(props: {cost: number | null, office: IOfficeSpace}): React.ReactElement {
|
function EffectText(props: {cost: number | null; office: IOfficeSpace}): React.ReactElement {
|
||||||
let cost = props.cost;
|
let cost = props.cost;
|
||||||
if(cost !== null && (isNaN(cost) || cost < 0)) return <p>Invalid value entered!</p>
|
if(cost !== null && (isNaN(cost) || cost < 0)) return <p>Invalid value entered!</p>
|
||||||
if(cost === null) cost = 0;
|
if(cost === null) cost = 0;
|
||||||
return <p>Throwing this party will cost a total of {numeralWrapper.formatMoney(cost * props.office.employees.length)}</p>
|
return <p>Throwing this party will cost a total of {numeralWrapper.formatMoney(cost * props.office.employees.length)}</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
|
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||||
if (event.keyCode === 13) throwParty();
|
if (event.keyCode === 13) throwParty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export function UnlockUpgrade(props: IProps): React.ReactElement {
|
|||||||
const data = props.upgradeData;
|
const data = props.upgradeData;
|
||||||
const text = `${data[2]} - ${numeralWrapper.formatMoney(data[1])}`;
|
const text = `${data[2]} - ${numeralWrapper.formatMoney(data[1])}`;
|
||||||
const tooltip = data[3];
|
const tooltip = data[3];
|
||||||
function onClick() {
|
function onClick(): void {
|
||||||
const corp = props.corp;
|
const corp = props.corp;
|
||||||
if (corp.funds.lt(data[1])) {
|
if (corp.funds.lt(data[1])) {
|
||||||
dialogBoxCreate("Insufficient funds");
|
dialogBoxCreate("Insufficient funds");
|
||||||
|
@ -24,12 +24,12 @@ export function UpgradeOfficeSizePopup(props: IProps): React.ReactElement {
|
|||||||
const upgradeCost15 = CorporationConstants.OfficeInitialCost * mult;
|
const upgradeCost15 = CorporationConstants.OfficeInitialCost * mult;
|
||||||
|
|
||||||
//Calculate max upgrade size and cost
|
//Calculate max upgrade size and cost
|
||||||
let maxMult = (props.corp.funds.dividedBy(CorporationConstants.OfficeInitialCost)).toNumber();
|
const maxMult = (props.corp.funds.dividedBy(CorporationConstants.OfficeInitialCost)).toNumber();
|
||||||
let maxNum = 1;
|
let maxNum = 1;
|
||||||
mult = Math.pow(costMultiplier, initialPriceMult);
|
mult = Math.pow(costMultiplier, initialPriceMult);
|
||||||
while(maxNum < 50) { //Hard cap of 50x (extra 150 employees)
|
while(maxNum < 50) { //Hard cap of 50x (extra 150 employees)
|
||||||
if (mult >= maxMult) break;
|
if (mult >= maxMult) break;
|
||||||
let multIncrease = Math.pow(costMultiplier, initialPriceMult + maxNum);
|
const multIncrease = Math.pow(costMultiplier, initialPriceMult + maxNum);
|
||||||
if (mult + multIncrease > maxMult) {
|
if (mult + multIncrease > maxMult) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user