Ejemplo n.º 1
0
        public void EncodeItems(COutPacket p)
        {
            var nCount = (byte)Inventory.GetAll().Count;

            p.Encode1(nCount);

            if (nCount <= 0)
            {
                p.Encode1(0);
                return;
            }

            foreach (var item in Inventory.GetAll())
            {
                var bundles = 1;

                if (item.Item is GW_ItemSlotBundle isb)
                {
                    bundles = item.NumberOfBundles; // there is some sort of extra handling here but f**k that rn
                }

                p.Encode2(item.NumberOfBundles);
                p.Encode2(item.ItemsInBundle);
                p.Encode4(item.Price);
                item.Item.RawEncode(p);
            }
        }
Ejemplo n.º 2
0
        public static bool HasSpace(Character pChar, TempInventory tempInv)
        {
            var map = new Dictionary <InventoryType, int>();

            foreach (var item in tempInv.GetAll())
            {
                if (map.ContainsKey(item.Type))
                {
                    map[item.Type]++;
                }
                else
                {
                    map.Add(item.Type, 1);
                }
            }

            return(HasSpace(pChar, map));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Transfer items from a temp inventory to a character inventory.
        /// No validation is done to see if the items will fit.
        /// At the end of this method the temp inventory is cleared.
        /// </summary>
        /// <param name="pChar">Character to transfer items to.</param>
        /// <param name="pTempInv">Inventory to transfer items from.</param>
        /// <param name="bSubtractFee">If the money being transferred should have the trade fee deducted.</param>
        private void TransferItems(Character pChar, TempInventory pTempInv, bool bSubtractFee)
        {
            foreach (var item in pTempInv.GetAll())
            {
                InventoryManipulator.InsertInto(pChar, item.Item);
            }

            if (pTempInv.Meso > 0)
            {
                if (bSubtractFee)
                {
                    pTempInv.Meso -= Fee((int)pTempInv.Meso);
                }

                pChar?.Modify.GainMeso((int)pTempInv.Meso);
            }

            pTempInv.Clear();
        }