Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OpCalculator(homes, homesNeeded, warDamage) {
- // warDamage is 0.5, 1 or 1.5 depending on the war's duration (50%, 100%, 150% war damage)
- var opDamage = 0.01 * warDamage;
- var totalHomesDestroyed = 0;
- var totalOps = 0;
- var homesDestroyed = 0;
- while(totalHomesDestroyed < homesNeeded) {
- homesDestroyed= Math.floor(homes * opDamage);
- homes -= homesDestroyed;
- totalHomesDestroyed += homesDestroyed;
- totalOps += 1;
- }
- return totalOps;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement