Advertising Multiplier: x{numeralWrapper.format(totalAdvertisingFac, "0.000")}
@@ -191,9 +184,9 @@ export function IndustryOverview(props: IProps): React.ReactElement {
}
{advertisingInfo}
- {revenue}
- {expenses}
- {profitStr}
+ Revenue: {Money(division.lastCycleRevenue.toNumber())} / s
+ Expenses: {Money(division.lastCycleExpenses.toNumber())} /s
+ Profit: {Money(profit)} / s
Production Multiplier: {numeralWrapper.format(division.prodMult, "0.00")} @@ -264,8 +257,9 @@ export function IndustryOverview(props: IProps): React.ReactElement { } upgrades.push(renderUpgrade({ + key: index, onClick: onClick, - text: `${upgrade[4]} - ${numeralWrapper.formatMoney(cost)}`, + text: <>{upgrade[4]} - {Money(cost)}>, tooltip: upgrade[5], })); } @@ -274,14 +268,15 @@ export function IndustryOverview(props: IProps): React.ReactElement { } interface IRenderUpgradeProps { + key: string; onClick: () => void; - text: string; + text: JSX.Element; tooltip: string; } function renderUpgrade(props: IRenderUpgradeProps): React.ReactElement { return ( -
-"Dividends are a distribution of a portion of the corporation's
+Dividends are a distribution of a portion of the corporation's
profits to the shareholders. This includes yourself, as well. Total Stock Shares: " + numeralWrapper.format(props.corp.totalShares, "0.000a") +
- "" +
- `Outstanding Shares: ${numeralWrapper.format(props.corp.issuedShares, "0.000a")} {props.name}{numeralWrapper.format(props.mult, "0.000")} Bonus time: {convertTimeMsToTimeElapsedString(storedTime)}
+ Total Funds: {Money(props.corp.funds.toNumber())}
+ Total Stock Shares: {numeralWrapper.format(props.corp.totalShares, "0.000a")}
+
+ Outstanding Shares: {numeralWrapper.format(props.corp.issuedShares, "0.000a")}
In order to issue dividends, simply allocate some percentage
of your corporation's profits to dividends. This percentage must be an
diff --git a/src/Corporation/ui/LevelableUpgrade.tsx b/src/Corporation/ui/LevelableUpgrade.tsx
index b3a8ca93d..a1a9e5170 100644
--- a/src/Corporation/ui/LevelableUpgrade.tsx
+++ b/src/Corporation/ui/LevelableUpgrade.tsx
@@ -6,32 +6,32 @@ import { dialogBoxCreate } from "../../../utils/DialogBox";
import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { CorporationUpgrade } from "../data/CorporationUpgrades";
+import { LevelUpgrade } from "../Actions";
+import { Money } from "../../ui/React/Money";
interface IProps {
- upgradeData: CorporationUpgrade;
- upgradeLevel: number;
+ upgrade: CorporationUpgrade;
corp: ICorporation;
player: IPlayer;
}
export function LevelableUpgrade(props: IProps): React.ReactElement {
- const data = props.upgradeData;
- const level = props.upgradeLevel;
+ const data = props.upgrade;
+ const level = props.corp.upgrades[data[0]];
const baseCost = data[1];
const priceMult = data[2];
const cost = baseCost * Math.pow(priceMult, level);
- const text = `${data[4]} - ${numeralWrapper.formatMoney(cost)}`
+ const text = <>{data[4]} - {Money(cost)}>
const tooltip = data[5];
function onClick(): void {
- const corp = props.corp;
- if (corp.funds.lt(cost)) {
- dialogBoxCreate("Insufficient funds");
- } else {
- corp.upgrade(data);
- corp.rerender(props.player);
+ try {
+ LevelUpgrade(props.corp, props.upgrade);
+ } catch(err) {
+ dialogBoxCreate(err);
}
+ props.corp.rerender(props.player);
}
return (
diff --git a/src/Corporation/ui/NewIndustryPopup.tsx b/src/Corporation/ui/NewIndustryPopup.tsx
index f619e5423..a841aa295 100644
--- a/src/Corporation/ui/NewIndustryPopup.tsx
+++ b/src/Corporation/ui/NewIndustryPopup.tsx
@@ -9,6 +9,7 @@ import { Industry } from "../Industry";
import { ICorporation } from "../ICorporation";
import { IIndustry } from "../IIndustry";
import { CorporationRouting } from "./Routing";
+import { NewIndustry } from "../Actions";
interface IProps {
corp: ICorporation;
@@ -24,33 +25,17 @@ export function NewIndustryPopup(props: IProps): React.ReactElement {
const [name, setName] = useState('');
function newIndustry(): void {
- const ind = industry;
- const newDivisionName = name;
-
- for (let i = 0; i < props.corp.divisions.length; ++i) {
- if (props.corp.divisions[i].name === newDivisionName) {
- dialogBoxCreate("This name is already in use!");
- return;
- }
+ try {
+ NewIndustry(props.corp, industry, name);
+ } catch(err) {
+ dialogBoxCreate(err);
+ return;
}
- if (props.corp.funds.lt(IndustryStartingCosts[ind])) {
- dialogBoxCreate("Not enough money to create a new division in this industry");
- } else if (newDivisionName === "") {
- dialogBoxCreate("New division must have a name!");
- } else {
- props.corp.funds = props.corp.funds.minus(IndustryStartingCosts[ind]);
- const newInd = new Industry({
- corp: props.corp,
- name: newDivisionName,
- type: ind,
- });
- props.corp.divisions.push(newInd);
- // Set routing to the new division so that the UI automatically switches to it
- props.routing.routeTo(newDivisionName);
+ // Set routing to the new division so that the UI automatically switches to it
+ props.routing.routeTo(name);
- removePopup(props.popupId);
- }
+ removePopup(props.popupId);
}
function onNameChange(event: React.ChangeEvent
` +
- `Dividend Percentage: ${numeralWrapper.format(props.corp.dividendPercentage / 100, "0%")}
` +
- `Dividends per share: ${numeralWrapper.format(dividendsPerShare, "$0.000a")} / s
` +
- `Your earnings as a shareholder (Pre-Tax): ${numeralWrapper.format(playerEarnings, "$0.000a")} / s
` +
- `Dividend Tax Rate: ${props.corp.dividendTaxPercentage}%
` +
- `Your earnings as a shareholder (Post-Tax): ${numeralWrapper.format(playerEarnings * (1 - (props.corp.dividendTaxPercentage / 100)), "$0.000a")} / s
`;
- }
-
- let txt = "Total Funds: " + numeralWrapper.format(props.corp.funds.toNumber(), '$0.000a') + "
" +
- "Total Revenue: " + numeralWrapper.format(props.corp.revenue.toNumber(), "$0.000a") + " / s
" +
- "Total Expenses: " + numeralWrapper.format(props.corp.expenses.toNumber(), "$0.000a") + " / s
" +
- "Total Profits: " + profitStr + " / s
" +
- dividendStr +
- "Publicly Traded: " + (props.corp.public ? "Yes" : "No") + "
" +
- "Owned Stock Shares: " + numeralWrapper.format(props.corp.numShares, '0.000a') + "
" +
- "Stock Price: " + (props.corp.public ? numeralWrapper.formatMoney(props.corp.sharePrice) : "N/A") + "
" +
- "
` +
- `Private Shares: ${numeralWrapper.format(props.corp.totalShares - props.corp.issuedShares - props.corp.numShares, "0.000a")}` +
- "
";
-
- const storedTime = props.corp.storedCycles * CONSTANTS.MilliPerCycle;
- if (storedTime > 15000) {
- txt += `Bonus time: ${convertTimeMsToTimeElapsedString(storedTime)}
`;
- }
-
- const prodMult = props.corp.getProductionMultiplier(),
- storageMult = props.corp.getStorageMultiplier(),
- advMult = props.corp.getAdvertisingMultiplier(),
- empCreMult = props.corp.getEmployeeCreMultiplier(),
- empChaMult = props.corp.getEmployeeChaMultiplier(),
- empIntMult = props.corp.getEmployeeIntMultiplier(),
- empEffMult = props.corp.getEmployeeEffMultiplier(),
- salesMult = props.corp.getSalesMultiplier(),
- sciResMult = props.corp.getScientificResearchMultiplier();
- if (prodMult > 1) {txt += "Production Multiplier: " + numeralWrapper.format(prodMult, "0.000") + "
";}
- if (storageMult > 1) {txt += "Storage Multiplier: " + numeralWrapper.format(storageMult, "0.000") + "
";}
- if (advMult > 1) {txt += "Advertising Multiplier: " + numeralWrapper.format(advMult, "0.000") + "
";}
- if (empCreMult > 1) {txt += "Empl. Creativity Multiplier: " + numeralWrapper.format(empCreMult, "0.000") + "
";}
- if (empChaMult > 1) {txt += "Empl. Charisma Multiplier: " + numeralWrapper.format(empChaMult, "0.000") + "
";}
- if (empIntMult > 1) {txt += "Empl. Intelligence Multiplier: " + numeralWrapper.format(empIntMult, "0.000") + "
";}
- if (empEffMult > 1) {txt += "Empl. Efficiency Multiplier: " + numeralWrapper.format(empEffMult, "0.000") + "
";}
- if (salesMult > 1) {txt += "Sales Multiplier: " + numeralWrapper.format(salesMult, "0.000") + "
";}
- if (sciResMult > 1) {txt += "Scientific Research Multiplier: " + numeralWrapper.format(sciResMult, "0.000") + "
";}
-
- return txt;
+ function openBribeFactionPopup(): void {
+ const popupId = "corp-bribe-popup";
+ createPopup(popupId, BribeFactionPopup, {
+ player: props.player,
+ popupId: popupId,
+ corp: props.corp,
+ });
}
- // Render the buttons that lie below the overview text.
- // These are mainly for things such as managing finances/stock
- 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 getStarterGuideBtn = createButton({
- class: "a-link-button",
- display: "inline-block",
- onClick: () => props.corp.getStarterGuide(props.player),
- text: "Getting Started Guide",
- tooltip: "Get a copy of and read 'The Complete Handbook for Creating a Successful Corporation.' " +
- "This is a .lit file that guides you through the beginning of setting up a Corporation and " +
- "provides some tips/pointers for helping you get started with managing it.",
- });
+ const profit: number = props.corp.revenue.minus(props.corp.expenses).toNumber();
- function openBribeFactionPopup(): void {
- const popupId = "corp-bribe-popup";
- createPopup(popupId, BribeFactionPopup, {
- player: props.player,
- popupId: popupId,
- corp: props.corp,
- });
- }
+ function DividendsStats() {
+ if(props.corp.dividendPercentage <= 0 || profit <= 0) return (<>>);
+ const totalDividends = (props.corp.dividendPercentage / 100) * profit;
+ const retainedEarnings = profit - totalDividends;
+ const dividendsPerShare = totalDividends / props.corp.totalShares;
+ const playerEarnings = props.corp.numShares * dividendsPerShare;
+ return (<>
+ Retained Profits (after dividends): {Money(retainedEarnings)} / s
+ Dividend Percentage: {numeralWrapper.format(props.corp.dividendPercentage / 100, "0%")}
+ Dividends per share: {Money(dividendsPerShare)} / s
+ Your earnings as a shareholder (Pre-Tax): {Money(playerEarnings)} / s
+ Dividend Tax Rate: {props.corp.dividendTaxPercentage}%
+ Your earnings as a shareholder (Post-Tax): {Money(playerEarnings * (1 - (props.corp.dividendTaxPercentage / 100)))} / s
+ >);
+ }
- // Create a "Bribe Factions" button if your Corporation is powerful enough.
- // This occurs regardless of whether you're public or private
+ function Mult(props: {name: string, mult: number}): React.ReactElement {
+ if(props.mult <= 1) return (<>>);
+ return (
- {generalBtns.bribeFactions}
-
- {issueNewSharesBtn}
- {issueDividendsBtn}
+
+
- {generalBtns.bribeFactions}
- Unlocks
- {unlockUpgrades}
+ {
+ Object.values(CorporationUnlockUpgrades)
+ .filter((upgrade: CorporationUnlockUpgrade) => props.corp.unlockUpgrades[upgrade[0]] === 0)
+ .map((upgrade: CorporationUnlockUpgrade) =>
+ Upgrades
{
- levelableUpgradeProps.map((data: UpgradeData) =>
+ Total Revenue: {Money(props.corp.revenue.toNumber())} / s
+ Total Expenses: {Money(props.corp.expenses.toNumber())} / s
+ Total Profits: {Money(profit)} / s
+
+ Owned Stock Shares: {numeralWrapper.format(props.corp.numShares, '0.000a')}
+ Stock Price: {(props.corp.public ? Money(props.corp.sharePrice) : "N/A")}
+
+ Private Shares: {numeralWrapper.format(props.corp.totalShares - props.corp.issuedShares - props.corp.numShares, "0.000a")}
+
+
+
- {renderUpgrades()}
+
+