This commit is contained in:
Olivier Gagnon 2021-11-11 20:31:26 -05:00
parent d91d7c564e
commit 6e74716940
3 changed files with 20 additions and 19 deletions

@ -1294,9 +1294,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
// Return player's money // Return player's money
workerScript.log( workerScript.log(
"getServerMoneyAvailable", "getServerMoneyAvailable",
`returned player's money: ${numeralWrapper.formatMoney(Player.money.toNumber())}`, `returned player's money: ${numeralWrapper.formatMoney(Player.money)}`,
); );
return Player.money.toNumber(); return Player.money;
} }
workerScript.log( workerScript.log(
"getServerMoneyAvailable", "getServerMoneyAvailable",
@ -1522,7 +1522,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return ""; return "";
} }
if (Player.money.lt(cost)) { if (Player.money < cost) {
workerScript.log( workerScript.log(
"purchaseServer", "purchaseServer",
`Not enough money to purchase server. Need ${numeralWrapper.formatMoney(cost)}`, `Not enough money to purchase server. Need ${numeralWrapper.formatMoney(cost)}`,
@ -2126,7 +2126,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
company_rep_mult: Player.company_rep_mult, company_rep_mult: Player.company_rep_mult,
faction_rep_mult: Player.faction_rep_mult, faction_rep_mult: Player.faction_rep_mult,
numPeopleKilled: Player.numPeopleKilled, numPeopleKilled: Player.numPeopleKilled,
money: Player.money.toNumber(), money: Player.money,
city: Player.city, city: Player.city,
location: Player.location, location: Player.location,
companyName: Player.companyName, companyName: Player.companyName,

@ -18,12 +18,13 @@ export function hasTorRouter(this: IPlayer): boolean {
export function getCurrentServer(this: IPlayer): BaseServer { export function getCurrentServer(this: IPlayer): BaseServer {
const server = GetServer(this.currentServer); 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; return server;
} }
export function getHomeComputer(this: IPlayer): Server { export function getHomeComputer(this: IPlayer): Server {
const home = GetServer("home"); const home = GetServer("home");
console.log(home);
if (home instanceof Server) return home; if (home instanceof Server) return home;
throw new Error("home computer was not a normal server"); throw new Error("home computer was not a normal server");
} }

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