From 909e5e964f23e93f07316c50dfd06f9a63d44186 Mon Sep 17 00:00:00 2001 From: phyzical Date: Sun, 10 Apr 2022 18:19:45 +0800 Subject: [PATCH] add call to missing stock market init when using the api --- src/NetscriptFunctions/StockMarket.ts | 3 ++- src/StockMarket/StockMarket.tsx | 2 +- src/ui/GameRoot.tsx | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/NetscriptFunctions/StockMarket.ts b/src/NetscriptFunctions/StockMarket.ts index d2c535b09..353c2c80f 100644 --- a/src/NetscriptFunctions/StockMarket.ts +++ b/src/NetscriptFunctions/StockMarket.ts @@ -3,7 +3,7 @@ import { WorkerScript } from "../Netscript/WorkerScript"; import { IPlayer } from "../PersonObjects/IPlayer"; import { getRamCost } from "../Netscript/RamCostGenerator"; 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 { OrderTypes } from "../StockMarket/data/OrderTypes"; import { PositionTypes } from "../StockMarket/data/PositionTypes"; @@ -411,6 +411,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript } player.hasWseAccount = true; + initStockMarketFn(); player.loseMoney(getStockMarketWseCost(), "stock"); workerScript.log("stock.purchaseWseAccount", () => "Purchased WSE Account Access"); return true; diff --git a/src/StockMarket/StockMarket.tsx b/src/StockMarket/StockMarket.tsx index 119d272b4..7869b9f9d 100644 --- a/src/StockMarket/StockMarket.tsx +++ b/src/StockMarket/StockMarket.tsx @@ -306,7 +306,7 @@ export function processStockPrices(numCycles = 1): void { } } -export function initStockMarketFnForReact(): void { +export function initStockMarketFn(): void { initStockMarket(); initSymbolToStockMap(); } diff --git a/src/ui/GameRoot.tsx b/src/ui/GameRoot.tsx index aec6cf48f..15d5c59f2 100644 --- a/src/ui/GameRoot.tsx +++ b/src/ui/GameRoot.tsx @@ -22,7 +22,7 @@ import { buyStock, sellStock, shortStock, sellShort } from "../StockMarket/Buyin import { cancelOrder, eventEmitterForUiReset, - initStockMarketFnForReact, + initStockMarketFn, placeOrder, StockMarket, } from "../StockMarket/StockMarket"; @@ -445,7 +445,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme buyStockShort={shortStock} cancelOrder={cancelOrder} eventEmitterForReset={eventEmitterForUiReset} - initStockMarket={initStockMarketFnForReact} + initStockMarket={initStockMarketFn} p={player} placeOrder={placeOrder} sellStockLong={sellStock}