Fixed a problem with noted item pricing in shops

This commit is contained in:
ceikry 2021-07-17 14:55:59 -05:00
parent bff9af71b2
commit 05e8ff76b0

View file

@ -604,6 +604,7 @@ public class Shop {
*/ */
public int getSellingValue(Item item, Player player) { public int getSellingValue(Item item, Player player) {
if (!item.getDefinition().isUnnoted()) { if (!item.getDefinition().isUnnoted()) {
player.setAttribute("shop:originalId",item.getId());
item = new Item(item.getNoteChange(), item.getAmount()); item = new Item(item.getNoteChange(), item.getAmount());
} }
int amount = getContainer(1).getAmount(item); int amount = getContainer(1).getAmount(item);
@ -622,8 +623,10 @@ public class Shop {
* @return the selling value. * @return the selling value.
*/ */
private int getSellValue(Player player, int amount, Item item) { private int getSellValue(Player player, int amount, Item item) {
if(item.getAmount() > ContentAPI.amountInInventory(player, item.getId())){ int id = player.getAttribute("shop:originalId",item.getId());
item.setAmount(ContentAPI.amountInInventory(player, item.getId())); if(item.getAmount() > ContentAPI.amountInInventory(player, id)){
item.setAmount(ContentAPI.amountInInventory(player, id));
player.removeAttribute("shop:originalId");
} }
double diff = item.getDefinition().isStackable() ? 0.005 : 0.05; double diff = item.getDefinition().isStackable() ? 0.005 : 0.05;
double maxMod = 1.0 - (amount * diff); double maxMod = 1.0 - (amount * diff);
@ -635,6 +638,7 @@ public class Shop {
minMod = 0.25; minMod = 0.25;
} }
double mod = (maxMod + minMod) / 2; double mod = (maxMod + minMod) / 2;
SystemLogger.logInfo("" + item.getDefinition().getAlchemyValue(highAlch) + " " + mod + " " + item.getAmount());
int value = (int) (item.getDefinition().getAlchemyValue(highAlch) * mod * item.getAmount()); int value = (int) (item.getDefinition().getAlchemyValue(highAlch) * mod * item.getAmount());
if(item.getId() == 12183){ if(item.getId() == 12183){
value = 25 * item.getAmount(); value = 25 * item.getAmount();