Widget:YieldCalc: Difference between revisions

From Ara: History Untold Wiki
No edit summary
Tag: Reverted
No edit summary
 
(128 intermediate revisions by the same user not shown)
Line 5: Line 5:
</noinclude>
</noinclude>
<includeonly>
<includeonly>
 
<style>
<form id="yieldCalc">
input[type='number']{
   <input type="number" id="cityProd" placeholder="62" size="4"><br />
    width: 40px;
   <input type="number" id="regionYield" placeholder="3" size="4"><br />
}
   <input type="number" id="farmCount" placeholder="3" size="4"><br />
#foodYieldForm {
   <input type="number" id="percBonus" placeholder="50" size="4"><br />
    width: 700px;
   <input type="radial" id=""><br />
}
   <button type="submit">Calculate</button>
</style>
<form id="foodYieldForm">
   <input type="number" id="cityProd"> - City Production<br />
   <input type="number" id="regionYield"> - Yield(Apples) of the region<br />
   <input type="number" id="farmCount"> - Amount of Farms in the region<br />
   <input type="number" id="percBonus"> - Total Percentage Bonus (e.g. 50% from a Plow and 150% from an expert adds up to 200%)<br />
   <input type="checkbox" id="verseBonus" onClick="yieldScript()"> - Religious Verse active?<br />
   <input type="submit" value="Calculate" onClick="yieldScript()">
</form>
</form>
<script type="text/javascript">
<script type="text/javascript">
/* Yield Calculator */
// Prevent Submit button from reloading page
let yieldCalc = document.getElementById("yieldCalc");
foodYieldForm.addEventListener("submit", (event) => {
  event.preventDefault();
});


let a = 62; /* City Production */
// Yield Calculator
let b = 6; /* Yield(Apples) of the region */
function yieldScript(){ 
let c = 3; /* Amount of Farms in the region */
  let A = Number(document.getElementById('cityProd').value); // City Production
let e = 250; /* Total Percentage Bonus (e.g. 50% from a Plow) */
  let B = Number(document.getElementById('regionYield').value); // Yield(Apples) of the region
  let C = Number(document.getElementById('farmCount').value); // Amount of Farms in the region
  let E = Number(document.getElementById('percBonus').value); // Total Percentage Bonus (e.g. 50% from a Plow)
  let F = document.getElementById('verseBonus'); // Extra farm adjacency from religious verse


let f = 1; /* Extra farm adjacency from religious verse (Boolean) */
  if (F.checked == true){
let h = c + f; /* Add f to the actual amount of farms in the region */
    var G = 1;
  } else {
    var G = 0;
  }


let z = Math.floor(a*b+b*5*h+5+(a+5*h)*(e/100)+(h-1)*5+a); /* Food yield for a single farm in the region */
  let H = C + G; // Add G to the actual amount of farms in the region
  let Z = Number(Math.floor(A*B+B*5*H+5+(A+5*H)*(E/100)+(H-1)*5+A)); // Resulting production of a single farm
  let Y = Math.round(Z/25); // Resulting food yield of that production of a single farm
  let O = Y*C; // Resulting food yield of that production of the entire region


let y = z x c; /* Food yield multiplied by the amount of farms in the region */
  document.getElementById('outputvalue').innerText= Y;
  document.getElementById('outputvalueall').innerText= O;
}


document.getElementById("foodYield").innerHTML = z;
</script>
</script>
</includeonly>
</includeonly>

Latest revision as of 03:06, 30 October 2024

This widget is used to display and calculate the yield with the values submitted by the user.

Usage: ‎{{#Widget:YieldCalc}}