示例#1
0
 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);
        }
示例#3
0
        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);
        }
示例#5
0
        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);
        }
示例#7
0
 public Gear GetGear(string gear)
 {
     return(GearCollection.FirstOrDefault(n => n.GearID == gear));
 }
示例#8
0
 public List <Gear> GetAllGears()
 {
     return(GearCollection.ToList());
 }
 public Gear GetGear(string code)
 {
     CurrentEntity = GearCollection.FirstOrDefault(n => n.Code == code);
     return(CurrentEntity);
 }
示例#10
0
 public List <Gear> GetAllGears()
 {
     return(GearCollection.OrderBy(t => t.Name).ToList());
 }