JSFiddle - React, Tailwind, and code Playground
HTML
<h1>
Unspoiled Yield Calculator
</h1>
<form>
<div>
<input id="gpEl" type="number" min="500" max="1000" value="750"/>
<label>GP</label>
</div>
<div>
<input id="chanceEl" type="number" min="50" max="100" value="95"/>
<label>% gather chance</label>
</div>
<div>
<input id="hitsEl" type="number" min="4" max="8" value="5"/>
<label>hits</label>
</div>
<div>
<input id="pickEl" type="number" min="1" max="2" value="2"/>
<label>Pick Clean yield bonus</label>
</div>
<div>
<input id="bhEl" type="number" min="1" max="3" value="2"/>
<label>Bountiful Harvest II yield bonus</label>
</div>
</form>
<div>
<h2>Result</h2>
<p id="output"></p>
</div>
CSS
body {
font-family: sans-serif;
color: #48f;
background-color: #20262e;
padding-left: 30px;
}
label {
color: #ccc;
}
input {
width: 4em;
background-color: black;
border-style: none;
color: #ccc;
padding: 5px;
margin: 3px;
}
b {
color: #6af;
}
h2 {
margin-top: 30px;
}
JavaScript
[gpEl, chanceEl, hitsEl, pickEl, bhEl].forEach(el => el.addEventListener('change', run));
const STRATEGIES = [
['Bountiful', [false, false]],
['Pick clean + bountiful whenever you have =<100gp', [false, true]],
['Blessed Harvest/Kings Yield 2 + bountiful whenever you have =<100gp', [true, false]],
['Blessed Harvest/Kings Yield 2 + pick clean + bountiful when you get 100gp', [true, true]],
];
function simulate(hits, gp, pick, bh, useBlessed, usePickClean) {
let y = 0;
let perHit = 1;
if (useBlessed && gp >= 500) {
gp -= 500;
perHit += 2;
}
if (usePickClean && gp >= 250) {
gp -= 250;
perHit += pick;
}
while (hits--) {
if (gp >= 100) {
gp -= 100;
y += bh;
}
y += perHit;
gp += 6;
}
return y;
}
function run() {
const [GP, chance, hits, pick, bh] = [gpEl, chanceEl, hitsEl, pickEl, bhEl].map(el => parseInt(el.value, 10));
let gp = GP;
if (chance < 85) {
// Field Mastery III
gp -= 250;
} else if (chance < 95) {
// Field Mastery II
gp -= 100;
} else if (chance < 100) {
// Field Mastery I
gp -= 50;
}
let max = -Infinity;
let winningStrategy = null;
for (const [strategy, args] of STRATEGIES) {
const y = simulate(hits, gp, pick, bh, ...args);
if (y > max) {
winningStrategy = strategy;
max = y;
}
}
output.innerHTML = `The maximum yield is <b>${max}</b>, your strategy: <b>${winningStrategy}</b>`;
}
run();