private static void printLastInsruction(Game.ePlayerId i_PlayerId, string i_Instruction)
        {
            string playerName;

            BoardCell.eSigns playerSign;

            if (i_Instruction.Length != UI.k_SingleLetter)
            {
                playerName = s_Game.GetPlayerNameById(i_PlayerId);
                playerSign = BoardCell.GetSignFromPlayerId(i_PlayerId);
                UI.PrintInsruction(playerSign, playerName, i_Instruction);
            }
        }
Esempio n. 2
0
        private void initializePlayer(int i_From, int i_To, ePlayerId i_PlayerId)
        {
            BoardCell.eSigns sign             = BoardCell.GetSignFromPlayerId(i_PlayerId);
            bool             needToInitialize = i_From != Board.k_FirstRow;

            m_Players[(int)i_PlayerId].ChekersList.Clear();
            for (int i = i_From; i < i_To; i++)
            {
                for (int j = 0; j < m_Board.BoardSize; j++)
                {
                    m_Board[i, j] = new BoardCell();
                    if (!isEmptyRow(i) && needToSetChecker(i, j))
                    {
                        m_Board[i, j].InitializeCell(i, j, i_PlayerId);
                        m_Players[(int)i_PlayerId].AddChecker(m_Board[i, j].Id);
                    }
                    else
                    {
                        m_Board[i, j].InitializeCell(i, j, ePlayerId.None);
                    }
                }
            }
        }
        private static Game.eMessage play(Game.ePlayerId i_PlayerId)
        {
            bool   isTurnFinished = false;
            string input          = string.Empty;
            string playerName     = s_Game.GetPlayerNameById(i_PlayerId);

            BoardCell.eSigns playerSign    = BoardCell.GetSignFromPlayerId(i_PlayerId);
            Game.eMessage    outputMessage = Game.eMessage.StartGame;

            while (!isTurnFinished)
            {
                if (i_PlayerId == Game.ePlayerId.Computer)
                {
                    Thread.Sleep(k_SleepTime);
                    input = s_Game.GetComputerInstruction();
                }
                else
                {
                    input = UI.GetInstruction(playerName, playerSign);
                }

                outputMessage  = s_Game.PlayTurn(input, i_PlayerId);
                isTurnFinished = isPlayerTurnFinished(outputMessage);
                if (outputMessage == Game.eMessage.MustJumpOverAgain)
                {
                    printUpdatedBoard();
                    printLastInsruction(i_PlayerId, input);
                    UI.PrintMessage(outputMessage);
                }
            }

            printUpdatedBoard();
            printLastInsruction(i_PlayerId, input);

            return(outputMessage);
        }