public void AddGem(Gem gem) { GemAmount.Add(gem); long gemAmount = gem.Amount; long goldAmount = CalculateCurrentGoldAmount(); if (gemAmount > goldAmount) { GemAmount.Remove(gem); } else if (CalculateCurrentGemAmount() > goldAmount) { GemAmount.Remove(gem); } else if (CalculateTotallAmount() > MaxCapacity) { GemAmount.Remove(gem); } }
public long CalculateCurrentGemAmount() { return(GemAmount.Select(x => x.Amount).Sum()); }