示例#1
0
    public static void StartScreen(int currentUser)
    {
        bool loggedIn = true;
        var  ThisUser = Program.accounts.Find(x => x.userID == currentUser);

        TextCode.LoadTextFiles(ThisUser.userID);
        Console.WriteLine($"Welcome {ThisUser.username} \nType help for all commands");
        while (loggedIn)
        {
            string command = Console.ReadLine();
            if (command == "logout")
            {
                loggedIn = false;
            }

            else if (command.Contains("accounts"))
            {
                command = command.Substring(8);
                command = Program.RemoveWhitespace(command);
                AllAccounts(command);
            }
            else if (command.ToLower().Contains("delete"))
            {
                command = command.Substring(6);
                command = Program.RemoveWhitespace(command);
                if (command.Length < 3)
                {
                    Console.WriteLine("Choose an account to delete");
                    AllAccounts(command);
                    command = Console.ReadLine();
                }
                Program.DeleteAccount(command);
            }
            else if (command.ToLower().Contains("changeusername"))
            {
                command = command.Substring(14);
                command = Program.RemoveWhitespace(command);
                if (command.Length < 2)
                {
                    Console.WriteLine("Choose a new username");
                    command = Console.ReadLine();
                }
                if (!command.Contains("§"))
                {
                    Program.ChangeUsername(command, ThisUser.userID);
                }
            }
            else if (command.ToLower().Contains("changepassword"))
            {
                command = command.Substring(14);
                command = Program.RemoveWhitespace(command);
                if (command.Length < 2)
                {
                    Console.WriteLine("Choose a new password");
                    command = Console.ReadLine();
                }
                if (!command.Contains("§"))
                {
                    Program.ChangePassword(command, ThisUser.userID);
                }
            }
            //text code
            else if (command.ToLower().Contains("text"))
            {
                TextCode.TextFileConditions(command, currentUser);
            }
            //game code
            else if (command.Contains("game"))
            {
                Console.Write("All available games: ");
                foreach (var game in games)
                {
                    Console.Write(game + ", ");
                }
                Console.WriteLine();
                command = Console.ReadLine();
                if (command.Contains("31"))
                {
                    Game31.Game();
                    Console.Clear();
                }
                else if (command.Contains("drawgame"))
                {
                    DrawGame.DrawGameInit(currentUser);
                    Console.Clear();
                }
            }
            else if (command.Contains("help"))
            {
                Console.Write("All available commands: ");
                foreach (var com in commands)
                {
                    Console.Write(com + ", ");
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Invalid command");
            }
        }
    }