-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbank.js
131 lines (104 loc) · 4.81 KB
/
bank.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { COLORS, pctColor, PrintTable, DefaultStyle, ColorPrint } from 'tables.js'
import { FormatMoney, WaitPids } from 'utils.js'
import { RamBudget, GangBudget } from 'budget.js'
//import { GetSitRep } from 'sitrep.js'
/** @param {NS} ns */
export async function main(ns) {
const money = ns.getMoneySources();
let columns = [
{ header: ' Source', width: 22 },
{ header: ' $ install', width: 11 },
{ header: ' $ overall', width: 11 },
{ header: ' $ budget', width: 11 },
];
let data = [];
let spent= [0, 0];
let gained= [0, 0];
for (const key of Object.keys(money.sinceInstall)) {
const install = money.sinceInstall[key];
const start = money.sinceStart[key];
if (install == 0 && start == 0) continue;
if (key == 'total') continue;
if (install > 0) gained[0] += install;
if (install < 0) spent[0] += install;
if (start > 0) gained[1] += start;
if (start < 0) spent[1] += start;
let budget = '';
if (key == 'servers') {
budget = FormatMoney(ns, RamBudget(ns));
}
if (key == 'gang') {
budget = FormatMoney(ns, GangBudget(ns));
}
data.push([' ' + key, FormatMoney(ns, install, 1).padStart(10), FormatMoney(ns, start, 1).padStart(10), budget.padStart(10)]);
}
data.push(null);
data.push([' Gained', FormatMoney(ns, gained[0], 1).padStart(10), FormatMoney(ns, gained[1], 1).padStart(10), '']);
data.push([' Spent', FormatMoney(ns, spent[0], 1).padStart(10), FormatMoney(ns, spent[1], 1).padStart(10), '']);
data.push(null);
data.push([' Total', FormatMoney(ns, money.sinceInstall['total'], 1).padStart(10), FormatMoney(ns, money.sinceStart['total'], 1).padStart(10), '']);
PrintTable(ns, data, columns, DefaultStyle(), ColorPrint);
// const status = {
// augs: ns.singularity.getOwnedAugmentations(false).length,
// augsNeeded: ns.getBitNodeMultipliers().DaedalusAugsRequirement,
// money: ns.getServerMoneyAvailable('home'),
// level: ns.getHackingLevel()
// }
await WaitPids(ns, ns.run('flightStatus.js'));
const sitrep = JSON.parse(ns.read('sitrep.txt'));
columns = [
{ header: ' Information', width: 20 },
{ header: ' Value', width: 37 }
];
data = [];
data.push([' Time since install', ' ' + ns.tFormat(ns.getTimeSinceLastAug())]);
data.push([' Time since start', ' ' + ns.tFormat(ns.getPlayer().playtimeSinceLastBitnode)]);
data.push([' Karma', ' ' + ns.heart.break().toFixed(0) + ' / ' + '-54000']);
data.push([' Augmentations', ' ' + sitrep.flightStatus.augs.toString() + ' / ' + sitrep.flightStatus.augsNeeded.toString()]);
data.push([' Money', ' ' + FormatMoney(ns, sitrep.flightStatus.money) + ' / ' + FormatMoney(ns, 100_000_000_000)]);
data.push([' Hacking skill', ' ' + ns.getHackingLevel().toString() + ' / ' + '2500']);
data.push([' World daemon', ' ' + ns.getHackingLevel().toString() + ' / ' + (ns.getBitNodeMultipliers().WorldDaemonDifficulty * 3000).toString()]);
PrintTable(ns, data, columns, DefaultStyle(), ColorPrint);
}
// export function GetBank(ns) {
// return JSON.parse(ns.read('bank.txt'));
// }
export function UpdateBankCache(ns) {
//ns.write('bank.txt', JSON.stringify(output), 'w');
// return output;
}
// export function GetTotalWorth(ns) {
// let money = ns.getServerMoneyAvailable('home');
// let stocks = GetStocksValue(ns);
// let total = money + stocks.total;
// ns.tprint('Player money : ' + ns.nFormat(money, '0.000a').padStart(9));
// ns.tprint('Stocks paid : ' + ns.nFormat(stocks.paid, '0.000a').padStart(9));
// ns.tprint('Stocks profit : ' + ns.nFormat(stocks.profit, '0.000a').padStart(9));
// ns.tprint('Stocks total : ' + ns.nFormat(stocks.total, '0.000a').padStart(9));
// ns.tprint('Total money : ' + ns.nFormat(total, '0.000a').padStart(9));
// return total;
// }
// export function GetStocksValue(ns) {
// let total = 0;
// let paid = 0;
// let profit = 0;
// for (const sym of ns.stock.getSymbols()) {
// // Obtain prices and other stock metrics
// let askPrice = ns.stock.getAskPrice(sym);
// let bidPrice = ns.stock.getBidPrice(sym);
// // Get current position on longs and shorts
// const [shares, avgPx, sharesShort, avgPxShort] = ns.stock.getPosition(sym);
// // Short stocks sell for Ask price.
// // Long stocks sell for Bid price.
// let longValue = shares * bidPrice;
// let shortValue = sharesShort * askPrice;
// let longPaid = shares * avgPx;
// let shortPaid = sharesShort * avgPxShort;
// let longProfit = longValue - longPaid;
// let shortProfit = shortPaid - shortValue;
// total += longValue + shortValue;
// paid += longPaid + shortPaid;
// profit += longProfit + shortProfit;
// }
// return { total: total, paid: paid, profit: profit };
// }