SHARE
TWEET

Untitled

a guest Sep 28th, 2016 84 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top