Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function OpCalculator(homes, homesNeeded, warDamage) {
  2.   // warDamage is 0.5, 1 or 1.5 depending on the war's duration (50%, 100%, 150% war damage)
  3.   var opDamage = 0.01 * warDamage;
  4.   var totalHomesDestroyed = 0;
  5.   var totalOps = 0;
  6.   var homesDestroyed = 0;
  7.  
  8.   while(totalHomesDestroyed < homesNeeded) {
  9.     homesDestroyed= Math.floor(homes * opDamage);
  10.     homes -= homesDestroyed;
  11.     totalHomesDestroyed += homesDestroyed;
  12.     totalOps += 1;
  13.   }
  14.   return totalOps;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement