mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-06 15:47:52 +02:00
Refactored stock buying/selling code into its own file. Refactored WorkerScript & NetscriptEnvironment into their own Typescript classes. Refactored a ton of code to remove circular dependencies
This commit is contained in:
@@ -22,11 +22,26 @@ export class Order {
|
||||
|
||||
readonly pos: PositionTypes;
|
||||
readonly price: number;
|
||||
readonly shares: number;
|
||||
shares: number;
|
||||
readonly stock: Stock;
|
||||
readonly type: OrderTypes;
|
||||
|
||||
constructor(stk: Stock = new Stock(), shares: number=0, price: number=0, typ: OrderTypes=OrderTypes.LimitBuy, pos: PositionTypes=PositionTypes.Long) {
|
||||
// Validate arguments
|
||||
let invalidArgs: boolean = false;
|
||||
if (typeof shares !== "number" || typeof price !== "number") {
|
||||
invalidArgs = true;
|
||||
}
|
||||
if (isNaN(shares) || isNaN(price)) {
|
||||
invalidArgs = true;
|
||||
}
|
||||
if (!(stk instanceof Stock)) {
|
||||
invalidArgs = true;
|
||||
}
|
||||
if (invalidArgs) {
|
||||
throw new Error(`Invalid constructor paramters for Order`);
|
||||
}
|
||||
|
||||
this.stock = stk;
|
||||
this.shares = shares;
|
||||
this.price = price;
|
||||
|
||||
Reference in New Issue
Block a user