public void SetClass(string actor, Player.Classes playerClass) { Player player = Find(actor); if (player == null || Player.IsTier2Class(player.Class)) { return; } player.Class = playerClass; }
public List <Player> FindByClass(Player.Classes playerClass) { List <Player> list = new List <Player>(); foreach (Player player in Items) { if (player.Class == playerClass) { list.Add(player); } } return(list); }
public static GameObjects LoadObjects(string name) { Player player = Player.GetPlayer(" ", " ", Player.Classes.Brawler, Player.Body.Athletic, "R1"); StreamReader inputFile; string input = " "; GameObjects options = new GameObjects(); if (name == " ") { Console.Write("\nEnter the player's name: "); input = Console.ReadLine(); string inputFileName = input + ".save"; string folder = Environment.CurrentDirectory; try { inputFile = File.OpenText($"{folder}/save/{input}/{inputFileName}"); string user = inputFile.ReadLine(); string password = inputFile.ReadLine(); bool run = true; int i = 0; do { if (i == 3) { Console.WriteLine("\nToo many wrong passwords\n"); GameOptions.Startup(); } Console.Write("\nEnter your password: "******"\nInvalid Password, Please try again\n"); i++; } }while (run == true); input = inputFile.ReadLine(); Player.Classes userClass = Player.Classes.Brawler; switch (input) { case "Brawler": userClass = Player.Classes.Brawler; break; case "Martial Artist": userClass = Player.Classes.MartialArtist; break; case "Soldier": userClass = Player.Classes.Soldier; break; } input = inputFile.ReadLine(); Player.Body type = Player.Body.Athletic; switch (input) { case "Athletic": type = Player.Body.Athletic; break; case "Body Builder": type = Player.Body.BodyBuilder; break; case "Fat": type = Player.Body.Fat; break; case "Skinny": type = Player.Body.Skinny; break; } player = Player.GetPlayer(user, password, userClass, type, "R1"); options = GameObjects.GetObjects(LoadMobs(user), LoadRooms(user), LoadItems(user), LoadPotions(user), LoadTreasures(user), LoadWeapons(user), player); inputFile.Close(); return(options); } catch (FileNotFoundException) { Console.Write("\nFile not found\nWould you like to start a new game or exit?\n>"); input = Console.ReadLine(); switch (input.ToLower()) { case "new game": player = GameOptions.NewPlayer(); GameOptions.CreateUserOptions(player.Name); options = LoadObjects(player.Name); break; default: Environment.Exit(0); break; } } } return(options); }
//Create New Player public static Player NewPlayer() { bool validPassword = false; Console.Write("What's your name: "); string user = Console.ReadLine(); string password = "******"; Player.Classes userClass = Player.Classes.Brawler; Player.Body type = Player.Body.Athletic; do { Console.Write("\nEnter a password to load your game when you save your progress: "); string input = Console.ReadLine(); if (input.Length < 7) { Console.WriteLine("\nPassword needs to be at least seven characters"); } else { if (ContainsSpecialCharacter(input) == false) { Console.WriteLine("\nPassword must contain a special character: !@#$%^&*^&*()_-=`~+'"); } else if (ContainsUppercase(input) == false) { Console.WriteLine("\nPassword must contain at least 1 uppercase letter"); } else if (ContainsLowercase(input) == false) { Console.WriteLine("\nPassword must contain at least 1 lower letter"); } else { password = input; validPassword = true; } } }while (validPassword == false); bool validClass = false; do { Console.Write("\nWhat's your class\nBrawler, Martial Artist, Soldier: "); string input = Console.ReadLine(); switch (input.ToLower()) { case "brawler": userClass = Player.Classes.Brawler; validClass = true; break; case "martial artist": userClass = Player.Classes.MartialArtist; validClass = true; break; case "soldier": userClass = Player.Classes.Soldier; validClass = true; break; default: Console.WriteLine("\nInvalid class please choose between Brawler, Martial Artist, or Soldier"); break; } }while (validClass == false); bool validType = false; do { Console.Write("\nWhat's your body type\nAthletic, Body Builder, Fat, or Skinny: "); string input = Console.ReadLine(); switch (input.ToLower()) { case "athletic": type = Player.Body.Athletic; validType = true; break; case "body builder": type = Player.Body.BodyBuilder; validType = true; break; case "fat": type = Player.Body.Fat; validType = true; break; case "skinny": type = Player.Body.Skinny; validType = true; break; default: Console.WriteLine("\nInvalid class please choose between Brawler, Martial Artist, or Soldier"); break; } }while (validType == false); Player player = Player.GetPlayer(user, password, userClass, type, "R1"); SavePlayerInfo(player, player.RoomID); Console.WriteLine("\nConfirmed! \nPlayer: " + player.Name + "\nJob: " + player.Class); Console.ReadLine(); return(player); }