Exemple #1
0
        public bool Draggable => ItemIndex != 0 && Amount != 0; // TODO: cursed?

        public int Add(ItemSlot item, int maxAmount = 99)
        {
            int amountToAdd = Math.Min(item.Amount, maxAmount);

            if (item.ItemIndex == ItemIndex)
            {
                if (Amount + amountToAdd > 99)
                {
                    item.Amount = Amount + amountToAdd - 99;
                    Amount      = 99;
                    return(item.Amount);
                }
                else
                {
                    Amount      += amountToAdd;
                    item.Amount -= amountToAdd;
                    return(item.Amount);
                }
            }
            else if (!Empty)
            {
                return(item.Amount);
            }
            else
            {
                ItemIndex           = item.ItemIndex;
                Amount              = amountToAdd;
                Flags               = item.Flags;
                NumRemainingCharges = item.NumRemainingCharges;
                RechargeTimes       = item.RechargeTimes;
                item.Amount        -= amountToAdd;
                return(item.Amount);
            }
        }
Exemple #2
0
 public void Clear()
 {
     ItemIndex           = 0;
     Amount              = 0;
     Flags               = ItemSlotFlags.None;
     NumRemainingCharges = 0;
     RechargeTimes       = 0;
 }
Exemple #3
0
 public void Replace(ItemSlot item)
 {
     ItemIndex           = item.ItemIndex;
     Amount              = item.Amount;
     Flags               = item.Flags;
     NumRemainingCharges = item.NumRemainingCharges;
     RechargeTimes       = item.RechargeTimes;
 }
Exemple #4
0
        public void ReadMerchant(Merchant merchant, IDataReader dataReader)
        {
            for (int y = 0; y < 4; ++y)
            {
                for (int x = 0; x < 6; ++x)
                {
                    int amount = dataReader.ReadByte();
                    dataReader.ReadBytes(2); // Unknown
                    ItemSlotFlags flags     = (ItemSlotFlags)dataReader.ReadByte();
                    uint          itemIndex = dataReader.ReadWord();

                    merchant.Slots[x, y] = new ItemSlot
                    {
                        ItemIndex = itemIndex,
                        Amount    = amount,
                        Flags     = flags
                    };
                }
            }
        }
Exemple #5
0
        public void Exchange(ItemSlot item)
        {
            var itemIndex           = ItemIndex;
            var amount              = Amount;
            var flags               = Flags;
            var numRemainingCharges = NumRemainingCharges;
            var rechargeTimes       = RechargeTimes;

            ItemIndex           = item.ItemIndex;
            Amount              = item.Amount;
            Flags               = item.Flags;
            NumRemainingCharges = item.NumRemainingCharges;
            RechargeTimes       = item.RechargeTimes;

            item.ItemIndex           = itemIndex;
            item.Amount              = amount;
            item.Flags               = flags;
            item.NumRemainingCharges = numRemainingCharges;
            item.RechargeTimes       = rechargeTimes;
        }
Exemple #6
0
        public void ReadChest(Chest chest, IDataReader dataReader)
        {
            for (int y = 0; y < 4; ++y)
            {
                for (int x = 0; x < 6; ++x)
                {
                    int amount = dataReader.ReadByte();
                    dataReader.ReadBytes(2); // Unknown
                    ItemSlotFlags flags     = (ItemSlotFlags)dataReader.ReadByte();
                    uint          itemIndex = dataReader.ReadWord();

                    chest.Slots[x, y] = new ItemSlot
                    {
                        ItemIndex = itemIndex,
                        Amount    = amount,
                        Flags     = flags
                    };
                }
            }

            chest.Gold = dataReader.ReadWord();
            chest.Food = dataReader.ReadWord();
        }