private static void HandleOpenBox(GameSession session, IReadOnlyCollection <Item> items, int amount)
    {
        int           opened = 0;
        OpenBoxResult result = OpenBoxResult.Success;

        foreach (Item item in items)
        {
            for (int i = opened; i < amount; i++)
            {
                if (item.Amount <= 0)
                {
                    break;
                }

                if (!ItemBoxHelper.GiveItemFromOpenBox(session, item, out result))
                {
                    break;
                }

                opened++;
            }
        }

        session.Send(ItemUsePacket.Use(items.First().Id, opened, result));
    }
Пример #2
0
        private static void HandleOpenBox(GameSession session, Dictionary <long, Item> items, /*OpenItemBox box,*/ int amount)
        {
            int opened = 0;

            foreach (KeyValuePair <long, Item> kvp in items)
            {
                Item item = kvp.Value;

                for (int i = opened; i < amount; i++)
                {
                    if (item.Amount <= 0)
                    {
                        break;
                    }

                    opened++;
                    ItemBoxHelper.GiveItemFromOpenBox(session, item);
                }
            }

            session.Send(ItemUsePacket.Use(items.FirstOrDefault().Value.Id, amount));
        }
Пример #3
0
        private static void HandleOpenItemBox(GameSession session, PacketReader packet, Item item)
        {
            short boxType = packet.ReadShort();

            ItemBoxHelper.GiveItemFromOpenBox(session, item);
        }