Added find-target & other updates

This commit is contained in:
2022-03-19 13:55:27 -04:00
parent 436a9f278e
commit 88ff84c082
6 changed files with 157 additions and 63 deletions

View File

@ -1,3 +1,20 @@
/**
* Scan the entire network for the best device to hack.
* @param ns {NS} - BitBurner API
* @returns {string[]} - Sorted list of targets to hack based on financial return
*/
export function bestTarget(ns) {
const [devices, network] = scanNetwork(ns, 'home');
return devices.map(d => ns.getServer(d)).filter(d => d.hasAdminRights).map(d => ({
...d,
moneyAMinute: (ns.hackAnalyze(d.hostname) * ns.getServerMaxMoney(d.hostname)) * ((60 / (ns.getHackTime(d.hostname) / 1000)) * ns.hackAnalyzeChance(d.hostname))}
)).sort((a, b) => {
if(a.moneyAMinute < b.moneyAMinute) return 1;
if(a.moneyAMinute > b.moneyAMinute) return -1;
return 0;
});
}
/**
* Copy a file & scan it for dependencies copying them as well.
* @param ns {NS} - BitBurner API