Advertisement
PowerCell46

Radio Crystals JS

Dec 8th, 2022
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function radioCrystals(array) {
  2.   let finalThickness = Number(array[0]);
  3.  
  4.   let cutCounter = 0;
  5.   let cutOperation = false;
  6.   let lapCounter = 0;
  7.   let lapOperation = false;
  8.   let grindCounter = 0;
  9.   let grindOperation = false;
  10.   let etchCounter = 0;
  11.   let etchOperation = false;
  12.   let xRayCounter = 0;
  13.   let xRayWasUsed = false;
  14.  
  15.   for (let index = 1; index < Number(array.length); index++) {
  16.     let currentCrystalThickness = Number(array[index]);
  17.     console.log(`Processing chunk ${currentCrystalThickness} microns`);
  18.  
  19.     while (currentCrystalThickness / 4 >= finalThickness) {
  20.       // Cut operation
  21.       currentCrystalThickness = currentCrystalThickness / 4;
  22.       cutCounter++;
  23.       cutOperation = true;
  24.     }
  25.     if (cutOperation === true) {
  26.       console.log(`Cut x${cutCounter}`);
  27.       console.log("Transporting and washing");
  28.       currentCrystalThickness = Math.floor(currentCrystalThickness);
  29.     }
  30.  
  31.     while (
  32.       currentCrystalThickness - ((currentCrystalThickness / 100) * 20) >= finalThickness) {
  33.       // Lap operation
  34.       currentCrystalThickness = currentCrystalThickness - ((currentCrystalThickness / 100) * 20);
  35.       lapCounter++;
  36.       lapOperation = true;
  37.     }
  38.     if (lapOperation === true) {
  39.       console.log(`Lap x${lapCounter}`);
  40.       console.log("Transporting and washing");
  41.       currentCrystalThickness = Math.floor(currentCrystalThickness);
  42.     }
  43.  
  44.     while (currentCrystalThickness - 20 >= finalThickness) {
  45.       // Grind operation
  46.       currentCrystalThickness -= 20;
  47.       grindCounter++;
  48.       grindOperation = true;
  49.     }
  50.     if (grindOperation === true) {
  51.       console.log(`Grind x${grindCounter}`);
  52.       console.log("Transporting and washing");
  53.       currentCrystalThickness = Math.floor(currentCrystalThickness);
  54.     }
  55.  
  56.     while (currentCrystalThickness - 2 >= finalThickness - 1) {
  57.       // Etch operation
  58.       currentCrystalThickness -= 2;
  59.       etchCounter++;
  60.       etchOperation = true;
  61.     }
  62.     if (etchOperation === true) {
  63.       console.log(`Etch x${etchCounter}`);
  64.       console.log("Transporting and washing");
  65.       currentCrystalThickness = Math.floor(currentCrystalThickness);
  66.     }
  67.  
  68.     if (currentCrystalThickness < finalThickness) {
  69.       xRayWasUsed = true;
  70.       xRayCounter++;
  71.     }
  72.     if (xRayWasUsed === true && xRayCounter === 1) {
  73.       // X-ray operation
  74.       currentCrystalThickness++;
  75.       console.log(`X-ray x${xRayCounter}`);
  76.     }
  77.  
  78.     if (currentCrystalThickness === finalThickness) {
  79.       console.log(`Finished crystal ${currentCrystalThickness} microns`);
  80.       cutCounter = 0;
  81.       cutOperation = false;
  82.       lapCounter = 0;
  83.       lapOperation = false;
  84.       grindCounter = 0;
  85.       grindOperation = false;
  86.       etchCounter = 0;
  87.       etchOperation = false;
  88.       xRayCounter = 0;
  89.       xRayWasUsed = false;
  90.     }
  91.   }
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement