CORPORATION: Account for CapEx and Cap Gains differently (#977)

This commit is contained in:
Jesse Clark
2023-12-16 01:56:57 -08:00
committed by GitHub
parent a6436ca4b3
commit 417671ecb8
3 changed files with 9 additions and 6 deletions

View File

@ -74,7 +74,7 @@ export function purchaseOffice(corporation: Corporation, division: Division, cit
if (division.offices[city]) {
throw new Error(`You have already expanded into ${city} for ${division.name}`);
}
corporation.loseFunds(corpConstants.officeInitialCost, "office");
corporation.loseFunds(corpConstants.officeInitialCost, "division");
division.offices[city] = new OfficeSpace({
city: city,
size: corpConstants.officeInitialSize,
@ -391,7 +391,7 @@ export function ThrowParty(corp: Corporation, office: OfficeSpace, costPerEmploy
export function purchaseWarehouse(corp: Corporation, division: Division, city: CityName): void {
if (corp.funds < corpConstants.warehouseInitialCost) return;
if (division.warehouses[city]) return;
corp.loseFunds(corpConstants.warehouseInitialCost, "warehouse");
corp.loseFunds(corpConstants.warehouseInitialCost, "division");
division.warehouses[city] = new Warehouse({
division: division,
loc: city,

View File

@ -5,7 +5,6 @@ import { CorporationState } from "./CorporationState";
import { CorpUnlocks } from "./data/CorporationUnlocks";
import { CorpUpgrades } from "./data/CorporationUpgrades";
import * as corpConstants from "./data/Constants";
import { IndustriesData } from "./data/IndustryData";
import { FundsSource, LongTermFundsSources } from "./data/FundsSource";
import { Division } from "./Division";
import { calculateUpgradeCost } from "./helpers";
@ -84,7 +83,11 @@ export class Corporation {
return;
}
if (LongTermFundsSources.has(source)) {
this.totalAssets += amt;
// This cycle's assets include the purchase price of a capital expenditure.
// (It will likely depreciate in the following cycle.)
// Or the value of some non-accounted item (equity, hashes) that was sold for a capital gain.
// (It will remain as funds, with no effect on assetDelta.)
this.totalAssets += Math.abs(amt);
}
this.funds += amt;
}
@ -225,7 +228,7 @@ export class Corporation {
updateTotalAssets(): void {
let assets = this.funds;
this.divisions.forEach((ind) => {
assets += IndustriesData[ind.type].startingCost;
assets += ind.calculateRecoupableValue();
for (const warehouse of getRecordValues(ind.warehouses)) {
for (const mat of getRecordValues(warehouse.materials)) {
assets += mat.stored * mat.averagePrice;

View File

@ -2,7 +2,6 @@
// This includes capital expenditures (which may be recoupable), time-limited actions, and transfers to/from other game mechanics.
const FundsSourceLongTerm = [
"product development",
"division",
"office",
"warehouse",
"upgrades",
@ -16,6 +15,7 @@ const FundsSourceLongTerm = [
// Funds transactions which should be included in earnings projections for valuation.
// This includes all automatic or indefinetly-repeatable income and operating expenses.
type FundsSourceShortTerm =
| "division"
| "operating expenses"
| "operating revenue"
| "dividends"