public void PurchaseEquipment(Equipment e) { if (CanAffordEquipment(e) && CanEquipEquipment(e)) { cash -= e.Price; EquipEquipment(e); } else { throw new Exception("Player tried to purchase unaffordable or unwearable Equipment."); } }
public void SellEquipment(Equipment e) { cash += (int)Math.Round(e.Price * 0.75, MidpointRounding.ToEven); UnEquipEquipment(e); }
public bool CanAffordEquipment(Equipment e) { return (cash >= e.Price); }
public void UnEquipEquipment(Equipment equipment) { this.characterEquipment.Remove(equipment); foreach (var s in equipment.Slots) { this.slots.Find(sf => !sf.SlotFree && sf.SlotType == s.SlotType).SetSlotFree(true, null); } }
public void EquipEquipment(Equipment equipment) { if (CanEquipEquipment(equipment)) { this.characterEquipment.Add(equipment); foreach (var s in equipment.Slots) { this.slots.Find(sf => sf.SlotFree && sf.SlotType == s.SlotType).SetSlotFree(false, equipment.Name); } } else { throw new Exception(); } }
public bool CanEquipEquipment(Equipment equipment) { var uniqueSlots = equipment.Slots.Distinct(); foreach (var e in uniqueSlots) { if (slots.Count(i => i.SlotFree && i.SlotType == e.SlotType) < equipment.Slots.Select(x => x.SlotType == e.SlotType).Count()) { return false; } } return true; }