Example #1
0
    public void AddGem(string name, long value)
    {
        if (Capacity + value <= MaxCapacity && GetGoldAmount() >= GetGemsAmount() + value)
        {
            if (!Gems.Any(g => g.Name == name))
            {
                Gems.Add(new Gem(name));
            }

            var current = Gems.FirstOrDefault(g => g.Name == name);
            current.Value += value;
            Capacity      += value;
        }
    }
Example #2
0
        public void AddGem(string name, long quantity)
        {
            if (IsEnoughSpace(quantity) && Gold >= Gems.Sum(g => g.Quantity) + quantity)
            {
                Gem gem = Gems.FirstOrDefault(g => g.Name == name);
                if (gem == null)
                {
                    gem = new Gem(name);
                    Gems.Add(gem);
                }

                gem.Quantity += quantity;
            }
        }
Example #3
0
 public IReadOnlyList <Gem> GetGemsInSlot(ItemSlot slot) =>
 Gems.FirstOrDefault(gs => gs.First().ItemSlot == slot) ?? Array.Empty <Gem>();