mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
Bunch of corporation fixes
This commit is contained in:
parent
2a43b90ed3
commit
d99d37f191
@ -1,6 +1,8 @@
|
||||
import { Player } from "../Player";
|
||||
import { IPlayer } from "src/PersonObjects/IPlayer";
|
||||
import { MaterialSizes } from "./MaterialSizes";
|
||||
import { ICorporation } from "./ICorporation";
|
||||
import { Corporation } from "./Corporation";
|
||||
import { IIndustry } from "./IIndustry";
|
||||
import { IndustryStartingCosts, IndustryResearchTrees } from "./IndustryData";
|
||||
import { Industry } from "./Industry";
|
||||
@ -463,6 +465,23 @@ export function Research(division: IIndustry, researchName: string): void {
|
||||
// Get the Node from the Research Tree and set its 'researched' property
|
||||
researchTree.research(researchName);
|
||||
division.researched[researchName] = true;
|
||||
|
||||
// I couldn't figure out where else to put this so that warehouse size would get updated instantly
|
||||
// whether research is done by script or UI. All other stats gets calculated in every cycle
|
||||
// Warehouse size gets updated only when something increases it.
|
||||
if (researchName == "Drones - Transport") {
|
||||
for (let i = 0; i < CorporationConstants.Cities.length; ++i) {
|
||||
const city = CorporationConstants.Cities[i];
|
||||
const warehouse = division.warehouses[city];
|
||||
if (!(warehouse instanceof Warehouse)) {
|
||||
continue;
|
||||
}
|
||||
if (Player.corporation instanceof Corporation) {
|
||||
// Stores cycles in a "buffer". Processed separately using Engine Counters
|
||||
warehouse.updateSize(Player.corporation, division);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function ExportMaterial(
|
||||
|
@ -83,6 +83,10 @@ export class Corporation {
|
||||
const gameCycles = marketCycles * CorporationConstants.CyclesPerIndustryStateCycle;
|
||||
this.storedCycles -= gameCycles;
|
||||
|
||||
this.divisions.forEach((ind) => {
|
||||
ind.resetImports(state);
|
||||
});
|
||||
|
||||
this.divisions.forEach((ind) => {
|
||||
ind.process(marketCycles, state, this);
|
||||
});
|
||||
@ -230,6 +234,7 @@ export class Corporation {
|
||||
let sharePrice = this.sharePrice;
|
||||
let sharesSold = 0;
|
||||
let profit = 0;
|
||||
let targetPrice = this.getTargetSharePrice();
|
||||
|
||||
const maxIterations = Math.ceil(numShares / CorporationConstants.SHARESPERPRICEUPDATE);
|
||||
if (isNaN(maxIterations) || maxIterations > 10e6) {
|
||||
@ -249,9 +254,13 @@ export class Corporation {
|
||||
sharesUntilUpdate = CorporationConstants.SHARESPERPRICEUPDATE;
|
||||
sharesTracker -= sharesUntilUpdate;
|
||||
sharesSold += sharesUntilUpdate;
|
||||
|
||||
targetPrice = this.valuation / (2 * (this.totalShares + sharesSold - this.numShares));
|
||||
// Calculate what new share price would be
|
||||
sharePrice = this.valuation / (2 * (this.totalShares + sharesSold - this.numShares));
|
||||
if (sharePrice <= targetPrice) {
|
||||
sharePrice *= 1 + 0.5 * 0.01;
|
||||
} else {
|
||||
sharePrice *= 1 - 0.5 * 0.01;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ export interface IIndustry {
|
||||
processMaterials(marketCycles: number, corporation: ICorporation): [number, number];
|
||||
processProducts(marketCycles: number, corporation: ICorporation): [number, number];
|
||||
processProduct(marketCycles: number, product: Product, corporation: ICorporation): number;
|
||||
resetImports(state: string): void;
|
||||
discontinueProduct(product: Product): void;
|
||||
getAdVertCost(): number;
|
||||
applyAdVert(corporation: ICorporation): void;
|
||||
|
@ -523,24 +523,6 @@ export class Industry implements IIndustry {
|
||||
expenses = 0;
|
||||
this.calculateProductionFactors();
|
||||
|
||||
//At the start of the export state, set the imports of everything to 0
|
||||
if (this.state === "EXPORT") {
|
||||
for (let i = 0; i < CorporationConstants.Cities.length; ++i) {
|
||||
const city = CorporationConstants.Cities[i];
|
||||
if (!(this.warehouses[city] instanceof Warehouse)) {
|
||||
continue;
|
||||
}
|
||||
const warehouse = this.warehouses[city];
|
||||
if (warehouse === 0) continue;
|
||||
for (const matName of Object.keys(warehouse.materials)) {
|
||||
if (warehouse.materials.hasOwnProperty(matName)) {
|
||||
const mat = warehouse.materials[matName];
|
||||
mat.imp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < CorporationConstants.Cities.length; ++i) {
|
||||
const city = CorporationConstants.Cities[i];
|
||||
const office = this.offices[city];
|
||||
@ -1236,6 +1218,26 @@ export class Industry implements IIndustry {
|
||||
return totalProfit;
|
||||
}
|
||||
|
||||
resetImports(state: string): void {
|
||||
//At the start of the export state, set the imports of everything to 0
|
||||
if (state === "EXPORT") {
|
||||
for (let i = 0; i < CorporationConstants.Cities.length; ++i) {
|
||||
const city = CorporationConstants.Cities[i];
|
||||
if (!(this.warehouses[city] instanceof Warehouse)) {
|
||||
continue;
|
||||
}
|
||||
const warehouse = this.warehouses[city];
|
||||
if (warehouse === 0) continue;
|
||||
for (const matName of Object.keys(warehouse.materials)) {
|
||||
if (warehouse.materials.hasOwnProperty(matName)) {
|
||||
const mat = warehouse.materials[matName];
|
||||
mat.imp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
discontinueProduct(product: Product): void {
|
||||
for (const productName of Object.keys(this.products)) {
|
||||
if (this.products.hasOwnProperty(productName)) {
|
||||
|
@ -110,7 +110,7 @@ export function IssueNewSharesModal(props: IProps): React.ReactElement {
|
||||
You can issue new equity shares (i.e. stocks) in order to raise capital for your corporation.
|
||||
<br />
|
||||
<br />
|
||||
* You can issue at most {numeralWrapper.formatMoney(maxNewShares)} new shares
|
||||
* You can issue at most {numeralWrapper.format(maxNewShares, "0.000a")} new shares
|
||||
<br />
|
||||
* New shares are sold at a 10% discount
|
||||
<br />
|
||||
|
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -7140,7 +7140,7 @@ interface CorporationInfo {
|
||||
numShares: number;
|
||||
/** Cooldown until shares can be sold again */
|
||||
shareSaleCooldown: number;
|
||||
/** Amount of shares issued */
|
||||
/** Amount of aqcuirable shares. */
|
||||
issuedShares: number;
|
||||
/** Price of the shares */
|
||||
sharePrice: number;
|
||||
|
@ -125,7 +125,9 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE
|
||||
paragraph={false}
|
||||
onClick={() => terminal.connectToServer(player, item.hostname)}
|
||||
>
|
||||
<Typography sx={{ textDecoration: 'underline', "&:hover": { textDecoration: 'none'} }}>{item.hostname}</Typography>
|
||||
<Typography sx={{ textDecoration: "underline", "&:hover": { textDecoration: "none" } }}>
|
||||
{item.hostname}
|
||||
</Typography>
|
||||
</MuiLink>
|
||||
</>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user