public static void ItemUse(Player player, string noun) { if (noun != "") { if (player.Inventory.Find(x => x.Name == FirstLetterToCap.MakeFirstLetterCap(noun)).Name == noun) { Console.WriteLine($"Do you wish to use {noun}"); if (Console.ReadLine().ToLower() == "yes") { if (player.HP < player.PlayerMaxHP) { player.HP += GameAttributes.PlayerPotionByName(FirstLetterToCap.MakeFirstLetterCap(noun)).HPRecovery; if (player.PlayerMaxHP < player.HP) { player.HP = player.PlayerMaxHP; } } else { Console.WriteLine("You are already at max hp."); } } } else { Console.WriteLine($"You do not have {noun}"); } } else { Console.WriteLine("Please enter an iteme"); } }
public static void EquipmentChange(Player player, string noun) { if (player.Equipment.Name.ToLower() != noun) { if (string.IsNullOrEmpty(noun)) { Console.WriteLine("Please Enter the weapons name!"); } else { InheritItem weapon = player.ItemByName(player, noun); if (noun == weapon.Name.ToLower()) { player.Inventory.Add(new InheritItem(player.Equipment.ID, player.Equipment.Name, player.Equipment.Description, player.Equipment.Price)); player.Equipment = GameAttributes.PlayerWeaponByName(noun); player.RemoveItembyName(player, noun); } else { Console.WriteLine($"{noun} is not in your inventory."); } } } else { Console.WriteLine("You already have this weapon equip!"); } }
public static List <InheritItem> RandomItemsDropped(int itemDrop) { List <InheritItem> newItemList = new List <InheritItem>(); switch (itemDrop) { case 0: newItemList.Add(GameAttributes.PlayerItemByID(RandomNumGenerator.NumberBetween(401, 413))); newItemList.Add(GameAttributes.PlayerPotionByID(RandomNumGenerator.NumberBetween(301, 305))); newItemList.Add(GameAttributes.PlayerWeaponByID(RandomNumGenerator.NumberBetween(201, 220))); return(newItemList); case 1: newItemList.Add(GameAttributes.PlayerItemByID(RandomNumGenerator.NumberBetween(401, 415))); newItemList.Add(GameAttributes.PlayerPotionByID(RandomNumGenerator.NumberBetween(301, 310))); newItemList.Add(GameAttributes.PlayerWeaponByID(RandomNumGenerator.NumberBetween(212, 236))); return(newItemList); case 2: newItemList.Add(GameAttributes.PlayerItemByID(RandomNumGenerator.NumberBetween(401, 416))); newItemList.Add(GameAttributes.PlayerPotionByID(RandomNumGenerator.NumberBetween(305, 310))); newItemList.Add(GameAttributes.PlayerWeaponByID(RandomNumGenerator.NumberBetween(212, 252))); return(newItemList); case 3: newItemList.Add(GameAttributes.PlayerItemByID(RandomNumGenerator.NumberBetween(401, 419))); newItemList.Add(GameAttributes.PlayerPotionByID(RandomNumGenerator.NumberBetween(305, 314))); newItemList.Add(GameAttributes.PlayerWeaponByID(RandomNumGenerator.NumberBetween(231, 252))); return(newItemList); case 4: newItemList.Add(GameAttributes.PlayerItemByID(RandomNumGenerator.NumberBetween(415, 419))); newItemList.Add(GameAttributes.PlayerPotionByID(RandomNumGenerator.NumberBetween(310, 314))); newItemList.Add(GameAttributes.PlayerWeaponByID(RandomNumGenerator.NumberBetween(253, 267))); return(newItemList); case 5: newItemList.Add(GameAttributes.PlayerItemByID(RandomNumGenerator.NumberBetween(415, 419))); newItemList.Add(GameAttributes.PlayerPotionByID(RandomNumGenerator.NumberBetween(315, 319))); newItemList.Add(GameAttributes.PlayerWeaponByID(RandomNumGenerator.NumberBetween(253, 267))); return(newItemList); default: newItemList.Add(GameAttributes.PlayerItemByID(RandomNumGenerator.NumberBetween(415, 419))); newItemList.Add(GameAttributes.PlayerPotionByID(RandomNumGenerator.NumberBetween(320, 325))); newItemList.Add(GameAttributes.PlayerWeaponByID(RandomNumGenerator.NumberBetween(253, 268))); return(newItemList); } }
// Constructor to assign information gathered public Player(string playerName, string password, string playerClass, string race, int playerLevel, int currentRoom, int maxHp, int hp, int ac, int gold, int xp, bool isDead) : base(hp, ac, isDead) { PlayerName = playerName; Password = password; PlayerClass = playerClass; PlayerRace = race; PlayerLevel = playerLevel; CurrentRoom = GameAttributes.RoomByID(currentRoom); PlayerMaxHP = maxHp; HP = hp; AC = ac; Gold = gold; XP = xp; IsDead = isDead; Inventory = new List <InheritItem>(); }
public static string DisplayMovement(Player player, string input) { // Here after the player enters a direction the program finds which direction the user entered, then finds if the direction is valid by accessing the players current location. // If the direction is valid it will move the players current location to the new room by changing the currentroom in player.cs to the new subscript location. #region Player Movement North if (input.ToLower() == "north") { if (player.CurrentRoom.North != -1) { player.CurrentRoom = GameAttributes.RoomByID(player.CurrentRoom.North); } else { Console.WriteLine("\nYou are looking at a wall\n"); } } #endregion Player Movement North #region Player Movement South else if (input.ToLower() == "south") { if (player.CurrentRoom.South != -1) { player.CurrentRoom = GameAttributes.RoomByID(player.CurrentRoom.South); } else { Console.WriteLine("\nYou are looking at a wall\n"); } } #endregion Player Movement South #region Player Movement East else if (input.ToLower() == "east") { if (player.CurrentRoom.East != -1) { player.CurrentRoom = GameAttributes.RoomByID(player.CurrentRoom.East); } else { Console.WriteLine("\nYou are looking at a wall\n"); } } #endregion Player Movement East #region Player Movement West else if (input.ToLower() == "west") { if (player.CurrentRoom.West != -1) { player.CurrentRoom = GameAttributes.RoomByID(player.CurrentRoom.West); } else { Console.WriteLine("\nYou are looking at a wall\n"); } } #endregion Player Movement West #region Player Movement Up else if (input.ToLower() == "up") { if (player.CurrentRoom.Up != -1) { player.CurrentRoom = GameAttributes.RoomByID(player.CurrentRoom.Up); } else { Console.WriteLine("\nYou are looking at a wall\n"); } } #endregion Player Movement Up #region Player Movement Down else if (input.ToLower() == "down") { if (player.CurrentRoom.Down != -1) { player.CurrentRoom = GameAttributes.RoomByID(player.CurrentRoom.Down); } else { Console.WriteLine("\nYou are looking at a wall\n"); } } else { Console.WriteLine("\nNot a Valid Direction\n"); } #endregion Player Movement Down return(input); }
public static Player CreatePlayer(Player newPlayer) { // variables and objects for validation and player creation. string password = null; string name = null; bool validName = false; bool validClass = false; bool validRace = false; // Continues to run until the user has made a user name that is not in use. To keep previous users data safe. #region User Name Creation while (validName == false) { Console.Write("\nPlease create a User Name! > "); name = Console.ReadLine(); // After the user enters their name the if statement checks to see if the file name exits. If it doesn't then the program will continue. if (!File.Exists($"{name}.csv")) { newPlayer.PlayerName = name; validName = true; } else { Console.WriteLine("\nUser Name already Exists!\n"); } } #endregion // Continues to run until the user meets all requirements allocated for a password. #region Password Creation while (password == null || !password.Any(char.IsLower) || !password.Any(char.IsUpper) || !password.Any(x => char.IsLetterOrDigit(x))) { Console.WriteLine("\nMake a Password. Must have 1 captical letter, 1 lowercase letter, and 1 special character."); Console.Write("Please create a Password! > "); // Takes users Entry and passes it to a method for validation. Method will only return once user has a valid password, which will then exit the loop. password = PasswordValidator(Console.ReadLine()); } newPlayer.Password = password; #endregion Password Creation // Continues to run until the user chooses a class that we have allocated in our enums. #region Class Options while (validClass == false) { Console.WriteLine("Pick Class. Choose Warrior, Mage, Rogue, Paladin"); Console.Write("Choose a class! > "); // Created the class method to make sure that the users entry matches our enum. string playerClass = FirstLetterToCap.MakeFirstLetterCap(Console.ReadLine()); // This accesses our enum class and converts data inside to a string so that we can use our enums as comparision to user's entry. if (playerClass == Classes.Warrior.ToString() || playerClass == Classes.Mage.ToString() || playerClass == Classes.Rogue.ToString() || playerClass == Classes.Paladin.ToString()) { // After the class is chosen, the player gets stats based off class chosen. newPlayer.PlayerClass = playerClass; switch (playerClass) { case "Warrior": newPlayer.PlayerLevel = 1; newPlayer.CurrentRoom = GameAttributes.rooms[0]; newPlayer.Equipment = GameAttributes.PlayerWeaponByID(201); newPlayer.PlayerMaxHP = 100; newPlayer.HP = 30; newPlayer.AC = 13; newPlayer.Gold = 50; newPlayer.XP = 125; newPlayer.IsDead = false; break; case "Mage": newPlayer.PlayerLevel = 1; newPlayer.CurrentRoom = GameAttributes.rooms[0]; newPlayer.Equipment = GameAttributes.PlayerWeaponByID(202); newPlayer.PlayerMaxHP = 90; newPlayer.HP = 30; newPlayer.AC = 14; newPlayer.Gold = 100; newPlayer.XP = 175; newPlayer.IsDead = false; break; case "Rogue": newPlayer.PlayerLevel = 1; newPlayer.CurrentRoom = GameAttributes.rooms[0]; newPlayer.Equipment = GameAttributes.PlayerWeaponByID(203); newPlayer.PlayerMaxHP = 80; newPlayer.HP = 30; newPlayer.AC = 15; newPlayer.Gold = 75; newPlayer.XP = 150; newPlayer.IsDead = false; break; case "Paladin": newPlayer.PlayerLevel = 1; newPlayer.CurrentRoom = GameAttributes.rooms[0]; newPlayer.Equipment = GameAttributes.PlayerWeaponByID(204); newPlayer.PlayerMaxHP = 110; newPlayer.HP = 30; newPlayer.AC = 13; newPlayer.Gold = 25; newPlayer.XP = 100; newPlayer.IsDead = false; break; default: Console.WriteLine("Invalid input"); break; } validClass = true; } else { Console.WriteLine("\nNot a valid Class!\n"); } } #endregion Class Options // Continues to run until the user chooses a race that we have allocated in our enums. #region Race Options while (validRace == false) { Console.WriteLine("Pick Race. Choose Elf, Human, Dwarf, Orc"); Console.Write("Choose a Race! > "); // Created the class method to make sure that the users entry matches our enum. string playerRace = FirstLetterToCap.MakeFirstLetterCap(Console.ReadLine()); // This accesses our enum race and converts data inside to a string so that we can use our enums as comparision to user's entry. if (playerRace == Race.Elf.ToString() || playerRace == Race.Human.ToString() || playerRace == Race.Dwarf.ToString() || playerRace == Race.Orc.ToString()) { newPlayer.PlayerRace = playerRace; validRace = true; } else { Console.WriteLine("\nNot a valid Class!\n"); } } #endregion Race Options // After all player creations requirements are met the object is passed to another class to save the data to a CSV file. PlayerToFile.SavePlayerData(newPlayer); // Them the player must login to their new account. Console.Write("\nPlease enter your User Name to start: > "); return(newPlayer = LoadPlayerFromFile.LoadPlayer(Console.ReadLine())); }