예제 #1
0
        ////check if there are 4 in-a-row - vertical up down
        private bool fourInVerticalDown(int i_RowToCheck, int i_ColToCheck, Player.eShapeOfCoin i_ShapeToCheck)
        {
            bool foundedFourCoins = false;

            if (i_RowToCheck + 3 < m_BoardGame.Rows)
            {
                foundedFourCoins = m_BoardGame.GetCharByIndexes(i_RowToCheck + 1, i_ColToCheck) == (char)i_ShapeToCheck &&
                                   m_BoardGame.GetCharByIndexes(i_RowToCheck + 2, i_ColToCheck) == (char)i_ShapeToCheck &&
                                   m_BoardGame.GetCharByIndexes(i_RowToCheck + 3, i_ColToCheck) == (char)i_ShapeToCheck;
            }

            return(foundedFourCoins);
        }
예제 #2
0
        ////check if there are 4 in-a-row - diagonal up right
        private bool fourInDiagonalUpRight(int i_RowToCheck, int i_ColToCheck, Player.eShapeOfCoin i_ShapeToCheck)
        {
            bool foundedFourCoins = false;

            if (i_ColToCheck + 3 < m_BoardGame.Cols && i_RowToCheck - 3 >= 0)
            {
                foundedFourCoins = m_BoardGame.GetCharByIndexes(i_RowToCheck - 1, i_ColToCheck + 1) == (char)i_ShapeToCheck &&
                                   m_BoardGame.GetCharByIndexes(i_RowToCheck - 2, i_ColToCheck + 2) == (char)i_ShapeToCheck &&
                                   m_BoardGame.GetCharByIndexes(i_RowToCheck - 3, i_ColToCheck + 3) == (char)i_ShapeToCheck;
            }

            return(foundedFourCoins);
        }
예제 #3
0
        ////check if there are 4 in-a-row - Horizion right
        private bool fourInHorizonRight(int i_RowToCheck, int i_ColToCheck, Player.eShapeOfCoin i_ShapeToCheck)
        {
            bool foundedFourCoins = false;

            if (i_ColToCheck + 3 < m_BoardGame.Cols)
            {
                foundedFourCoins = m_BoardGame.GetCharByIndexes(i_RowToCheck, i_ColToCheck + 1) == (char)i_ShapeToCheck &&
                                   m_BoardGame.GetCharByIndexes(i_RowToCheck, i_ColToCheck + 2) == (char)i_ShapeToCheck &&
                                   m_BoardGame.GetCharByIndexes(i_RowToCheck, i_ColToCheck + 3) == (char)i_ShapeToCheck;
            }

            return(foundedFourCoins);
        }
예제 #4
0
        ////check if someone win
        public bool checkWinsOfTheMatch(Player.eNumberOfPlayer i_NumberOfPlayer)
        {
            Player.eShapeOfCoin shapeOfCurrentPlayer = (Player.eShapeOfCoin)m_Players[(int)i_NumberOfPlayer].ShapeOfCoin;
            bool foundedFourCoins = false;

            for (int i = m_BoardGame.Rows - k_IndexFix; i >= 0 && !foundedFourCoins; i--)
            {
                for (int j = m_BoardGame.Cols - k_IndexFix; j >= 0 && !foundedFourCoins; j--)
                {
                    if (m_BoardGame.GetCharByIndexes(i, j) == (char)shapeOfCurrentPlayer)
                    {
                        foundedFourCoins = fourInVerticalDown(i, j, shapeOfCurrentPlayer) ||
                                           fourInHorizonRight(i, j, shapeOfCurrentPlayer) ||
                                           fourInDiagonalDownRight(i, j, shapeOfCurrentPlayer) ||
                                           fourInDiagonalUpRight(i, j, shapeOfCurrentPlayer);
                    }
                }
            }

            return(foundedFourCoins);
        }