public static int CalculateTotalPoitnsForAccount(GameSpecificAccount account) { var points = 0; points += PointSystem.CalculatePointCost(account.Strength); points += PointSystem.CalculatePointCost(account.Dexterity); points += PointSystem.CalculatePointCost(account.Constitution); points += PointSystem.CalculatePointCost(account.Charisma); points += PointSystem.CalculatePointCost(account.Inteligence); return(points); }
private static void CreateAccount() { UserAccount account = new UserAccount(); int option = -1; bool creating = true; string Error = ""; Dictionary <int, string> optionsToStat = new Dictionary <int, string>() { { 2, "Strength" }, { 3, "Dexterity" }, { 4, "Constitution" }, { 5, "Charisma" }, { 6, "Inteligence" }, { 7, "Wisdom" } }; while (creating) { Console.Clear(); Console.WriteLine("~~~CHARACTER CREATION~~~"); Console.WriteLine(); Console.WriteLine("Points Left: " + (account.PointBuy - PointSystem.CalculateTotalPoitnsForAccount(account))); Console.WriteLine(); Console.WriteLine("1: Username: "******"" : account.Username)); Console.WriteLine(); Console.WriteLine("2: STR: " + (option == 2 ? "" : account.Strength.ToString())); Console.WriteLine("3: Dexterity: " + (option == 3 ? "" : account.Dexterity.ToString())); Console.WriteLine("4: Constitution: " + (option == 4 ? "" : account.Constitution.ToString())); Console.WriteLine("5: Charisma: " + (option == 5 ? "" : account.Charisma.ToString())); Console.WriteLine("6: Inteligence: " + (option == 6 ? "" : account.Inteligence.ToString())); Console.WriteLine("7: Wisdom: " + (option == 7 ? "" : account.Wisdom.ToString())); Console.WriteLine(); Console.WriteLine("0: Submit to SSO Server."); Console.WriteLine(); if (string.IsNullOrEmpty(Error)) { Console.WriteLine(); } else { Console.WriteLine("Error: " + Error); } Console.WriteLine(); Error = ""; if (option == -1) { Console.Write("Choose an option: "); string rawOption = Console.ReadLine(); try { option = int.Parse(rawOption); } catch (Exception ex) { Error = "Choose a valid Option"; } if (option > 7 || option < 0) { option = -1; Error = "Choose a valid Option"; } } else if (option == 1) { Console.Write("Choose a username: "******"Choose a " + optionsToStat[option] + " score: "); int score = 0; int.TryParse(Console.ReadLine(), out score); if (PointSystem.CalculatePointCost(score) > 100) { Error = "Choose a score between 7 and 18"; } else { switch (option) { case 2: account.Strength = score; break; case 3: account.Dexterity = score; break; case 4: account.Constitution = score; break; case 5: account.Charisma = score; break; case 6: account.Inteligence = score; break; case 7: account.Wisdom = score; break; } option = -1; } } else if (option == 0) { if (!PointSystem.IsValidAccount(account)) { Error = "Account is not valid."; option = -1; } else { BaseResponse response = client.Create(account); if (response.Status == 200) { creating = false; } else { Error = response.Text; option = -1; } } } } }
private static void CreateAccount(GameSpecificAccount newAccount) { int option = -1; bool creating = true; string Error = ""; Dictionary <int, string> optionsToStat = new Dictionary <int, string>() { { 2, "Strength" }, { 3, "Dexterity" }, { 4, "Constitution" }, { 5, "Charisma" }, { 6, "Inteligence" }, }; while (creating) { Console.Clear(); Console.WriteLine("~~~CHARACTER CREATION~~~"); Console.WriteLine(); Console.WriteLine("Points Left: " + (newAccount.PointBuy - CalculateTotalPoitnsForAccount(newAccount))); Console.WriteLine(); Console.WriteLine("2: STR: " + (option == 2 ? "" : newAccount.Strength.ToString())); Console.WriteLine("3: Dexterity: " + (option == 3 ? "" : newAccount.Dexterity.ToString())); Console.WriteLine("4: Constitution: " + (option == 4 ? "" : newAccount.Constitution.ToString())); Console.WriteLine("5: Charisma: " + (option == 5 ? "" : newAccount.Charisma.ToString())); Console.WriteLine("6: Inteligence: " + (option == 6 ? "" : newAccount.Inteligence.ToString())); Console.WriteLine(); Console.WriteLine("0: Save Account"); Console.WriteLine(); if (string.IsNullOrEmpty(Error)) { Console.WriteLine(); } else { Console.WriteLine("Error: " + Error); } Console.WriteLine(); Error = ""; if (option == -1) { Console.Write("Choose an option: "); string rawOption = Console.ReadLine(); try { option = int.Parse(rawOption); } catch (Exception ex) { Error = "Choose a valid Option"; } if (option > 6 || option < 0 || option == 1) { option = -1; Error = "Choose a valid Option"; } } else if (option > 1) { Console.Write("Choose a " + optionsToStat[option] + " score: "); int score = 0; int.TryParse(Console.ReadLine(), out score); if (PointSystem.CalculatePointCost(score) > 100) { Error = "Choose a score between 7 and 18"; } else { switch (option) { case 2: newAccount.StrMod = 0; newAccount.StrMod = score - newAccount.Strength; break; case 3: newAccount.DexMod = 0; newAccount.DexMod = score - newAccount.Dexterity; break; case 4: newAccount.ConMod = 0; newAccount.ConMod = score - newAccount.Constitution; break; case 5: newAccount.ChaMod = 0; newAccount.ChaMod = score - newAccount.Charisma; break; case 6: newAccount.IntMod = 0; newAccount.IntMod = score - newAccount.Inteligence; break; } option = -1; } } else if (option == 0) { if (CalculateTotalPoitnsForAccount(newAccount) != newAccount.PointBuy) { Error = "Account is not valid."; option = -1; } else { allAccounts.Add(newAccount); SaveAllUsers(); Console.Clear(); Console.WriteLine("Account made successfully!.\n\n"); account = newAccount; creating = false; } } } }