treasure = {
const loot = [
{ type: "Loot", level: 0, cost: 132, value: 3 },
{ type: "Loot", level: 6, cost: 820, value: 4 },
{ type: "Loot", level: 17, cost: 1743, value: 5 },
{ type: "Loot", level: 28, cost: 2882, value: 6 },
{ type: "Loot", level: 39, cost: 4231, value: 7 },
{ type: "Loot", level: 50, value: 8 }
];
function process(list) {
for (let i = 0; i < list.length - 1; ++i) {
const it = list[i];
it.next = list[i + 1];
it.label = `${it.type} ${it.level}`;
it.benefit = list[i + 1].value / it.value;
it.cost_benefit = it.benefit / it.cost;
}
const last = list[list.length - 1];
last.cost_benefit = 0;
}
const attack = _.times(101, (x) => ({
type: "Attack",
level: x,
cost: _.round(0.06 * x ** 2 + 3 * x + 6.212),
value: _.round(1 + 0.1 * x, 2)
}));
const haste = _.times(21, (x) => ({
type: "Haste",
level: x,
cost: _.round(0.01 * x ** 2 + 6 * x + 16),
value: _.round(1 + 0.05 * x, 2)
}));
process(loot);
process(attack);
process(haste);
const combined_ah = _(attack)
.concat(haste)
.filter("next")
.sortBy("cost_benefit")
.reverse()
.value();
const combined_all = _(combined_ah)
.concat(loot)
.filter("next")
.sortBy("cost_benefit")
.reverse()
.value();
const start_state = { time: 0, income: loot[0].value };
return { loot, attack, haste, combined_ah, combined_all, start_state };
}