Example #1
0
        public List <Coin> SquersToFlip(Player i_CurrentPlayer, Coin i_InputCoin, BoardGame i_FullBoardGame)
        {
            List <Coin> o_ListOfSquersToFlip = new List <Coin>(2);

            int  coinsToFlip = 0;
            int  rowDirection;
            int  columDirection;
            int  distance;
            int  sumCoinsToFlip = 0;
            Coin tempCoin       = new Coin();
            Coin coinToFlip;

            for (rowDirection = -1; rowDirection <= 1; rowDirection++)
            {
                for (columDirection = -1; columDirection <= 1; columDirection++)
                {
                    if (!(rowDirection == 0 && columDirection == 0))
                    {
                        distance       = 1;
                        tempCoin.Row   = i_InputCoin.Row + rowDirection;
                        tempCoin.Colum = i_InputCoin.Colum + columDirection;

                        while (IsInBoard(tempCoin) && IsRival(tempCoin, i_CurrentPlayer.CoinType, i_FullBoardGame))
                        {
                            distance++;
                            tempCoin.Row   += rowDirection;
                            tempCoin.Colum += columDirection;
                        }

                        if (distance > 1 && IsInBoard(tempCoin) && !IsRival(tempCoin, i_CurrentPlayer.CoinType, i_FullBoardGame) && !IsEmptySquare(tempCoin))
                        {
                            coinsToFlip    += distance - 1;
                            sumCoinsToFlip += distance - 1;
                            tempCoin.Row   -= rowDirection;
                            tempCoin.Colum -= columDirection;
                            do
                            {
                                coinToFlip = new Coin(tempCoin.Row, tempCoin.Colum);
                                o_ListOfSquersToFlip.Add(coinToFlip);
                                coinsToFlip--;
                                tempCoin.Row   -= rowDirection;
                                tempCoin.Colum -= columDirection;
                            }while (coinsToFlip > 0);
                        }
                    }
                }
            }

            return(o_ListOfSquersToFlip);
        }
Example #2
0
        public int OptionToMove(Coin i_OptionCoin, Player i_Player, BoardGame i_FullBoardGame)
        {
            int  coinsToFlip = 0;
            int  rowDirection;
            int  columDirection;
            int  distance;
            bool isEmpty  = true;
            Coin tempCoin = new Coin();

            if (!i_FullBoardGame.IsEmptySquare(i_OptionCoin))
            {
                isEmpty = false;
            }

            for (rowDirection = -1; rowDirection <= 1 && isEmpty; rowDirection++)
            {
                for (columDirection = -1; columDirection <= 1; columDirection++)
                {
                    if (!(rowDirection == 0 && columDirection == 0))
                    {
                        distance       = 1;
                        tempCoin.Row   = i_OptionCoin.Row + rowDirection;
                        tempCoin.Colum = i_OptionCoin.Colum + columDirection;

                        while (IsInBoard(tempCoin) && IsRival(tempCoin, i_Player.CoinType, i_FullBoardGame))
                        {
                            distance++;
                            tempCoin.Row   += rowDirection;
                            tempCoin.Colum += columDirection;
                        }

                        if (distance > 1 && IsInBoard(tempCoin) && !IsRival(tempCoin, i_Player.CoinType, i_FullBoardGame) && !IsEmptySquare(tempCoin))
                        {
                            coinsToFlip += distance - 1;
                        }
                    }
                }
            }

            return(coinsToFlip);
        }
Example #3
0
        public bool CanMove(BoardGame i_FullBoardGame)
        {
            Coin optionCoin = new Coin();
            bool o_CanMove  = false;

            for (int i = 0; i < this.m_PlayerBoard.Size && o_CanMove == false; i++)
            {
                optionCoin.Row = i;

                for (int j = 0; j < this.m_PlayerBoard.Size && o_CanMove == false; j++)
                {
                    optionCoin.Colum = j;
                    if (this.m_PlayerBoard.OptionToMove(optionCoin, this, i_FullBoardGame) > 0)
                    {
                        o_CanMove = true;
                    }
                }
            }

            return(o_CanMove);
        }
Example #4
0
        public void CreatePossibleCoinToMove(BoardGame i_FullBoardGame)
        {
            m_PossibleCoin.Clear();
            Coin coinToCheck = new Coin();
            Coin optionCoin;

            for (int i = 0; i < m_PlayerBoard.Size; i++)
            {
                coinToCheck.Row = i;

                for (int j = 0; j < m_PlayerBoard.Size; j++)
                {
                    coinToCheck.Colum = j;
                    if (m_PlayerBoard.OptionToMove(coinToCheck, this, i_FullBoardGame) > 0)
                    {
                        optionCoin = new Coin(coinToCheck.Row, coinToCheck.Colum);
                        m_PossibleCoin.Add(optionCoin);
                    }
                }
            }
        }
Example #5
0
 public bool IsRival(Coin i_Coin, char i_CurrentPlayer, BoardGame i_FullBoard)
 {
     return(i_FullBoard.m_BoardGame[i_Coin.Row, i_Coin.Colum] != i_CurrentPlayer && !i_FullBoard.IsEmptySquare(i_Coin));
 }
Example #6
0
 public void CreateBoard(int i_Size)
 {
     m_FullBoardGame = new BoardGame(i_Size);
     m_FullBoardGame.BuildBoard(m_XPlayer.PlayerBoard.OtheloBoardGame, m_OPlayer.PlayerBoard.OtheloBoardGame);
 }