add call to missing stock market init when using the api

This commit is contained in:
phyzical 2022-04-10 18:19:45 +08:00
parent 758b0e1127
commit 909e5e964f
3 changed files with 5 additions and 4 deletions

@ -3,7 +3,7 @@ import { WorkerScript } from "../Netscript/WorkerScript";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { getRamCost } from "../Netscript/RamCostGenerator"; import { getRamCost } from "../Netscript/RamCostGenerator";
import { buyStock, sellStock, shortStock, sellShort } from "../StockMarket/BuyingAndSelling"; import { buyStock, sellStock, shortStock, sellShort } from "../StockMarket/BuyingAndSelling";
import { StockMarket, SymbolToStockMap, placeOrder, cancelOrder } from "../StockMarket/StockMarket"; import { StockMarket, SymbolToStockMap, placeOrder, cancelOrder, initStockMarketFn } from "../StockMarket/StockMarket";
import { getBuyTransactionCost, getSellTransactionGain } from "../StockMarket/StockMarketHelpers"; import { getBuyTransactionCost, getSellTransactionGain } from "../StockMarket/StockMarketHelpers";
import { OrderTypes } from "../StockMarket/data/OrderTypes"; import { OrderTypes } from "../StockMarket/data/OrderTypes";
import { PositionTypes } from "../StockMarket/data/PositionTypes"; import { PositionTypes } from "../StockMarket/data/PositionTypes";
@ -411,6 +411,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
} }
player.hasWseAccount = true; player.hasWseAccount = true;
initStockMarketFn();
player.loseMoney(getStockMarketWseCost(), "stock"); player.loseMoney(getStockMarketWseCost(), "stock");
workerScript.log("stock.purchaseWseAccount", () => "Purchased WSE Account Access"); workerScript.log("stock.purchaseWseAccount", () => "Purchased WSE Account Access");
return true; return true;

@ -306,7 +306,7 @@ export function processStockPrices(numCycles = 1): void {
} }
} }
export function initStockMarketFnForReact(): void { export function initStockMarketFn(): void {
initStockMarket(); initStockMarket();
initSymbolToStockMap(); initSymbolToStockMap();
} }

@ -22,7 +22,7 @@ import { buyStock, sellStock, shortStock, sellShort } from "../StockMarket/Buyin
import { import {
cancelOrder, cancelOrder,
eventEmitterForUiReset, eventEmitterForUiReset,
initStockMarketFnForReact, initStockMarketFn,
placeOrder, placeOrder,
StockMarket, StockMarket,
} from "../StockMarket/StockMarket"; } from "../StockMarket/StockMarket";
@ -445,7 +445,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
buyStockShort={shortStock} buyStockShort={shortStock}
cancelOrder={cancelOrder} cancelOrder={cancelOrder}
eventEmitterForReset={eventEmitterForUiReset} eventEmitterForReset={eventEmitterForUiReset}
initStockMarket={initStockMarketFnForReact} initStockMarket={initStockMarketFn}
p={player} p={player}
placeOrder={placeOrder} placeOrder={placeOrder}
sellStockLong={sellStock} sellStockLong={sellStock}