Пример #1
0
 public void OnBoardUpdated(BoardUpdatedEventArgs bu)
 {
     if (BoardUpdated != null)
     {
         BoardUpdated(this, bu);
     }
 }
Пример #2
0
        public bool ImplementMove(Move i_InputMove, out string o_Errormessage)
        {
            BoardUpdatedEventArgs bu;
            GameEndedEventArgs    ge;
            Move   pcMove = new Move();
            bool   result = false, isSkipMove = false;
            string endGameMessage;

            createPossibleMovesForCurrentPlayer();
            isSkipMove = m_PlayerSkipMoves.Count != 0;

            if (isLegalMove(ref i_InputMove, out o_Errormessage))
            {
                m_LastGameToolPlaced = i_InputMove.Execute(m_GameBoard, m_CurrentPlayer.PlayerTools, m_NextPlayer.PlayerTools);

                m_PlayerSkipMoves.Clear();
                m_LastGameToolPlaced.AddSkipMoves(m_GameBoard, m_PlayerSkipMoves);

                if (isSkipMoveLeft() && isSkipMove)
                {
                    m_NeedToSkip = true;
                }
                else
                {
                    switchPlayers();
                    m_NeedToSkip = false;
                }

                bu = new BoardUpdatedEventArgs(i_InputMove);
                OnBoardUpdated(bu);
                result = true;
            }

            if (IsEndGame())
            {
                EndGame(out endGameMessage);
                ge = new GameEndedEventArgs(endGameMessage);
                OnGameEnded(ge);
            }
            else if (CurrentPlayer.IsPc())
            {
                createPossibleMovesForCurrentPlayer();
                pcMove = CurrentPlayer.GetPCMove(m_PlayerRegularMoves, m_PlayerSkipMoves);
                ImplementMove(pcMove, out o_Errormessage);
            }

            return(result);
        }