Exemplo n.º 1
0
        public ItemInstance addItem(ItemTemplate itemTemplate)
        {
            var slot = -1;

            if (itemTemplate.isTrinket())
            {
                if (items[6] == null)
                {
                    items[6] = new ItemInstance(itemTemplate, 6, 1);
                    return items[6];
                }
                return null;
            }

            if (itemTemplate.getMaxStack() > 1)
            {
                for (slot = 0; slot < 6; ++slot)
                {
                    if (items[slot] == null)
                        continue;

                    if (items[slot].getTemplate() == itemTemplate)
                    {
                        if (items[slot].getStacks() < itemTemplate.getMaxStack())
                        {
                            items[slot].incrementStacks();
                            return items[slot];
                        }
                        else if (items[slot].getStacks() == itemTemplate.getMaxStack())
                        {
                            return null;
                        }
                    }
                }
            }

            for (slot = 0; slot < 6; ++slot)
            {
                if (items[slot] == null)
                    break;
            }

            if (slot == 6)
            { // Inventory full
                return null;
            }

            Logger.LogCoreInfo("Adding item " + itemTemplate.getId() + " to slot " + slot);
            items[slot] = new ItemInstance(itemTemplate, (byte)slot, 1);

            return items[slot];
        }
Exemplo n.º 2
0
 public BuyItemAns(Champion actor, ItemInstance item) : base(PacketCmdS2C.PKT_S2C_BuyItemAns, actor.getNetId())
 {
     buffer.Write((int)item.getTemplate().getId());
     buffer.Write((byte)item.getSlot());
     buffer.Write((byte)item.getStacks());
     buffer.Write((byte)0); //unk or stacks => short
     buffer.Write((byte)0x40); //unk
 }
Exemplo n.º 3
0
 public static void notifyItemBought(Champion c, ItemInstance i)
 {
     var response = new BuyItemAns(c, i);
     PacketHandlerManager.getInstace().broadcastPacketVision(c, response, Channel.CHL_S2C);
 }