mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 13:45:44 +01:00
remove unused eventEmitterForUiReset
This commit is contained in:
parent
97961d6896
commit
0f15431b5f
@ -34,7 +34,7 @@ export function placeOrder(
|
||||
price: number,
|
||||
type: OrderTypes,
|
||||
position: PositionTypes,
|
||||
ctx: NetscriptContext | null = null,
|
||||
ctx?: NetscriptContext,
|
||||
): boolean {
|
||||
if (!(stock instanceof Stock)) {
|
||||
if (ctx) {
|
||||
@ -87,9 +87,7 @@ export interface ICancelOrderParams {
|
||||
type?: OrderTypes;
|
||||
}
|
||||
export function cancelOrder(params: ICancelOrderParams, ctx?: NetscriptContext): boolean {
|
||||
if (StockMarket["Orders"] == null) {
|
||||
return false;
|
||||
}
|
||||
if (StockMarket["Orders"] == null) return false;
|
||||
if (params.order && params.order instanceof Order) {
|
||||
const order = params.order;
|
||||
// An 'Order' object is passed in
|
||||
@ -121,15 +119,11 @@ export function cancelOrder(params: ICancelOrderParams, ctx?: NetscriptContext):
|
||||
params.pos === order.pos
|
||||
) {
|
||||
stockOrders.splice(i, 1);
|
||||
if (ctx) {
|
||||
helpers.log(ctx, () => "Successfully cancelled order: " + orderTxt);
|
||||
}
|
||||
if (ctx) helpers.log(ctx, () => "Successfully cancelled order: " + orderTxt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (ctx) {
|
||||
helpers.log(ctx, () => "Failed to cancel order: " + orderTxt);
|
||||
}
|
||||
if (ctx) helpers.log(ctx, () => "Failed to cancel order: " + orderTxt);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@ -143,9 +137,7 @@ export function loadStockMarket(saveString: string): void {
|
||||
storedCycles: 0,
|
||||
ticksUntilCycle: 0,
|
||||
} as IStockMarket;
|
||||
} else {
|
||||
StockMarket = JSON.parse(saveString, Reviver);
|
||||
}
|
||||
} else StockMarket = JSON.parse(saveString, Reviver);
|
||||
}
|
||||
|
||||
export function deleteStockMarket(): void {
|
||||
@ -159,9 +151,7 @@ export function deleteStockMarket(): void {
|
||||
|
||||
export function initStockMarket(): void {
|
||||
for (const stk of Object.keys(StockMarket)) {
|
||||
if (StockMarket.hasOwnProperty(stk)) {
|
||||
delete StockMarket[stk];
|
||||
}
|
||||
if (StockMarket.hasOwnProperty(stk)) delete StockMarket[stk];
|
||||
}
|
||||
|
||||
for (const metadata of InitStockMetadata) {
|
||||
@ -172,9 +162,7 @@ export function initStockMarket(): void {
|
||||
const orders: IOrderBook = {};
|
||||
for (const name of Object.keys(StockMarket)) {
|
||||
const stock = StockMarket[name];
|
||||
if (!(stock instanceof Stock)) {
|
||||
continue;
|
||||
}
|
||||
if (!(stock instanceof Stock)) continue;
|
||||
orders[stock.symbol] = [];
|
||||
}
|
||||
StockMarket["Orders"] = orders;
|
||||
@ -201,9 +189,7 @@ export function initSymbolToStockMap(): void {
|
||||
function stockMarketCycle(): void {
|
||||
for (const name of Object.keys(StockMarket)) {
|
||||
const stock = StockMarket[name];
|
||||
if (!(stock instanceof Stock)) {
|
||||
continue;
|
||||
}
|
||||
if (!(stock instanceof Stock)) continue;
|
||||
|
||||
const roll = Math.random();
|
||||
if (roll < 0.45) {
|
||||
@ -231,9 +217,7 @@ export function processStockPrices(numCycles = 1): void {
|
||||
// We can process the update every 4 seconds as long as there are enough
|
||||
// stored cycles. This lets us account for offline time
|
||||
const timeNow = new Date().getTime();
|
||||
if (timeNow - StockMarket.lastUpdate < 4e3) {
|
||||
return;
|
||||
}
|
||||
if (timeNow - StockMarket.lastUpdate < 4e3) return;
|
||||
|
||||
StockMarket.lastUpdate = timeNow;
|
||||
StockMarket.storedCycles -= cyclesPerStockUpdate;
|
||||
@ -243,16 +227,12 @@ export function processStockPrices(numCycles = 1): void {
|
||||
StockMarket.ticksUntilCycle = TicksPerCycle;
|
||||
}
|
||||
--StockMarket.ticksUntilCycle;
|
||||
if (StockMarket.ticksUntilCycle <= 0) {
|
||||
stockMarketCycle();
|
||||
}
|
||||
if (StockMarket.ticksUntilCycle <= 0) stockMarketCycle();
|
||||
|
||||
const v = Math.random();
|
||||
for (const name of Object.keys(StockMarket)) {
|
||||
const stock = StockMarket[name];
|
||||
if (!(stock instanceof Stock)) {
|
||||
continue;
|
||||
}
|
||||
if (!(stock instanceof Stock)) continue;
|
||||
let av = (v * stock.mv) / 100;
|
||||
if (isNaN(av)) {
|
||||
av = 0.02;
|
||||
@ -311,5 +291,3 @@ export function initStockMarketFn(): void {
|
||||
initStockMarket();
|
||||
initSymbolToStockMap();
|
||||
}
|
||||
|
||||
export const eventEmitterForUiReset = new EventEmitter<[]>();
|
||||
|
@ -9,10 +9,8 @@ import { StockTickers } from "./StockTickers";
|
||||
import { IStockMarket } from "../IStockMarket";
|
||||
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { EventEmitter } from "../../utils/EventEmitter";
|
||||
|
||||
type IProps = {
|
||||
eventEmitterForReset?: EventEmitter<[]>;
|
||||
initStockMarket: () => void;
|
||||
p: IPlayer;
|
||||
stockMarket: IStockMarket;
|
||||
@ -32,7 +30,7 @@ export function StockMarketRoot(props: IProps): React.ReactElement {
|
||||
<>
|
||||
<InfoAndPurchases initStockMarket={props.initStockMarket} p={props.p} rerender={rerender} />
|
||||
{props.p.hasWseAccount && (
|
||||
<StockTickers eventEmitterForReset={props.eventEmitterForReset} p={props.p} stockMarket={props.stockMarket} />
|
||||
<StockTickers p={props.p} stockMarket={props.stockMarket} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
@ -12,10 +12,8 @@ import { IStockMarket } from "../IStockMarket";
|
||||
import { Stock } from "../Stock";
|
||||
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { EventEmitter } from "../../utils/EventEmitter";
|
||||
|
||||
type IProps = {
|
||||
eventEmitterForReset?: EventEmitter<[]>;
|
||||
p: IPlayer;
|
||||
stockMarket: IStockMarket;
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ import { prestigeAugmentation } from "../Prestige";
|
||||
import { dialogBoxCreate } from "./React/DialogBox";
|
||||
import { GetAllServers } from "../Server/AllServers";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import { eventEmitterForUiReset, initStockMarketFn, StockMarket } from "../StockMarket/StockMarket";
|
||||
import { initStockMarketFn, StockMarket } from "../StockMarket/StockMarket";
|
||||
|
||||
import { Theme } from "@mui/material/styles";
|
||||
import makeStyles from "@mui/styles/makeStyles";
|
||||
@ -437,7 +437,6 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
|
||||
case Page.StockMarket: {
|
||||
mainPage = (
|
||||
<StockMarketRoot
|
||||
eventEmitterForReset={eventEmitterForUiReset}
|
||||
initStockMarket={initStockMarketFn}
|
||||
p={player}
|
||||
stockMarket={StockMarket}
|
||||
|
Loading…
Reference in New Issue
Block a user