public void AddShieldToInventory(Shield newShield) { Shield currentShield = UserInventory.OfType <Shield>().FirstOrDefault(w => w.Equipped == true); if (currentShield == null) { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"you found a... "); Console.WriteLine(newShield); Console.WriteLine("Its now equiped."); Console.ForegroundColor = ConsoleColor.White; newShield.Equipped = true; BlockRating = newShield.BlockRating; UserInventory.Add(newShield); Armour = newShield.ArmourAmount; } else if (newShield.BlockRating > currentShield.BlockRating) { currentShield.Equipped = false; newShield.Equipped = true; Armour = newShield.ArmourAmount; BlockRating = newShield.BlockRating; UserInventory.Add(newShield); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"you found a... "); Console.WriteLine(newShield); Console.WriteLine("Its now equiped."); Console.ForegroundColor = ConsoleColor.White; } else { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("You found a.."); Console.WriteLine(newShield); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("You current one is better.. you add it to inventory.."); UserInventory.Add(newShield); } Console.ReadKey(); }
public void AddWeaponToInventory(Weapon newWeapon) { Weapon currentWeapon = UserInventory.OfType <Weapon>().FirstOrDefault(w => w.Equipped == true); if (currentWeapon == null) { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"you found a"); Console.WriteLine(newWeapon); Console.WriteLine("Its now equiped."); Console.ForegroundColor = ConsoleColor.White; newWeapon.Equipped = true; UserInventory.Add(newWeapon); SetDmg(newWeapon); } else if (newWeapon.DmgUpperBound > currentWeapon.DmgUpperBound) { currentWeapon.Equipped = false; newWeapon.Equipped = true; SetDmg(newWeapon); UserInventory.Add(newWeapon); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"you found a"); Console.WriteLine(newWeapon); Console.WriteLine("Its now equiped."); Console.ForegroundColor = ConsoleColor.White; } else { Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("You found a.."); Console.WriteLine(newWeapon); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("You current one is better.. you add it to inventory.."); UserInventory.Add(newWeapon); } Console.ReadKey(); }