Exemple #1
0
 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.");
     }
 }
Exemple #2
0
 public void SellEquipment(Equipment e)
 {
     cash += (int)Math.Round(e.Price * 0.75, MidpointRounding.ToEven);
     UnEquipEquipment(e);
 }
Exemple #3
0
 public bool CanAffordEquipment(Equipment e)
 {
     return (cash >= e.Price);
 }
Exemple #4
0
 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);
     }
 }
Exemple #5
0
 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();
     }
 }
Exemple #6
0
        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;
        }