The3vilM0nk3y

augCheck.js

May 14th, 2022
1,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import * as helpers from "/apis/helpers.js";
  2. let earlyList = ["Netburners", "Tian Di Hui", "CyberSec"];
  3. let cityList = ["Aevum", "Chongqing", "Ishima", "New Tokyo", "Sector-12", "Volhaven"];
  4. let criminalList = ["Speakers for the Dead", "The Dark Army", "The Syndicate", "Silhouette", "Tetrads", "Slum Snakes"];
  5. let hackingList = ["BitRunners", "The Black Hand", "NiteSec"];
  6. let corporationList = ["ECorp", "MegaCorp", "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated", "OmniTek Incorporated", "Four Sigma", "KuaiGong International", "Fulcrum Secret Technologies"];
  7. let endgameList = ["Illuminati", "Daedalus", "The Covenant"];
  8. let specialList = ["Bladeburners", "Church of the Machine God"];
  9.  
  10.  
  11. /** @param {NS} ns */
  12. export async function main(ns) {
  13.     let owned = ns.singularity.getOwnedAugmentations(true);
  14.     let fullList = [];
  15.     fullList.push(...earlyList, ...cityList, ...criminalList, ...hackingList, ...corporationList, ...endgameList, ...specialList);
  16.     let argList = [];
  17.     argList.push("Active", "Early", "City", "Criminal", "Hacking", "Corporation", "EndGame", "Special", "All", ...fullList)
  18.     if (!argList.includes(ns.args[0])) {
  19.         ns.tprint("Valid options are - ", argList);
  20.         return;
  21.     }
  22.     let data = [[ "Augmentation", "Faction(s)","Money", "Rep"]];
  23.     switch (ns.args[0]) {
  24.         case "Early":
  25.             for (let faction of earlyList) {
  26.                 data.push(...getAugData(ns, faction, owned));
  27.             }
  28.             break;
  29.         case "City":
  30.             for (let faction of cityList) {
  31.                 data.push(...getAugData(ns, faction, owned));
  32.             }
  33.             break;
  34.         case "Criminal":
  35.             for (let faction of criminalList) {
  36.                 data.push(...getAugData(ns, faction, owned));
  37.             }
  38.             break;
  39.         case "Hacking":
  40.             for (let faction of hackingList) {
  41.                 data.push(...getAugData(ns, faction, owned));
  42.             }
  43.             break;
  44.         case "Corporation":
  45.             for (let faction of corporationList) {
  46.                 data.push(...getAugData(ns, faction, owned));
  47.             }
  48.             break;
  49.         case "EndGame":
  50.             for (let faction of endgameList) {
  51.                 data.push(...getAugData(ns, faction, owned));
  52.             }
  53.             break;
  54.         case "Special":
  55.             for (let faction of specialList) {
  56.                 data.push(...getAugData(ns, faction, owned));
  57.             }
  58.             break;
  59.         case "All":
  60.             for (let faction of fullList) {
  61.                 data.push(...getAugData(ns, faction, owned));
  62.             }
  63.             break;
  64.         case "Active":
  65.             for (let faction of ns.getPlayer().factions) {
  66.                 data.push(...getAugData(ns, faction, owned));
  67.             }
  68.             break;
  69.         default:
  70.             data.push(...getAugData(ns, ns.args[0], owned));
  71.             break;
  72.     }
  73.     data = cleanDuplicates(ns, data);
  74.     let sortArray = [[3,1],[2,1]];
  75.     data = await helpers.sortArray(data, sortArray);
  76.     //ns.tprint(data);
  77.     helpers.columnize(ns, data, 2,[["none"], ["none"],["num","(0.00 a)"], ["num","(0.00 a)"]], true);
  78. }
  79. function cleanDuplicates(ns, array){
  80.     let data = [];
  81.     let augs = [];
  82.     for (let i in array){
  83.         let augName = array[i][0];
  84.         //check if its already in the list
  85.         if (!augs.includes(augName)) {
  86.             //if its not in the list, add it in.
  87.             data.push(array[i]);
  88.             augs.push(augName);
  89.         } else {
  90.             //if its already in the list, add the faction to the current entry.
  91.             data[augs.indexOf(augName)][1] += ", " + array[i][1];
  92.         }
  93.     }
  94.     return data;
  95. }
  96. /** @param {NS} ns */
  97. function getAugData(ns, faction, owned) {
  98.     let factionAugs = ns.singularity.getAugmentationsFromFaction(faction);
  99.     let list = [];
  100.     for (let aug of factionAugs) {
  101.         if (!owned.includes(aug)) {
  102.             list.push([aug, faction, ns.singularity.getAugmentationPrice(aug), ns.singularity.getAugmentationRepReq(aug)]);
  103.         }
  104.     }
  105.     return list;
  106. }
  107. export function autocomplete(data, args) {
  108.     let factions = [
  109.         "Early",
  110.         "City",
  111.         "Criminal",
  112.         "Hacking",
  113.         "Corporation",
  114.         "Special",
  115.         "All",
  116.         "Active",
  117.         "Illuminati",
  118.         "Daedalus",
  119.         "The Covenant",
  120.         "ECorp",
  121.         "MegaCorp",
  122.         "Bachman & Associates",
  123.         "Blade Industries",
  124.         "NWO",
  125.         "Clarke Incorporated",
  126.         "OmniTek Incorporated",
  127.         "Four Sigma",
  128.         "KuaiGong International",
  129.         "Fulcrum Secret Technologies",
  130.         "BitRunners",
  131.         "The Black Hand",
  132.         "NiteSec",
  133.         "Aevum",
  134.         "Chongqing",
  135.         "Ishima",
  136.         "New Tokyo",
  137.         "Sector-12",
  138.         "Volhaven",
  139.         "Speakers for the Dead",
  140.         "The Dark Army",
  141.         "The Syndicate",
  142.         "Silhouette",
  143.         "Tetrads",
  144.         "Slum Snakes",
  145.         "Netburners",
  146.         "Tian Di Hui",
  147.         "CyberSec",
  148.         "Bladeburners",
  149.         "Church of the Machine God"]
  150.     return [...factions];
  151. }
Advertisement
Add Comment
Please, Sign In to add comment