fix Stock Initializer (#137)

* stock symbols initializer is called by stockmarket initializer
* remove redundant second initStockMarketFn function
This commit is contained in:
Snarling 2022-10-20 00:38:19 -04:00 committed by GitHub
parent 1d0d4f8da6
commit 19e8946d9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 10 deletions

@ -1,6 +1,6 @@
import { Player as player } from "../Player";
import { buyStock, sellStock, shortStock, sellShort } from "../StockMarket/BuyingAndSelling";
import { StockMarket, SymbolToStockMap, placeOrder, cancelOrder, initStockMarketFn } from "../StockMarket/StockMarket";
import { StockMarket, SymbolToStockMap, placeOrder, cancelOrder, initStockMarket } from "../StockMarket/StockMarket";
import { getBuyTransactionCost, getSellTransactionGain } from "../StockMarket/StockMarketHelpers";
import { OrderTypes } from "../StockMarket/data/OrderTypes";
import { PositionTypes } from "../StockMarket/data/PositionTypes";
@ -382,7 +382,7 @@ export function NetscriptStockMarket(): InternalAPI<TIX> {
}
player.hasWseAccount = true;
initStockMarketFn();
initStockMarket();
player.loseMoney(getStockMarketWseCost(), "stock");
helpers.log(ctx, () => "Purchased WSE Account Access");
return true;

@ -19,7 +19,7 @@ import { LiteratureNames } from "./Literature/data/LiteratureNames";
import { GetServer, AddToAllServers, initForeignServers, prestigeAllServers } from "./Server/AllServers";
import { prestigeHomeComputer } from "./Server/ServerHelpers";
import { SpecialServers } from "./Server/data/SpecialServers";
import { deleteStockMarket, initStockMarket, initSymbolToStockMap } from "./StockMarket/StockMarket";
import { deleteStockMarket, initStockMarket } from "./StockMarket/StockMarket";
import { Terminal } from "./Terminal";
import { dialogBoxCreate } from "./ui/React/DialogBox";
@ -142,7 +142,6 @@ export function prestigeAugmentation(): void {
// Reset Stock market
if (Player.hasWseAccount) {
initStockMarket();
initSymbolToStockMap();
}
// Red Pill
@ -278,7 +277,6 @@ export function prestigeSourceFile(flume: boolean): void {
// Reset Stock market, gang, and corporation
if (Player.hasWseAccount) {
initStockMarket();
initSymbolToStockMap();
} else {
deleteStockMarket();
}

@ -167,6 +167,7 @@ export function initStockMarket(): void {
StockMarket.storedCycles = 0;
StockMarket.lastUpdate = 0;
StockMarket.ticksUntilCycle = TicksPerCycle;
initSymbolToStockMap();
}
export function initSymbolToStockMap(): void {
@ -280,8 +281,3 @@ export function processStockPrices(numCycles = 1): void {
stock.shareTxUntilMovement = Math.min(stock.shareTxUntilMovement + 10, stock.shareTxForMovement);
}
}
export function initStockMarketFn(): void {
initStockMarket();
initSymbolToStockMap();
}