示例#1
0
        private void Finish(Player winner)
        {
            Design.SlowPrint("Player" + winner.Name + "Has won the game!", 70);
            Design.WriteLine("Press 'Any Key' to exit (ONLY that key will work)");
            Console.ReadKey();

            Environment.Exit(0);
        }
示例#2
0
        //OPTIMIZE CanMove
        //Checks if the player can move
        private void CanMove(Player turn)
        {
            Token[] tokens = turn.GetTokens();

            int choice = 0; //How many tokens can the player move
            int finish = 0;

            Console.WriteLine("Here are your pieces:");
            Design.WriteLine("", delay);
            foreach (Token tkn in tokens)                                               //Begins to write the tokens of the player
            {
                Console.Write("piece number: " + tkn.Id + " are placed: " + tkn.State); //Writes the id and state of each of the tokens
                switch (tkn.State)                                                      //Begins to check if the player can do anything with his/hers tokens
                {
                case TokenState.Home:
                    if (die.GetValue == 6)
                    {
                        Console.Write(" - Can move");
                        choice++;     //Can move this token AKA a choice
                        tkn.CanMove = true;
                    }
                    else
                    {
                        Console.Write(" - Can not move");
                        tkn.CanMove = false;
                    }
                    break;

                case TokenState.Finished:
                    Console.Write(" <- Is finished");
                    tkn.CanMove = false;
                    finish++;
                    break;

                default:
                    Console.Write(" <- Can move : " + tkn.Position + " ");
                    choice++;
                    tkn.CanMove = true;
                    break;
                }
                Design.WriteLine("", delay);
            }

            if (finish >= 4)
            {
                Finish(turn); //Finishes the game
            }

            Design.WriteLine("<------------------------------------------------>");
            Console.WriteLine(tokens[0].Color.ToString() + " have " + choice.ToString() + " options in this turn\n");

            tries++;

            if (tries < 3 && die.GetValue < 6 && choice == 0)
            {
                Turn();
            }

            tries = 0;

            if (choice == 0) //Cant do anything this turn skips the player
            {
                ChangeTurn();
            }
            else
            {
                MoveToField(players[playerTurn]);
                ChangeTurn();
            }
        }