The current enchantment cost calculation system can be pretty messy. One of the biggest issues was the cost from level to level was not linear. Some of the calculations such as calculating the cost of increasing an enchantment from level 3 to level 5 expect it to be, and perform best when that is the case. There are also more factors that need to be included in the cost, such as treasure enchantments, and curses. While those could be retrofitted into the older method, the new one is much more straight forward. Included in this issue are the new code methods, and a table of the results.
// New
public static int calculateNewEnchCost(Enchantment enchantment, int level) {
// Base cost is equal to roughly 2.5 levels of EXP.
int cost = 25;
// Cost is multiplied up to 10, based on rarity of the enchant.
// Rarer the enchant, higher the cost.
cost *= Math.max(11 - enchantment.getRarity().getWeight(), 1);
// Linear cost increase based on level.
cost *= level;
// The cost factor is applied. Default is 1.5.
// TODO make configurable
cost *= 1.5f;
// Curses cost even more to apply
if (enchantment.isCurse()) {
// TODO make configurable
cost *= 1.5f;
}
// Treasures cost more to apply
if (enchantment.isTreasureEnchantment()) {
// TODO make configurable
cost *= 1.5f;
}
return cost;
}
The current enchantment cost calculation system can be pretty messy. One of the biggest issues was the cost from level to level was not linear. Some of the calculations such as calculating the cost of increasing an enchantment from level 3 to level 5 expect it to be, and perform best when that is the case. There are also more factors that need to be included in the cost, such as treasure enchantments, and curses. While those could be retrofitted into the older method, the new one is much more straight forward. Included in this issue are the new code methods, and a table of the results.
The old method
The new method
Enchantment costs