Advertisement
AdiaLandfall

Satisfactory Calc

Jul 14th, 2020
1,430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const MATS = {
  2.     ORE_IRON: "iron ores",
  3.     ORE_COPPER: "copper ores",
  4.     ORE_STONE: "stone ores",
  5.  
  6.     INGOT_IRON: "iron ingot",
  7.     INGOT_COPPER: "copper ingot",
  8.     INGOT_STEEL: "steel ingot",
  9.     CONCRETE: "Concrete",
  10.  
  11.     PLATE: "Iron plate",
  12.     ROD: "rod",
  13.     SCREW: "screw",
  14.     TOUGH_PLATE: "Reinforced Iron Plate",
  15.  
  16.     WIRE: "Wire",
  17.     CABLE: "Cable",
  18.     QUICK_WIRE: "Quickwire",
  19.     COPPER_SHEET: "Copper Sheet",
  20.  
  21.     CUBE: "Modular Frame",
  22.     STEEL_BEAM: "Steel Beam",
  23.     STEEL_PIPE: "Steel Beam",
  24.     ROTOR: "Rotor",
  25.     STATOR: "Stator",
  26.     MOTOR: "Motor",
  27.  
  28.     PLASTIC: "Plastic",
  29.     RUBBER: "Rubber",
  30.  
  31.     SMART_PLATES: "Smart Plating",
  32.     AUTO_WIRES: "Automated Wiring",
  33.     BOARD: "Circuit Board",
  34.     FAT_CUBE: "Heavy Modular Frame",
  35.     CONCRETE_BEAM: "Encased Industrial Beam",
  36.     CPU: "Computer",
  37.  
  38.     VERS_FRAMES: "Versatile Framework",
  39.     MOD_ENGINE: "Modular Engine",
  40.     ACU: "Adaptive Control Unit",
  41. }
  42.  
  43. const PLANS = {
  44.  
  45.     "iron ingot": [MATS.ORE_IRON, 1],
  46.     "rod": [MATS.INGOT_IRON, 15],
  47.     "screw": [MATS.ROD, 40],
  48.     "Iron plate": [MATS.INGOT_IRON, 3],
  49.  
  50.     "Modular Frame": [
  51.         MATS.TOUGH_PLATE, 3,
  52.         MATS.ROD, 12,
  53.     ],
  54.     "Reinforced Iron Plate": [
  55.         MATS.PLATE, 6,
  56.         MATS.SCREW, 12,
  57.     ],
  58.  
  59.     "Smart Plating": [
  60.         MATS.TOUGH_PLATE, 1,
  61.         MATS.ROTOR, 1,
  62.     ],
  63.     "Automated Wiring": [
  64.         MATS.STATOR, 1,
  65.         MATS.CABLE, 20,
  66.     ],
  67.     "Circuit Board": [
  68.         MATS.COPPER_SHEET, 2,
  69.         MATS.PLASTIC, 4,
  70.     ],
  71.  
  72.     "Heavy Modular Frame": [
  73.         MATS.CUBE, 5,
  74.         MATS.STEEL_PIPE, 15,
  75.         MATS.CONCRETE_BEAM, 5,
  76.         MATS.SCREW, 100,
  77.     ],
  78.     "Encased Industrial Beam": [
  79.         MATS.STEEL_BEAM, 4,
  80.         MATS.CONCRETE, 5,
  81.     ],
  82.     "Computer": [
  83.         MATS.BOARD, 10,
  84.         MATS.CABLE, 9,
  85.         MATS.PLASTIC, 18,
  86.         MATS.SCREW, 52,
  87.     ],
  88.  
  89.     "Versatile Framework": [
  90.         MATS.CUBE, 1,
  91.         MATS.STEEL_BEAM, 12,
  92.     ],
  93.     "Modular Engine": [
  94.         MATS.MOTOR, 2,
  95.         MATS.RUBBER, 15,
  96.         MATS.SMART_PLATES, 2,
  97.     ],
  98.     "Adaptive Control Unit": [
  99.         MATS.AUTO_WIRES, 15,
  100.         MATS.BOARD, 10,
  101.         MATS.FAT_CUBE, 2,
  102.         MATS.CPU, 2,
  103.     ],
  104. }
  105.  
  106. function loadResult(){
  107.     const resultEle = document.getElementById("result");
  108.     const requestEle = document.getElementById("request");
  109.  
  110.     // 2500 vers frames,
  111.     // 500 mod engines
  112.     // 100 adaptive control units
  113.     const request = [
  114.         MATS.VERS_FRAMES, 2500,
  115.         MATS.MOD_ENGINE, 500,
  116.         MATS.ACU, 100,
  117.     ];
  118.    
  119.     const mats = getMatsFor(request);
  120.     requestEle.innerHTML = request;
  121.  
  122.     for(let i=0; i<mats.length; i+=2){
  123.         let oneLi = document.createElement('li');
  124.         oneLi.innerHTML = mats[i] +" x" +mats[i+1];
  125.         resultEle.appendChild(oneLi);
  126.     }
  127. }
  128.  
  129. function getMatsFor(req){
  130.     //debugger;
  131.     if( !req ) return null;
  132.     if( !Array.isArray(req) ) return null;
  133.  
  134.     /*
  135.     if( Array.isArray(req[0]) ){
  136.         const tray = [];
  137.         req.forEach(function(oneReq){
  138.             const oneResult = getMatsFor(oneReq);
  139.             tray.push(oneResult);
  140.         });
  141.         return tray;
  142.     } */
  143.  
  144.     const type = req[0];
  145.     const count = req[1];
  146.  
  147.     const tray = [];
  148.  
  149.     tray.push(type, count);
  150.  
  151.     const deeperReqs = getMatsFor(PLANS[type]);
  152.     //debugger;
  153.  
  154.     if(!!deeperReqs){
  155.         const toAdd = deeperReqs.map((x, i) => {
  156.             if(i%2==0) tray.push(x);
  157.             else tray.push(x*count);
  158.         });
  159.     }
  160.  
  161.     return tray;
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement