Widget:YieldCalc: Difference between revisions

From Ara: History Untold Wiki
No edit summary
No edit summary
 
(30 intermediate revisions by the same user not shown)
Line 7: Line 7:
<style>
<style>
input[type='number']{
input[type='number']{
     width: 63px;
     width: 40px;
}  
}  
#foodYieldForm {
#foodYieldForm {
     width: 80px;
     width: 700px;
}
}
</style>
</style>
<form id="foodYieldForm">
<form id="foodYieldForm">
   <input type="number" id="cityProd"><br />
   <input type="number" id="cityProd"> - City Production<br />
   <input type="number" id="regionYield"><br />
   <input type="number" id="regionYield"> - Yield(Apples) of the region<br />
   <input type="number" id="farmCount"><br />
   <input type="number" id="farmCount"> - Amount of Farms in the region<br />
   <input type="number" id="percBonus"><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"><br />
   <input type="checkbox" id="verseBonus" onClick="yieldScript()"> - Religious Verse active?<br />
   <input type="submit" value="Calculate" onClick="yieldScript()">   
   <input type="submit" value="Calculate" onClick="yieldScript()">   
</form>
</form>
1 Farm:    <span id="outputvalue">0</span><br />
All Farms: <span id="outputvalue">0</span>
<script type="text/javascript">
<script type="text/javascript">
// Prevent Submit button from reloading page
// Prevent Submit button from reloading page
Line 33: Line 30:
function yieldScript(){   
function yieldScript(){   
   let A = Number(document.getElementById('cityProd').value); // City Production
   let A = Number(document.getElementById('cityProd').value); // City Production
   let B = Number(document.getElementById('regionYield').value); / Yield(Apples) of the region
   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 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 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 = Number(document.getElementById('verseBonus').value); // 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 = Number(Math.floor(A*B+B*5*C+5+(A+5*C)*(E/100)+(C-1)*5+A)); // Resulting production of a single farm
  let H = C + G; // Add G to the actual amount of farms in the region
   let Y = Z / 25; // Resulting food yield of that production of a single farm
   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 O = Z * C / 25; // Resulting food yield of that production of the entire region
   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


   document.getElementById('outputvalue').innerText= Y ;
   document.getElementById('outputvalue').innerText= Y;
   document.getElementById('outputvalueall').innerText= O ;
   document.getElementById('outputvalueall').innerText= O;
}
}


</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}}