public Inventory(Player p) { this.p = p; for (int i = 0; i < slots.Length; i++) { slots[i] = new Item(-1, 0); } }
public bool tradeItem(int slot, int amount) { int itemId = player.getInventory().getItemInSlot(slot); bool stackable = ItemData.forId(itemId).isStackable(); int tradeSlot = findItem(itemId); if (amount <= 0 || itemId == -1 || status > 2) { return false; } if (ItemData.forId(itemId).isPlayerBound()) { player.getPackets().sendMessage("You cannot trade that item."); return false; } if (!stackable) { tradeSlot = findFreeSlot(); if (tradeSlot == -1) { player.getPackets().sendMessage("An error occured whilst trying to find free a trade slot."); return false; } if (amount > player.getInventory().getItemAmount(itemId)) { amount = player.getInventory().getItemAmount(itemId); } for (int i = 0; i < amount; i++) { tradeSlot = findFreeSlot(); if (!player.getInventory().deleteItem(itemId) || tradeSlot == -1) { break; } items[tradeSlot] = new Item(itemId, 1); } if (status == 2 || player2.getTrade().getStatus() == 2) { this.status = 1; player2.getTrade().setStatus(1); player.getPackets().modifyText("", 335, 36); player2.getPackets().modifyText("", 335, 36); } refreshTrade(); return true; } else if (stackable) { tradeSlot = findItem(itemId); if (tradeSlot == -1) { tradeSlot = findFreeSlot(); if (tradeSlot == -1) { player.getPackets().sendMessage("An error occured whilst trying to find free a trade slot."); return false; } } if (amount > player.getInventory().getAmountInSlot(slot)) { amount = player.getInventory().getAmountInSlot(slot); } if (player.getInventory().deleteItem(itemId, amount)) { if (items[tradeSlot] == null) { items[tradeSlot] = new Item(itemId, amount); } else { if (items[tradeSlot].getItemId() == itemId) { items[tradeSlot].setItemId(itemId); items[tradeSlot].setItemAmount(items[tradeSlot].getItemAmount() + amount); } } if (status == 2 || player2.getTrade().getStatus() == 2) { this.status = 1; player2.getTrade().setStatus(1); player.getPackets().modifyText("", 335, 36); player2.getPackets().modifyText("", 335, 36); } refreshTrade(); return true; } } return false; }
public void setLoanItem(Item loanItem) { this.loanItem = loanItem; }
public void setStock(Item[] stock) { this.stock = stock; }
public void setSlot(int slot, Item item) { this.stock[slot] = item; }
public void setSlot2(Item slot2) { this.slot2 = slot2; }
public void setSlot1(Item slot1) { this.slot1 = slot1; }