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