public void SetSellCostOverride(IItemCost cost) { if (cost == null) { RemoveSellCostOverride(); } else if (cost.CapitalResource?.Quantity >= 0) { SetSellCostOverride(cost.CapitalResource.Type, cost.CapitalResource.Quantity); } else if (cost.GameCurrency?.Quantity >= 0) { SetSellCostOverride(cost.GameCurrency.Type, cost.GameCurrency.Quantity); } else { throw new ArgumentException("Invalid Cost ", nameof(cost)); } }
public ItemCostXml(IItemCost cost) { CapitalResource = cost?.CapitalResource?.Quantity >= 0 ? new ItemCostCapitalResourceXml(cost.CapitalResource.Type, cost.CapitalResource.Quantity) : null; GameCurrency = cost?.GameCurrency?.Quantity >= 0 ? new ItemCostGameCurrencyXml(cost.GameCurrency.Type, cost.GameCurrency.Quantity) : null; if (CapitalResource == null && GameCurrency == null) { throw new ArgumentOutOfRangeException(); } if (CapitalResource != null && GameCurrency != null) { throw new ArgumentOutOfRangeException(); } }