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