mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-26 16:07:33 +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 { ResearchMap } from "./ResearchMap";
|
||||
import { Warehouse } from "./Warehouse";
|
||||
import { Employee } from "./Employee";
|
||||
import { OfficeSpace } from "./OfficeSpace";
|
||||
|
||||
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
||||
@ -34,21 +33,16 @@ import { appendLineBreaks } from "../../utils/uiHelp
|
||||
import { createElement } from "../../utils/uiHelpers/createElement";
|
||||
import { createPopup } from "../../utils/uiHelpers/createPopup";
|
||||
import { createPopupCloseButton } from "../../utils/uiHelpers/createPopupCloseButton";
|
||||
import { formatNumber, generateRandomString } from "../../utils/StringHelperFunctions";
|
||||
import { formatNumber } from "../../utils/StringHelperFunctions";
|
||||
import { getRandomInt } from "../../utils/helpers/getRandomInt";
|
||||
import { isString } from "../../utils/helpers/isString";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
import { removeElement } from "../../utils/uiHelpers/removeElement";
|
||||
import { removeElementById } from "../../utils/uiHelpers/removeElementById";
|
||||
import { yesNoBoxCreate,
|
||||
yesNoTxtInpBoxCreate,
|
||||
yesNoBoxGetYesButton,
|
||||
yesNoBoxGetNoButton,
|
||||
yesNoTxtInpBoxGetYesButton,
|
||||
yesNoTxtInpBoxGetNoButton,
|
||||
yesNoTxtInpBoxGetInput,
|
||||
yesNoBoxClose,
|
||||
yesNoTxtInpBoxClose } from "../../utils/YesNoBox";
|
||||
yesNoBoxClose } from "../../utils/YesNoBox";
|
||||
|
||||
// UI Related Imports
|
||||
import React from "react";
|
||||
@ -1455,13 +1449,6 @@ Industry.fromJSON = function(value) {
|
||||
|
||||
Reviver.constructors.Industry = Industry;
|
||||
|
||||
var OfficeSpaceTiers = {
|
||||
Basic: "Basic",
|
||||
Enhanced: "Enhanced",
|
||||
Luxurious: "Luxurious",
|
||||
Extravagant: "Extravagant",
|
||||
}
|
||||
|
||||
function Corporation(params={}) {
|
||||
this.name = params.name ? params.name : "The Corporation";
|
||||
|
||||
|
@ -56,7 +56,7 @@ export class Employee {
|
||||
}
|
||||
|
||||
//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,
|
||||
det = gain * Math.random();
|
||||
this.exp += gain;
|
||||
@ -127,7 +127,7 @@ export class Employee {
|
||||
}
|
||||
|
||||
//Process benefits from having an office party thrown
|
||||
throwParty(money: number) {
|
||||
throwParty(money: number): number {
|
||||
const mult = 1 + (money / 10e6);
|
||||
this.mor *= mult;
|
||||
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
|
||||
createUI(panel: any, corporation: any, industry: any) {
|
||||
createUI(panel: any, corporation: any, industry: any): void {
|
||||
const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(),
|
||||
effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(),
|
||||
effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(),
|
||||
|
@ -3,14 +3,10 @@ import { CorporationConstants } from "./data/Constants";
|
||||
import { getRandomInt } from "../../utils/helpers/getRandomInt";
|
||||
import { formatNumber, generateRandomString } from "../../utils/StringHelperFunctions";
|
||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
|
||||
import { yesNoBoxCreate,
|
||||
yesNoTxtInpBoxCreate,
|
||||
yesNoBoxGetYesButton,
|
||||
yesNoBoxGetNoButton,
|
||||
import { yesNoTxtInpBoxCreate,
|
||||
yesNoTxtInpBoxGetYesButton,
|
||||
yesNoTxtInpBoxGetNoButton,
|
||||
yesNoTxtInpBoxGetInput,
|
||||
yesNoBoxClose,
|
||||
yesNoTxtInpBoxClose } from "../../utils/YesNoBox";
|
||||
import { dialogBoxCreate } from "../../utils/DialogBox";
|
||||
import { createPopup } from "../../utils/uiHelpers/createPopup";
|
||||
@ -126,7 +122,7 @@ export class OfficeSpace {
|
||||
return salaryPaid;
|
||||
}
|
||||
|
||||
calculateEmployeeProductivity(parentRefs: any) {
|
||||
calculateEmployeeProductivity(parentRefs: any): void {
|
||||
const company = parentRefs.corporation, industry = parentRefs.industry;
|
||||
|
||||
//Reset
|
||||
@ -145,7 +141,7 @@ export class OfficeSpace {
|
||||
}
|
||||
|
||||
//Takes care of UI as well
|
||||
findEmployees(parentRefs: any) {
|
||||
findEmployees(parentRefs: any): void {
|
||||
if (this.atCapacity()) { 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:",
|
||||
});
|
||||
|
||||
const createEmpDiv = function(employee: any, office: any) {
|
||||
function createEmpDiv(employee: any, office: any): HTMLElement {
|
||||
const div = createElement("div", {
|
||||
class:"cmpy-mgmt-find-employee-option",
|
||||
innerHTML: "Intelligence: " + formatNumber(employee.int, 1) + "<br>" +
|
||||
@ -207,7 +203,7 @@ export class OfficeSpace {
|
||||
},
|
||||
});
|
||||
return div;
|
||||
};
|
||||
}
|
||||
|
||||
const cancelBtn = createElement("a", {
|
||||
class:"a-link-button",
|
||||
@ -228,7 +224,7 @@ export class OfficeSpace {
|
||||
createPopup("cmpy-mgmt-hire-employee-popup", elems);
|
||||
}
|
||||
|
||||
hireEmployee(employee: Employee, parentRefs: any) {
|
||||
hireEmployee(employee: Employee, parentRefs: any): void {
|
||||
const company = parentRefs.corporation;
|
||||
const yesBtn = yesNoTxtInpBoxGetYesButton(),
|
||||
noBtn = yesNoTxtInpBoxGetNoButton();
|
||||
|
@ -25,6 +25,10 @@ export function BribeFactionPopup(props: IProps): React.ReactElement {
|
||||
setStock(parseFloat(event.target.value));
|
||||
}
|
||||
|
||||
function changeFaction(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||
setSelectedFaction(event.target.value);
|
||||
}
|
||||
|
||||
function repGain(money: number, stock: number): number {
|
||||
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];
|
||||
if (fac == null) {
|
||||
dialogBoxCreate("ERROR: You must select a faction to bribe");
|
||||
@ -66,7 +70,7 @@ export function BribeFactionPopup(props: IProps): React.ReactElement {
|
||||
|
||||
return (<>
|
||||
<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) => {
|
||||
const info = Factions[name].getInfo();
|
||||
|
@ -3,12 +3,11 @@ import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { createElement } from "../../../utils/uiHelpers/createElement";
|
||||
|
||||
interface IProps {
|
||||
player: IPlayer,
|
||||
popupId: string,
|
||||
corp: any,
|
||||
player: IPlayer;
|
||||
popupId: string;
|
||||
corp: any;
|
||||
}
|
||||
|
||||
// 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 buybackPrice = currentStockPrice * 1.1;
|
||||
|
||||
function buy() {
|
||||
function buy(): void {
|
||||
if(shares === null) return;
|
||||
const tempStockPrice = props.corp.sharePrice;
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ interface IProps {
|
||||
export function CityTabs(props: IProps): React.ReactElement {
|
||||
const division = props.routing.currentDivision;
|
||||
|
||||
function openExpandNewCityModal() {
|
||||
function openExpandNewCityModal(): void {
|
||||
const popupId = "cmpy-mgmt-expand-city-popup";
|
||||
createPopup(popupId, ExpandNewCityPopup, {
|
||||
popupId: popupId,
|
||||
|
@ -4,13 +4,7 @@ import { Corporation,
|
||||
Industry,
|
||||
Warehouse,
|
||||
DividendMaxPercentage,
|
||||
IssueNewSharesCooldown,
|
||||
OfficeInitialCost,
|
||||
OfficeInitialSize,
|
||||
SellSharesCooldown,
|
||||
WarehouseInitialCost,
|
||||
WarehouseInitialSize,
|
||||
BribeToRepRatio } from "../Corporation";
|
||||
IssueNewSharesCooldown } from "../Corporation";
|
||||
import { OfficeSpace } from "../OfficeSpace";
|
||||
|
||||
import { Industries,
|
||||
@ -22,9 +16,6 @@ import { MaterialSizes } from "../MaterialSizes";
|
||||
|
||||
import { Product } from "../Product";
|
||||
|
||||
import { Player } from "../../Player";
|
||||
|
||||
import { Factions } from "../../Faction/Factions";
|
||||
import { Cities } from "../../Locations/Cities";
|
||||
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
|
@ -10,7 +10,7 @@ interface IProps {
|
||||
|
||||
// Create a popup that lets the player discontinue a product
|
||||
export function DiscontinueProductPopup(props: IProps): React.ReactElement {
|
||||
function discontinue() {
|
||||
function discontinue(): void {
|
||||
props.industry.discontinueProduct(props.product);
|
||||
removePopup(props.popupId);
|
||||
props.corp.rerender();
|
||||
|
@ -12,7 +12,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function HeaderTabs(props: IProps): React.ReactElement {
|
||||
function overviewOnClick() {
|
||||
function overviewOnClick(): void {
|
||||
props.routing.routeToOverviewPage();
|
||||
props.corp.rerender();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
const [numUnassigned, setNumUnassigned] = useState(0);
|
||||
const [numTraining, setNumTraining] = useState(0);
|
||||
|
||||
function resetEmployeeCount() {
|
||||
function resetEmployeeCount(): void {
|
||||
setNumEmployees(0);
|
||||
setNumOperations(0);
|
||||
setNumEngineers(0);
|
||||
@ -45,7 +45,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
setNumTraining(0);
|
||||
}
|
||||
|
||||
function updateEmployeeCount() {
|
||||
function updateEmployeeCount(): void {
|
||||
const division = props.routing.currentDivision;
|
||||
if (division == null) {
|
||||
throw new Error(`Routing does not hold reference to the current Industry`);
|
||||
@ -116,7 +116,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
updateEmployeeCount();
|
||||
|
||||
// Renders the "Employee Management" section of the Office UI
|
||||
function renderEmployeeManagement() {
|
||||
function renderEmployeeManagement(): React.ReactElement {
|
||||
updateEmployeeCount();
|
||||
|
||||
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 office = division.offices[props.currentCity]; // Validated in constructor
|
||||
const vechain = (props.corp.unlockUpgrades[4] === 1); // Has Vechain upgrade
|
||||
|
||||
const switchModeOnClick = () => {
|
||||
function switchModeOnClick(): void {
|
||||
setEmployeeManualAssignMode(true);
|
||||
props.corp.rerender();
|
||||
}
|
||||
@ -154,7 +154,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
// Helper functions for (re-)assigning employees to different positions
|
||||
function assignEmployee(to: string) {
|
||||
function assignEmployee(to: string): void {
|
||||
if (numUnassigned <= 0) {
|
||||
console.warn("Cannot assign employee. No unassigned employees available");
|
||||
return;
|
||||
@ -193,8 +193,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
|
||||
props.corp.rerender();
|
||||
}
|
||||
|
||||
function unassignEmployee(from: string) {
|
||||
function logWarning(pos: string) {
|
||||
function unassignEmployee(from: string): void {
|
||||
function logWarning(pos: string): void {
|
||||
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 operationAssignButtonOnClick = () => {
|
||||
function operationAssignButtonOnClick(): void {
|
||||
assignEmployee(EmployeePositions.Operations);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const operationUnassignButtonOnClick = () => {
|
||||
function operationUnassignButtonOnClick(): void {
|
||||
unassignEmployee(EmployeePositions.Operations);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const operationUnassignButtonClass = numOperations > 0 ? "std-button" : "a-link-button-inactive";
|
||||
|
||||
const engineerAssignButtonOnClick = () => {
|
||||
function engineerAssignButtonOnClick(): void {
|
||||
assignEmployee(EmployeePositions.Engineer);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const engineerUnassignButtonOnClick = () => {
|
||||
function engineerUnassignButtonOnClick(): void {
|
||||
unassignEmployee(EmployeePositions.Engineer);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const engineerUnassignButtonClass = numEngineers > 0 ? "std-button" : "a-link-button-inactive";
|
||||
|
||||
const businessAssignButtonOnClick = () => {
|
||||
function businessAssignButtonOnClick(): void {
|
||||
assignEmployee(EmployeePositions.Business);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const businessUnassignButtonOnClick = () => {
|
||||
function businessUnassignButtonOnClick(): void {
|
||||
unassignEmployee(EmployeePositions.Business);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const businessUnassignButtonClass = numBusiness > 0 ? "std-button" : "a-link-button-inactive";
|
||||
|
||||
const managementAssignButtonOnClick = () => {
|
||||
function managementAssignButtonOnClick(): void {
|
||||
assignEmployee(EmployeePositions.Management);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const managementUnassignButtonOnClick = () => {
|
||||
function managementUnassignButtonOnClick(): void {
|
||||
unassignEmployee(EmployeePositions.Management);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const managementUnassignButtonClass = numManagement > 0 ? "std-button" : "a-link-button-inactive";
|
||||
|
||||
const rndAssignButtonOnClick = () => {
|
||||
function rndAssignButtonOnClick(): void {
|
||||
assignEmployee(EmployeePositions.RandD);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const rndUnassignButtonOnClick = () => {
|
||||
function rndUnassignButtonOnClick(): void {
|
||||
unassignEmployee(EmployeePositions.RandD);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const rndUnassignButtonClass = numResearch > 0 ? "std-button" : "a-link-button-inactive";
|
||||
|
||||
const trainingAssignButtonOnClick = () => {
|
||||
function trainingAssignButtonOnClick(): void {
|
||||
assignEmployee(EmployeePositions.Training);
|
||||
props.corp.rerender();
|
||||
}
|
||||
const trainingUnassignButtonOnClick = () => {
|
||||
function trainingUnassignButtonOnClick(): void {
|
||||
unassignEmployee(EmployeePositions.Training);
|
||||
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 division = props.routing.currentDivision; // Validated in constructor
|
||||
const office = division.offices[props.currentCity]; // Validated in constructor
|
||||
|
||||
const switchModeOnClick = () => {
|
||||
function switchModeOnClick(): void {
|
||||
setEmployeeManualAssignMode(false);
|
||||
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>)
|
||||
}
|
||||
|
||||
const employeeSelectorOnChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
function employeeSelectorOnChange(e: React.ChangeEvent<HTMLSelectElement>): void {
|
||||
const name = getSelectText(e.target);
|
||||
for (let i = 0; i < office.employees.length; ++i) {
|
||||
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;
|
||||
const pos = getSelectText(e.target);
|
||||
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 });
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
function renderMakeProductButton() {
|
||||
function renderMakeProductButton(): React.ReactElement {
|
||||
const division = props.routing.currentDivision; // Validated inside render()
|
||||
|
||||
let createProductButtonText = "";
|
||||
@ -59,7 +59,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
default:
|
||||
createProductButtonText = "Create Product";
|
||||
createProductPopupText = "Create a new product!";
|
||||
return "";
|
||||
return (<></>);
|
||||
}
|
||||
createProductPopupText += "<br><br>To begin developing a product, " +
|
||||
"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 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 profitStr = `Profit: ${numeralWrapper.formatMoney(profit)} / s`;
|
||||
|
||||
const productionMultHelpTipOnClick = () => {
|
||||
function productionMultHelpTipOnClick(): void {
|
||||
// Wrapper for createProgressBarText()
|
||||
// Converts the industry's "effectiveness factors"
|
||||
// into a graphic (string) depicting how high that effectiveness is
|
||||
function convertEffectFacToGraphic(fac: number) {
|
||||
function convertEffectFacToGraphic(fac: number): string {
|
||||
return createProgressBarText({
|
||||
progress: fac,
|
||||
totalTicks: 20,
|
||||
@ -191,7 +191,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
)
|
||||
}
|
||||
|
||||
function renderUpgrades() {
|
||||
function renderUpgrades(): React.ReactElement[] {
|
||||
const corp = props.corp;
|
||||
const division = props.routing.currentDivision; // Validated inside render()
|
||||
const office = division.offices[props.currentCity];
|
||||
@ -219,7 +219,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
break;
|
||||
}
|
||||
|
||||
const onClick = () => {
|
||||
function onClick(): void {
|
||||
if (corp.funds.lt(cost)) {
|
||||
dialogBoxCreate("Insufficient funds");
|
||||
} else {
|
||||
@ -243,7 +243,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
function renderUpgrade(props: any) {
|
||||
function renderUpgrade(props: any): React.ReactElement {
|
||||
return (
|
||||
<div className={"cmpy-mgmt-upgrade-div tooltip"} onClick={props.onClick} key={props.text}>
|
||||
{props.text}
|
||||
|
@ -24,7 +24,7 @@ interface IProductProps {
|
||||
}
|
||||
|
||||
// Creates the UI for a single Product type
|
||||
function ProductComponent(props: IProductProps) {
|
||||
function ProductComponent(props: IProductProps): React.ReactElement {
|
||||
const corp = props.corp;
|
||||
const division = props.division;
|
||||
const city = props.city;
|
||||
@ -73,7 +73,7 @@ function ProductComponent(props: IProductProps) {
|
||||
}
|
||||
const limitProductionButtonOnClick = eventHandler.createLimitProductProdutionPopup.bind(eventHandler, product, city);
|
||||
|
||||
function openDiscontinueProductPopup() {
|
||||
function openDiscontinueProductPopup(): void {
|
||||
const popupId = "cmpy-mgmt-discontinue-product-popup";
|
||||
createPopup(popupId, DiscontinueProductPopup, {
|
||||
product: product,
|
||||
@ -206,7 +206,7 @@ interface IMaterialProps {
|
||||
}
|
||||
|
||||
// Creates the UI for a single Material type
|
||||
function MaterialComponent(props: IMaterialProps) {
|
||||
function MaterialComponent(props: IMaterialProps): React.ReactElement {
|
||||
const corp = props.corp;
|
||||
const division = props.division;
|
||||
const warehouse = props.warehouse;
|
||||
@ -351,7 +351,7 @@ interface IProps {
|
||||
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
|
||||
// current industry.
|
||||
function isRelevantMaterial(matName: string, division: any): boolean {
|
||||
@ -365,7 +365,7 @@ export function IndustryWarehouse(props: IProps) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function renderWarehouseUI() {
|
||||
function renderWarehouseUI(): React.ReactElement {
|
||||
const corp = props.corp;
|
||||
const division = props.routing.currentDivision; // 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 canAffordUpgrade = (corp.funds.gt(sizeUpgradeCost));
|
||||
const upgradeWarehouseClass = canAffordUpgrade ? "std-button" : "a-link-button-inactive";
|
||||
const upgradeWarehouseOnClick = () => {
|
||||
function upgradeWarehouseOnClick(): void {
|
||||
++warehouse.level;
|
||||
warehouse.updateSize(corp, division);
|
||||
corp.funds = corp.funds.minus(sizeUpgradeCost);
|
||||
corp.rerender();
|
||||
return;
|
||||
}
|
||||
|
||||
// Industry material Requirements
|
||||
@ -447,7 +446,7 @@ export function IndustryWarehouse(props: IProps) {
|
||||
|
||||
// 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;
|
||||
corp.rerender();
|
||||
}
|
||||
@ -537,7 +536,7 @@ export function IndustryWarehouse(props: IProps) {
|
||||
}
|
||||
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)) {
|
||||
dialogBoxCreate("You do not have enough funds to do this!");
|
||||
} else {
|
||||
|
@ -20,7 +20,7 @@ export function LevelableUpgrade(props: IProps): React.ReactElement {
|
||||
|
||||
const text = `${data[4]} - ${numeralWrapper.formatMoney(cost)}`
|
||||
const tooltip = data[5];
|
||||
function onClick() {
|
||||
function onClick(): void {
|
||||
const corp = props.corp;
|
||||
if (corp.funds.lt(cost)) {
|
||||
dialogBoxCreate("Insufficient funds");
|
||||
|
@ -32,7 +32,7 @@ export function MainPanel(props: IProps): React.ReactElement {
|
||||
}
|
||||
}
|
||||
|
||||
function renderOverviewPage() {
|
||||
function renderOverviewPage(): React.ReactElement {
|
||||
return (
|
||||
<div id="cmpy-mgmt-panel">
|
||||
<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
|
||||
const division = props.routing.currentDivision;
|
||||
if (division == null) {
|
||||
|
@ -24,7 +24,7 @@ interface IProps {
|
||||
|
||||
export function Overview(props: IProps): React.ReactElement {
|
||||
// Generic Function for Creating a button
|
||||
function createButton(props: any) {
|
||||
function createButton(props: any): React.ReactElement {
|
||||
let className = props.class ? props.class : "std-button";
|
||||
const displayStyle = props.display ? props.display : "block";
|
||||
const hasTooltip = (props.tooltip != null);
|
||||
@ -46,7 +46,7 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
// Returns a string with general information about Corporation
|
||||
function getOverviewText() {
|
||||
function getOverviewText(): string {
|
||||
// Formatted text for profit
|
||||
const profit = props.corp.revenue.minus(props.corp.expenses).toNumber(),
|
||||
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.
|
||||
// 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
|
||||
// handbook and adds it to the players home computer
|
||||
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.",
|
||||
});
|
||||
|
||||
function openBribeFactionPopup() {
|
||||
function openBribeFactionPopup(): void {
|
||||
const popupId = "corp-bribe-popup";
|
||||
createPopup(popupId, BribeFactionPopup, {
|
||||
player: props.player,
|
||||
@ -162,7 +162,7 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
|
||||
|
||||
// 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 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;
|
||||
@ -202,7 +202,7 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
// 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 sellSharesOnCd = (corp.shareSaleCooldown > 0);
|
||||
@ -228,7 +228,7 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
tooltip: sellSharesTooltip,
|
||||
});
|
||||
|
||||
function openBuybackSharesPopup() {
|
||||
function openBuybackSharesPopup(): void {
|
||||
const popupId = "corp-buyback-shares-popup";
|
||||
createPopup(popupId, BuybackSharesPopup, {
|
||||
player: props.player,
|
||||
@ -281,9 +281,9 @@ export function Overview(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
// Render the UI for Corporation upgrades
|
||||
function renderUpgrades() {
|
||||
function renderUpgrades(): React.ReactElement {
|
||||
// Don't show upgrades
|
||||
if (props.corp.divisions.length <= 0) { return; }
|
||||
if (props.corp.divisions.length <= 0) { return (<></>); }
|
||||
|
||||
// Create an array of all Unlocks
|
||||
const unlockUpgrades: React.ReactElement[] = [];
|
||||
|
@ -4,7 +4,6 @@ import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { removePopup } from "../../ui/React/createPopup";
|
||||
import { CorporationConstants } from "../data/Constants";
|
||||
import { createElement } from "../../../utils/uiHelpers/createElement";
|
||||
|
||||
interface IProps {
|
||||
corp: any;
|
||||
@ -22,7 +21,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
|
||||
else setShares(Math.round(parseFloat(event.target.value)));
|
||||
}
|
||||
|
||||
function ProfitIndicator(props: {shares: number | null, corp: any}): React.ReactElement {
|
||||
function ProfitIndicator(props: {shares: number | null; corp: any}): React.ReactElement {
|
||||
if(props.shares === null) return (<></>);
|
||||
if (isNaN(props.shares) || props.shares <= 0) {
|
||||
return (<>ERROR: Invalid value entered for number of shares to sell</>);
|
||||
@ -35,7 +34,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
|
||||
}
|
||||
}
|
||||
|
||||
function sell() {
|
||||
function sell(): void {
|
||||
if(shares === null) return;
|
||||
if (isNaN(shares) || shares <= 0) {
|
||||
dialogBoxCreate("ERROR: Invalid value for number of shares");
|
||||
@ -50,7 +49,7 @@ export function SellSharesPopup(props: IProps): React.ReactElement {
|
||||
props.corp.numShares -= shares;
|
||||
if (isNaN(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)) {
|
||||
props.corp.issuedShares = 0;
|
||||
} 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();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ export function ThrowPartyPopup(props: IProps): React.ReactElement {
|
||||
setCost(parseFloat(event.target.value));
|
||||
}
|
||||
|
||||
function throwParty() {
|
||||
function throwParty(): void {
|
||||
if (cost === null || isNaN(cost) || cost < 0) {
|
||||
dialogBoxCreate("Invalid value entered");
|
||||
} 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;
|
||||
if(cost !== null && (isNaN(cost) || cost < 0)) return <p>Invalid value entered!</p>
|
||||
if(cost === null) cost = 0;
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ export function UnlockUpgrade(props: IProps): React.ReactElement {
|
||||
const data = props.upgradeData;
|
||||
const text = `${data[2]} - ${numeralWrapper.formatMoney(data[1])}`;
|
||||
const tooltip = data[3];
|
||||
function onClick() {
|
||||
function onClick(): void {
|
||||
const corp = props.corp;
|
||||
if (corp.funds.lt(data[1])) {
|
||||
dialogBoxCreate("Insufficient funds");
|
||||
|
@ -24,12 +24,12 @@ export function UpgradeOfficeSizePopup(props: IProps): React.ReactElement {
|
||||
const upgradeCost15 = CorporationConstants.OfficeInitialCost * mult;
|
||||
|
||||
//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;
|
||||
mult = Math.pow(costMultiplier, initialPriceMult);
|
||||
while(maxNum < 50) { //Hard cap of 50x (extra 150 employees)
|
||||
if (mult >= maxMult) break;
|
||||
let multIncrease = Math.pow(costMultiplier, initialPriceMult + maxNum);
|
||||
const multIncrease = Math.pow(costMultiplier, initialPriceMult + maxNum);
|
||||
if (mult + multIncrease > maxMult) {
|
||||
break;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user