From 6e71258a5345e3f8750c84ead6597e3796d2fef2 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Fri, 26 Nov 2021 18:43:50 -0500 Subject: [PATCH] fix disable log for tix api --- src/NetscriptFunctions/StockMarket.ts | 15 +++++++++------ src/StockMarket/BuyingAndSelling.tsx | 26 +++++++++++++------------- src/StockMarket/StockMarket.tsx | 4 ++-- src/index.html | 6 ------ src/index.tsx | 7 +++++++ 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/NetscriptFunctions/StockMarket.ts b/src/NetscriptFunctions/StockMarket.ts index a57dc03d9..030afe661 100644 --- a/src/NetscriptFunctions/StockMarket.ts +++ b/src/NetscriptFunctions/StockMarket.ts @@ -315,18 +315,18 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript checkTixApiAccess("purchase4SMarketData"); if (player.has4SData) { - workerScript.log("purchase4SMarketData", () => "Already purchased 4S Market Data."); + workerScript.log("stock.purchase4SMarketData", () => "Already purchased 4S Market Data."); return true; } if (player.money < getStockMarket4SDataCost()) { - workerScript.log("purchase4SMarketData", () => "Not enough money to purchase 4S Market Data."); + workerScript.log("stock.purchase4SMarketData", () => "Not enough money to purchase 4S Market Data."); return false; } player.has4SData = true; player.loseMoney(getStockMarket4SDataCost(), "stock"); - workerScript.log("purchase4SMarketData", () => "Purchased 4S Market Data"); + workerScript.log("stock.purchase4SMarketData", () => "Purchased 4S Market Data"); return true; }, purchase4SMarketDataTixApi: function () { @@ -334,18 +334,21 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript checkTixApiAccess("purchase4SMarketDataTixApi"); if (player.has4SDataTixApi) { - workerScript.log("purchase4SMarketDataTixApi", () => "Already purchased 4S Market Data TIX API"); + workerScript.log("stock.purchase4SMarketDataTixApi", () => "Already purchased 4S Market Data TIX API"); return true; } if (player.money < getStockMarket4STixApiCost()) { - workerScript.log("purchase4SMarketDataTixApi", () => "Not enough money to purchase 4S Market Data TIX API"); + workerScript.log( + "stock.purchase4SMarketDataTixApi", + () => "Not enough money to purchase 4S Market Data TIX API", + ); return false; } player.has4SDataTixApi = true; player.loseMoney(getStockMarket4STixApiCost(), "stock"); - workerScript.log("purchase4SMarketDataTixApi", () => "Purchased 4S Market Data TIX API"); + workerScript.log("stock.purchase4SMarketDataTixApi", () => "Purchased 4S Market Data TIX API"); return true; }, }; diff --git a/src/StockMarket/BuyingAndSelling.tsx b/src/StockMarket/BuyingAndSelling.tsx index 9ce482f9d..c4b754e11 100644 --- a/src/StockMarket/BuyingAndSelling.tsx +++ b/src/StockMarket/BuyingAndSelling.tsx @@ -51,7 +51,7 @@ export function buyStock( } if (stock == null || isNaN(shares)) { if (workerScript) { - workerScript.log("buyStock", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); + workerScript.log("stock.buy", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); } else if (opts.suppressDialog !== true) { dialogBoxCreate("Failed to buy stock. This may be a bug, contact developer"); } @@ -67,7 +67,7 @@ export function buyStock( if (Player.money < totalPrice) { if (workerScript) { workerScript.log( - "buyStock", + "stock.buy", () => `You do not have enough money to purchase this position. You need ${numeralWrapper.formatMoney(totalPrice)}.`, ); @@ -86,7 +86,7 @@ export function buyStock( if (shares + stock.playerShares + stock.playerShortShares > stock.maxShares) { if (workerScript) { workerScript.log( - "buyStock", + "stock.buy", () => `Purchasing '${shares + stock.playerShares + stock.playerShortShares}' shares would exceed ${ stock.symbol @@ -118,7 +118,7 @@ export function buyStock( `Bought ${numeralWrapper.formatShares(shares)} shares of ${stock.symbol} for ${numeralWrapper.formatMoney( totalPrice, )}. ` + `Paid ${numeralWrapper.formatMoney(CONSTANTS.StockMarketCommission)} in commission fees.`; - workerScript.log("buyStock", () => resultTxt); + workerScript.log("stock.buy", () => resultTxt); } else if (opts.suppressDialog !== true) { dialogBoxCreate( <> @@ -148,7 +148,7 @@ export function sellStock( // Sanitize/Validate arguments if (stock == null || shares < 0 || isNaN(shares)) { if (workerScript) { - workerScript.log("sellStock", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); + workerScript.log("stock.sell", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); } else if (opts.suppressDialog !== true) { dialogBoxCreate( "Failed to sell stock. This is probably due to an invalid quantity. Otherwise, this may be a bug, contact developer", @@ -194,7 +194,7 @@ export function sellStock( const resultTxt = `Sold ${numeralWrapper.formatShares(shares)} shares of ${stock.symbol}. ` + `After commissions, you gained a total of ${numeralWrapper.formatMoney(gains)}.`; - workerScript.log("sellStock", () => resultTxt); + workerScript.log("stock.sell", () => resultTxt); } else if (opts.suppressDialog !== true) { dialogBoxCreate( <> @@ -228,7 +228,7 @@ export function shortStock( } if (stock == null || isNaN(shares)) { if (workerScript) { - workerScript.log("shortStock", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); + workerScript.log("stock.short", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); } else if (opts.suppressDialog !== true) { dialogBoxCreate( "Failed to initiate a short position in a stock. This is probably " + @@ -246,7 +246,7 @@ export function shortStock( if (Player.money < totalPrice) { if (workerScript) { workerScript.log( - "shortStock", + "stock.short", () => "You do not have enough " + "money to purchase this short position. You need " + @@ -267,7 +267,7 @@ export function shortStock( if (shares + stock.playerShares + stock.playerShortShares > stock.maxShares) { if (workerScript) { workerScript.log( - "shortStock", + "stock.short", () => `This '${shares + stock.playerShares + stock.playerShortShares}' short shares would exceed ${ stock.symbol @@ -300,7 +300,7 @@ export function shortStock( CONSTANTS.StockMarketCommission, )} ` + `in commission fees.`; - workerScript.log("shortStock", () => resultTxt); + workerScript.log("stock.short", () => resultTxt); } else if (!opts.suppressDialog) { dialogBoxCreate( <> @@ -329,7 +329,7 @@ export function sellShort( ): boolean { if (stock == null || isNaN(shares) || shares < 0) { if (workerScript) { - workerScript.log("sellShort", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); + workerScript.log("stock.sellShort", () => `Invalid arguments: stock='${stock}' shares='${shares}'`); } else if (!opts.suppressDialog) { dialogBoxCreate( "Failed to sell a short position in a stock. This is probably " + @@ -352,7 +352,7 @@ export function sellShort( if (totalGain == null || isNaN(totalGain) || origCost == null) { if (workerScript) { workerScript.log( - "sellShort", + "stock.sellShort", () => `Failed to sell short position in a stock. This is probably either due to invalid arguments, or a bug`, ); } else if (!opts.suppressDialog) { @@ -387,7 +387,7 @@ export function sellShort( const resultTxt = `Sold your short position of ${numeralWrapper.formatShares(shares)} shares of ${stock.symbol}. ` + `After commissions, you gained a total of ${numeralWrapper.formatMoney(totalGain)}`; - workerScript.log("sellShort", () => resultTxt); + workerScript.log("stock.sellShort", () => resultTxt); } else if (!opts.suppressDialog) { dialogBoxCreate( <> diff --git a/src/StockMarket/StockMarket.tsx b/src/StockMarket/StockMarket.tsx index 5debf153e..46c7cbf20 100644 --- a/src/StockMarket/StockMarket.tsx +++ b/src/StockMarket/StockMarket.tsx @@ -37,7 +37,7 @@ export function placeOrder( ): boolean { if (!(stock instanceof Stock)) { if (workerScript) { - workerScript.log("placeOrder", () => `Invalid stock: '${stock}'`); + workerScript.log("stock.placeOrder", () => `Invalid stock: '${stock}'`); } else { dialogBoxCreate(`ERROR: Invalid stock passed to placeOrder() function`); } @@ -45,7 +45,7 @@ export function placeOrder( } if (typeof shares !== "number" || typeof price !== "number") { if (workerScript) { - workerScript.log("placeOrder", () => `Invalid arguments: shares='${shares}' price='${price}'`); + workerScript.log("stock.placeOrder", () => `Invalid arguments: shares='${shares}' price='${price}'`); } else { dialogBoxCreate("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument"); } diff --git a/src/index.html b/src/index.html index 11aa78f33..40e049867 100644 --- a/src/index.html +++ b/src/index.html @@ -13,12 +13,6 @@ -