public void AddRecordToRepo(Gear gear) { if (gear == null) { throw new ArgumentNullException("Error: The argument is Null"); } GearCollection.Add(gear); }
public void Serialize(string fileName) { SerializeGear serialize = new SerializeGear { Gears = GearCollection.ToList() }; serialize.Save(fileName); }
public void DropEquipment(Player player) { GearCollection gears = new GearCollection(); gears.AddGears(); var rnd = new Random(); int maxIndex = gears.Gears.Count; Gear item = gears.Gears[rnd.Next(maxIndex)]; Console.WriteLine($"You have earned {item.Name}. Congratulations!"); if (item.Name.Contains("Sword")) { Weapon newWeapon = (Weapon)item; if (player.Weapon.CompareTo(newWeapon) < 0) { ChangeEquipment(newWeapon, player); } } else if (item.Name.Contains("Cuirass")) { Armor newArmor = (Armor)item; if (player.Armor.CompareTo(newArmor) < 0) { ChangeEquipment(newArmor, player); } } else if (item.Name.Contains("Boots")) { Boots newBoots = (Boots)item; if (player.Boots.CompareTo(newBoots) < 0) { ChangeEquipment(newBoots, player); } } else if (item.Name.Contains("Armguard")) { Armguard newArmguard = (Armguard)item; if (player.Armguard.CompareTo(newArmguard) < 0) { ChangeEquipment(newArmguard, player); } } IncreaseStats(player); }
public bool AddRecordToRepo(Gear gear) { if (gear == null) { throw new ArgumentNullException("Error: The argument is Null"); } GearCollection.Add(gear); return(_editSucceeded); }
public void DeleteRecordFromRepo(string id) { if (id == null) { throw new Exception("Record ID cannot be null"); } int index = 0; while (index < GearCollection.Count) { if (GearCollection[index].GearID == id) { GearCollection.RemoveAt(index); break; } index++; } }
public bool DeleteRecordFromRepo(string code) { if (code == null) { throw new Exception("Record ID cannot be null"); } int index = 0; while (index < GearCollection.Count) { if (GearCollection[index].Code == code) { GearCollection.RemoveAt(index); break; } index++; } return(_editSucceeded); }
public Gear GetGear(string gear) { return(GearCollection.FirstOrDefault(n => n.GearID == gear)); }
public List <Gear> GetAllGears() { return(GearCollection.ToList()); }
public Gear GetGear(string code) { CurrentEntity = GearCollection.FirstOrDefault(n => n.Code == code); return(CurrentEntity); }
public List <Gear> GetAllGears() { return(GearCollection.OrderBy(t => t.Name).ToList()); }