예제 #1
0
 public Inventory(Player p)
 {
     this.p = p;
     for (int i = 0; i < slots.Length; i++)
     {
         slots[i] = new Item(-1, 0);
     }
 }
예제 #2
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;
 }
예제 #3
0
 public void setLoanItem(Item loanItem)
 {
     this.loanItem = loanItem;
 }
예제 #4
0
파일: Shop.cs 프로젝트: ramatronics/rsps
 public void setStock(Item[] stock)
 {
     this.stock = stock;
 }
예제 #5
0
파일: Shop.cs 프로젝트: ramatronics/rsps
 public void setSlot(int slot, Item item)
 {
     this.stock[slot] = item;
 }
예제 #6
0
파일: GEItem.cs 프로젝트: ramatronics/rsps
 public void setSlot2(Item slot2)
 {
     this.slot2 = slot2;
 }
예제 #7
0
파일: GEItem.cs 프로젝트: ramatronics/rsps
 public void setSlot1(Item slot1)
 {
     this.slot1 = slot1;
 }