예제 #1
0
        private bool transferToKing(Point i_Location, GameTool i_GameToolToMove)
        {
            bool result = false;

            if ((i_Location.X == Height - 1 || i_Location.X == 0) && !i_GameToolToMove.IsKing())
            {
                result = true;
            }

            return(result);
        }
예제 #2
0
        public void UpdateMoveOnBoard(Move i_Move, GameTool i_GameToolToMove)
        {
            char tempSign = i_GameToolToMove.Sign;

            DeleteFromBoard(i_Move.From);
            if (transferToKing(i_Move.To, i_GameToolToMove))
            {
                i_GameToolToMove.Sign       = i_GameToolToMove.FriendSign;
                i_GameToolToMove.FriendSign = tempSign;
            }

            addToBoard(i_Move.To, i_GameToolToMove.Sign);
        }
예제 #3
0
파일: Move.cs 프로젝트: naorbakal/Checkers
        private GameTool findGameToolByLocation(List <GameTool> i_CurrentPlayerTools, Point i_GameToolLocation)
        {
            GameTool result = null;

            foreach (GameTool currentGameTool in i_CurrentPlayerTools)
            {
                if (currentGameTool.Location == i_GameToolLocation)
                {
                    result = currentGameTool;
                    break;
                }
            }

            return(result);
        }
예제 #4
0
파일: Game.cs 프로젝트: naorbakal/Checkers
        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);
        }
예제 #5
0
 private bool checkIfKing(GameTool currentPlayerTool)
 {
     return(currentPlayerTool.Sign == (char)GameTool.eSigns.PlayerOKing ||
            currentPlayerTool.Sign == (char)GameTool.eSigns.PlayerXKing);
 }