Verified:

Celphi Game profile

Member
EE Patron
6349

Feb 1st 2019, 5:59:06


(function(){

function calcDefense(countryInfo){

let countryNum = countryInfo.countryNum;
let govt = countryInfo.yourGovtType;
let weapTech = countryInfo.yourWeapTech;
let attackType = countryInfo.attackType;

const advisorLeft = document.querySelectorAll("#spyop_" + Number(countryNum) + " .softct")[0];
const advisorRight = document.querySelectorAll("#spyop_" + Number(countryNum) + " .softct")[1];
const militaryForces = advisorRight.querySelectorAll(".advisor")[1];
const yourWeapTech = weapTech / 100;
const attackTypeBonus = (attackType === "PS") ? 1.5 : 1;
const govtBonus = {
'I': 1.25,
'R': .9,
}[govt] || 1;

const troops = Number(militaryForces
.querySelector("tr:nth-child(3) td:last-child")
.innerHTML.replace(",", ""));

const turrets = Number(militaryForces
.querySelector("tr:nth-child(5) td:last-child")
.innerHTML.replace(",", ""));

const tanks = Number(militaryForces
.querySelector("tr:nth-child(6) td:last-child")
.innerHTML.replace(",", ""));

const technology = advisorLeft.querySelectorAll(".advisor")[2];
const enemyWeapTech = Number(technology
.querySelector("tr:nth-child(9) td:last-child")
.innerHTML.replace(/[.,%]/g, '')) / 1000;

const totalDefense = (((((troops * .5) + (turrets) + (tanks * 2)) * 1.1 * enemyWeapTech) / yourWeapTech) / govtBonus) / attackTypeBonus;

return totalDefense;
}


const countryInfo = {

countryNum: 72, // country number saved on spy center
yourGovtType: 'T', // use first letter of govt type
yourWeapTech: 100, // enter number as percentage, decimal not included
attackType: "PS" // SS or PS

};

console.log(calcDefense(countryInfo));

})();



So I was bored and decided to type this up.
Use this on your spy ops page and it will auto calc what you need to send. Only modify the numbers inside of countryInfo object.
Resistance is futile. You will be assimilated.

AnimalP0P Game profile

Member
102

Feb 1st 2019, 6:06:10

I am even lazier. I mental math and round up each type of unit. I almost never take gov. Type into account and just glance at mil tech.