Merge pull request #1695 from danielyxie/dev

wtf
This commit is contained in:
hydroflame
2021-11-11 20:46:07 -05:00
committed by GitHub
11 changed files with 36 additions and 21 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,7 @@ export function buyDarkwebItem(itemName: string): void {
}
// return if the player doesn't have enough money
if (Player.money.lt(item.price)) {
if (Player.money < item.price) {
Terminal.error("Not enough money to purchase " + item.program);
return;
}

View File

@ -87,7 +87,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
} else {
dialogBoxCreate(txt);
}
} else if (aug.baseCost !== 0 && Player.money.lt(aug.baseCost * factionInfo.augmentationPriceMult)) {
} else if (aug.baseCost !== 0 && Player.money < aug.baseCost * factionInfo.augmentationPriceMult) {
const txt = "You don't have enough money to purchase " + aug.name;
if (sing) {
return txt;
@ -99,7 +99,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
return txt;
}
dialogBoxCreate(txt);
} else if (aug.baseCost === 0 || Player.money.gte(aug.baseCost * factionInfo.augmentationPriceMult)) {
} else if (aug.baseCost === 0 || Player.money >= aug.baseCost * factionInfo.augmentationPriceMult) {
const queuedAugmentation = new PlayerOwnedAugmentation(aug.name);
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
queuedAugmentation.level = getNextNeurofluxLevel();

View File

@ -63,7 +63,7 @@ export class PlayerObject implements IPlayer {
numPeopleKilled: number;
location: LocationName;
max_hp: number;
money: any;
money: number;
moneySourceA: MoneySourceTracker;
moneySourceB: MoneySourceTracker;
playtimeSinceLastAug: number;

View File

@ -333,7 +333,7 @@ export function gainMoney(this: PlayerObject, money: number, source: string): vo
console.error("NaN passed into Player.gainMoney()");
return;
}
this.money = this.money.plus(money);
this.money = this.money + money;
this.recordMoneySource(money, source);
}
@ -342,8 +342,8 @@ export function loseMoney(this: PlayerObject, money: number, source: string): vo
console.error("NaN passed into Player.loseMoney()");
return;
}
if (this.money.eq(Infinity) && money === Infinity) return;
this.money = this.money.minus(money);
if (this.money === Infinity && money === Infinity) return;
this.money = this.money - money;
this.recordMoneySource(-1 * money, source);
}

View File

@ -18,7 +18,7 @@ export function hasTorRouter(this: IPlayer): boolean {
export function getCurrentServer(this: IPlayer): BaseServer {
const server = GetServer(this.currentServer);
if (server === null) throw new Error("somehow connected to a server that does not exist.");
if (server === null) throw new Error(`somehow connected to a server that does not exist. ${this.currentServer}`);
return server;
}

View File

@ -64,7 +64,7 @@ export function buyStock(
if (totalPrice == null) {
return false;
}
if (Player.money.lt(totalPrice)) {
if (Player.money < totalPrice) {
if (workerScript) {
workerScript.log(
"buyStock",
@ -241,7 +241,7 @@ export function shortStock(
if (totalPrice == null) {
return false;
}
if (Player.money.lt(totalPrice)) {
if (Player.money < totalPrice) {
if (workerScript) {
workerScript.log(
"shortStock",

View File

@ -1 +0,0 @@
declare module "decimal.js";

View File

@ -251,6 +251,22 @@ const Engine: {
const timeOffline = Engine._lastUpdate - lastUpdate;
const numCyclesOffline = Math.floor(timeOffline / CONSTANTS._idleSpeed);
// Generate coding contracts
// let numContracts = 0;
// if (numCyclesOffline < 3000 * 100) {
// // if we have less than 100 rolls, just roll them exactly.
// for (let i = 0; i < numCyclesOffline / 3000; i++) {
// if (Math.random() < 0.25) numContracts++;
// }
// } else {
// // just average it.
// numContracts = (numCyclesOffline / 3000) * 0.25;
// }
// console.log(`${numCyclesOffline} ${numContracts}`);
// for (let i = 0; i < numContracts; i++) {
// generateRandomContract();
// }
let offlineReputation = 0;
const offlineHackingIncome = (Player.moneySourceA.hacking / Player.playtimeSinceLastAug) * timeOffline * 0.75;
Player.gainMoney(offlineHackingIncome, "hacking");

View File

@ -856,7 +856,7 @@ describe("Stock Market Tests", function () {
expect(buyStock(stock, shares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShares).equal(shares);
expect(stock.playerAvgPx).greaterThan(0);
expect(Player.money.toNumber()).equal(0);
expect(Player.money).equal(0);
});
});
@ -888,7 +888,7 @@ describe("Stock Market Tests", function () {
expect(sellStock(stock, shares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShares).equal(0);
expect(stock.playerAvgPx).equal(0);
expect(Player.money.toNumber()).equal(gain);
expect(Player.money).equal(gain);
});
it("should cap the number of sharse sold to however many the player owns", function () {
@ -902,7 +902,7 @@ describe("Stock Market Tests", function () {
expect(sellStock(stock, attemptedShares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShares).equal(0);
expect(stock.playerAvgPx).equal(0);
expect(Player.money.toNumber()).equal(gain);
expect(Player.money).equal(gain);
});
it("should properly update stock properties for partial transactions", function () {
@ -916,7 +916,7 @@ describe("Stock Market Tests", function () {
expect(sellStock(stock, shares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShares).equal(shares);
expect(stock.playerAvgPx).equal(origPrice);
expect(Player.money.toNumber()).equal(gain);
expect(Player.money).equal(gain);
});
});
@ -950,7 +950,7 @@ describe("Stock Market Tests", function () {
expect(shortStock(stock, shares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShortShares).equal(shares);
expect(stock.playerAvgShortPx).greaterThan(0);
expect(Player.money.toNumber()).equal(0);
expect(Player.money).equal(0);
});
});
@ -982,7 +982,7 @@ describe("Stock Market Tests", function () {
expect(sellShort(stock, shares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShortShares).equal(0);
expect(stock.playerAvgShortPx).equal(0);
expect(Player.money.toNumber()).equal(gain);
expect(Player.money).equal(gain);
});
it("should cap the number of sharse sold to however many the player owns", function () {
@ -996,7 +996,7 @@ describe("Stock Market Tests", function () {
expect(sellShort(stock, attemptedShares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShortShares).equal(0);
expect(stock.playerAvgShortPx).equal(0);
expect(Player.money.toNumber()).equal(gain);
expect(Player.money).equal(gain);
});
it("should properly update stock properties for partial transactions", function () {
@ -1010,7 +1010,7 @@ describe("Stock Market Tests", function () {
expect(sellShort(stock, shares, null, suppressDialogOpt)).equal(true);
expect(stock.playerShortShares).equal(shares);
expect(stock.playerAvgShortPx).equal(origPrice);
expect(Player.money.toNumber()).equal(gain);
expect(Player.money).equal(gain);
});
});
});