Widget:YieldCalc: Difference between revisions
No edit summary |
No edit summary |
||
Line 21: | Line 21: | ||
<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"> | ||
Line 31: | Line 32: | ||
// Yield Calculator | // Yield Calculator | ||
function yieldScript(){ | function yieldScript(){ | ||
let A = Number(document.getElementById('cityProd').value); / | let A = Number(document.getElementById('cityProd').value); // City Production | ||
let B = Number(document.getElementById('regionYield').value); / | let B = Number(document.getElementById('regionYield').value); / Yield(Apples) of the region | ||
let C = Number(document.getElementById('farmCount').value); / | let C = Number(document.getElementById('farmCount').value); // Amount of Farms in the region | ||
let E = Number(document.getElementById('percBonus').value); / | let E = Number(document.getElementById('percBonus').value); // Total Percentage Bonus (e.g. 50% from a Plow) | ||
let F = Number(document.getElementById('verseBonus').value); / | let F = Number(document.getElementById('verseBonus').value); // Extra farm adjacency from religious verse (Boolean) | ||
let H = C + F; / | let H = C + F; // Add F to the actual amount of farms in the region | ||
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 Y = Z / 25; // Resulting food yield of that production of a single farm | |||
); | let O = (Z*C)/25; // Resulting food yield of that production of the entire region | ||
document.getElementById('outputvalue').innerText= Y ; | |||
document.getElementById('outputvalueall').innerText= O ; | |||
} | } | ||
</script> | </script> | ||
</includeonly> | </includeonly> |
Revision as of 01:27, 25 October 2024
This widget is used to display and calculate the yield with the values submitted by the user.
Usage: {{#Widget:YieldCalc}}