Beispiel #1
0
        private string getSignToPrint(eSign i_SignToPrint)
        {
            char signChar;

            switch (i_SignToPrint)
            {
            case eSign.Empty:
                signChar = ' ';
                break;

            case eSign.O:
                signChar = 'O';
                break;

            case eSign.X:
                signChar = 'X';
                break;

            case eSign.U:
                signChar = 'U';
                break;

            case eSign.K:
                signChar = 'K';
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(i_SignToPrint), i_SignToPrint, null);
            }

            return(signChar.ToString());
        }
Beispiel #2
0
        //cheick if bingo in a diagonal \
        public bool IsBingoDiagonalB(Coin i_Coin)
        {
            int   m_IndexRow           = i_Coin.m_CoinRow;
            int   m_IndexColumn        = i_Coin.m_CoinColumn;
            eSign m_CoinSign           = i_Coin.Sign;
            int   m_CounterInDiagonalB = 0;

            for (int stepDiagonal = 0; stepDiagonal < 3; stepDiagonal++)
            {
                if (GetBoardSpot(m_IndexRow + stepDiagonal, m_IndexColumn - stepDiagonal).Sign == m_CoinSign)
                {
                    m_CounterInDiagonalB++;
                }
                else
                {
                    break;
                }
            }
            for (int stepDiagonal = 0; stepDiagonal < 3; stepDiagonal++)
            {
                if (GetBoardSpot(m_IndexRow - stepDiagonal, m_IndexColumn + stepDiagonal).Sign == m_CoinSign)
                {
                    m_CounterInDiagonalB++;
                }
                else
                {
                    break;
                }
            }
            if (m_CounterInDiagonalB >= 4)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
 public Player(ePlayerType i_PlayerType, eSign i_Sign, string i_PlayerName)
 {
     m_PlayerType  = i_PlayerType;
     m_Sign        = i_Sign;
     m_PlayerName  = i_PlayerName;
     m_NumOfTokens = 0;
 }
Beispiel #4
0
        //check if bingo in a column
        public bool IsBingoColumn(Coin i_Coin)
        {
            int   m_IndexRow        = i_Coin.m_CoinRow;
            int   m_IndexColumn     = i_Coin.m_CoinColumn;
            eSign m_CoinSign        = i_Coin.Sign;
            int   m_CounterInColumn = 0;

            for (int stepUp = 0; stepUp < 3; stepUp++)
            {
                if (GetBoardSpot(m_IndexRow + stepUp, m_IndexColumn).Sign == m_CoinSign)
                {
                    m_CounterInColumn++;
                }
                else
                {
                    break;
                }
            }
            for (int stepDown = 0; stepDown < 3; stepDown++)
            {
                if (GetBoardSpot(m_IndexRow + stepDown, m_IndexColumn).Sign == m_CoinSign)
                {
                    m_CounterInColumn++;
                }
                else
                {
                    break;
                }
            }
            if (m_CounterInColumn >= 4)
            {
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        private char getSignToPrint(eSign i_CellSign)
        {
            char signChar;

            switch (i_CellSign)
            {
            case eSign.Empty:
                signChar = ' ';
                break;

            case eSign.O:
                signChar = 'O';
                break;

            case eSign.X:
                signChar = 'X';
                break;

            case eSign.U:
                signChar = 'U';
                break;

            case eSign.K:
                signChar = 'K';
                break;

            default:
                throw new System.ArgumentOutOfRangeException(nameof(i_CellSign), i_CellSign, null);
            }

            return(signChar);
        }
        private bool checkDiagonalLose(Board.Cell i_LastMove, byte i_PlayerIndex, eSign i_PlayerSign)
        {
            bool minorDiagonalLoseFlag = true;
            bool majorDiagonalLoseFlag = true;

            for (byte colRowIndex = 0; colRowIndex < this.Board.BoardSize; colRowIndex++)
            {
                if (i_LastMove != this.Board[(byte)(this.m_BoardSize - colRowIndex - 1), colRowIndex])
                {
                    if (minorDiagonalLoseFlag && this.Board[(byte)(this.Board.BoardSize - colRowIndex - 1), colRowIndex].m_CellSign != i_PlayerSign)
                    {
                        minorDiagonalLoseFlag = false;
                    }
                }

                if (i_LastMove != this.Board[colRowIndex, colRowIndex])
                {
                    if (majorDiagonalLoseFlag && this.Board[colRowIndex, colRowIndex].m_CellSign != i_PlayerSign)
                    {
                        majorDiagonalLoseFlag = false;
                    }
                }
            }

            bool minorOrMajorDiagonalLose = minorDiagonalLoseFlag || majorDiagonalLoseFlag;

            if (minorOrMajorDiagonalLose)
            {
                this.Players[i_PlayerIndex].RoundStatus = minorDiagonalLoseFlag ? eRoundStatus.MinorDiagonalLose : eRoundStatus.MajorDiagonalLose;
                this.Players[GetOtherPlayerIndex(i_PlayerIndex)].RoundStatus = eRoundStatus.Win;
            }

            return(minorOrMajorDiagonalLose);
        }
Beispiel #7
0
        // Check if bingo in a diagonal \
        public bool IsBingoDiagonalB(Coin i_Coin)
        {
            bool  IsBingo            = false;
            int   IndexRow           = i_Coin.m_CoinRow;
            int   IndexColumn        = i_Coin.m_CoinColumn;
            eSign CoinSign           = i_Coin.Sign;
            int   CounterInDiagonalB = 0;

            for (int stepDiagonalUpLeft = 1; stepDiagonalUpLeft < 4; stepDiagonalUpLeft++)
            {
                if (((IndexRow - stepDiagonalUpLeft) == -1) || ((IndexColumn - stepDiagonalUpLeft) == -1))
                {
                    break;
                }

                if (GetBoardSpot(IndexRow - stepDiagonalUpLeft, IndexColumn - stepDiagonalUpLeft) == null)
                {
                    break;
                }

                if (GetBoardSpot(IndexRow - stepDiagonalUpLeft, IndexColumn - stepDiagonalUpLeft).Sign == CoinSign)
                {
                    CounterInDiagonalB++;
                }
                else
                {
                    break;
                }
            }

            for (int stepDiagonalDownRight = 1; stepDiagonalDownRight < 4; stepDiagonalDownRight++)
            {
                if (((IndexRow + stepDiagonalDownRight) == m_Rows) || ((IndexColumn + stepDiagonalDownRight) == m_Columns))
                {
                    break;
                }

                if (GetBoardSpot(IndexRow + stepDiagonalDownRight, IndexColumn + stepDiagonalDownRight) == null)
                {
                    break;
                }

                if (GetBoardSpot(IndexRow + stepDiagonalDownRight, IndexColumn + stepDiagonalDownRight).Sign == CoinSign)
                {
                    CounterInDiagonalB++;
                }
                else
                {
                    break;
                }
            }

            if (CounterInDiagonalB >= 3)
            {
                IsBingo = true;
            }

            return(IsBingo);
        }
Beispiel #8
0
        // Check if bingo in a column
        public bool IsBingoColumn(Coin i_Coin)
        {
            bool  IsBingo         = false;
            int   IndexRow        = i_Coin.m_CoinRow;
            int   IndexColumn     = i_Coin.m_CoinColumn;
            eSign CoinSign        = i_Coin.Sign;
            int   CounterInColumn = 0;

            for (int stepUp = 1; stepUp < 4; stepUp++)
            {
                if ((IndexRow - stepUp) == -1)
                {
                    break;
                }

                if (GetBoardSpot(IndexRow - stepUp, IndexColumn) == null)
                {
                    break;
                }
                else if (GetBoardSpot(IndexRow - stepUp, IndexColumn).Sign == CoinSign)
                {
                    CounterInColumn++;
                }
                else
                {
                    break;
                }
            }

            for (int stepDown = 1; stepDown < 4; stepDown++)
            {
                if ((IndexRow + stepDown) == m_Rows)
                {
                    break;
                }

                if (GetBoardSpot(IndexRow + stepDown, IndexColumn) == null)
                {
                    break;
                }
                else if (GetBoardSpot(IndexRow + stepDown, IndexColumn).Sign == CoinSign)
                {
                    CounterInColumn++;
                }
                else
                {
                    break;
                }
            }

            if (CounterInColumn >= 3)
            {
                IsBingo = true;
            }

            return(IsBingo);
        }
Beispiel #9
0
        // Check if bingo in a row
        public bool IsBingoRow(Coin i_Coin)
        {
            bool  IsBingo      = false;
            int   IndexRow     = i_Coin.m_CoinRow;
            int   IndexColumn  = i_Coin.m_CoinColumn;
            eSign CoinSign     = i_Coin.Sign;
            int   CounterInRow = 0;

            for (int stepRight = 1; stepRight < 4; stepRight++)
            {
                if ((IndexColumn + stepRight) == m_Columns)
                {
                    break;
                }

                if (GetBoardSpot(IndexRow, IndexColumn + stepRight) == null)
                {
                    break;
                }
                else if (GetBoardSpot(IndexRow, IndexColumn + stepRight).Sign == CoinSign)
                {
                    CounterInRow++;
                }
                else
                {
                    break;
                }
            }

            for (int stepLeft = 1; stepLeft < 4; stepLeft++)
            {
                if ((IndexColumn - stepLeft) == -1)
                {
                    break;
                }

                if (GetBoardSpot(IndexRow, IndexColumn - stepLeft) == null)
                {
                    break;
                }
                else if (GetBoardSpot(IndexRow, IndexColumn - stepLeft).Sign == CoinSign)
                {
                    CounterInRow++;
                }
                else
                {
                    break;
                }
            }

            if (CounterInRow >= 3)
            {
                IsBingo = true;
            }

            return(IsBingo);
        }
        private static eType getType(eSign i_Sign)
        {
            eType type = eType.Regular;

            if (i_Sign == eSign.U || i_Sign == eSign.K)
            {
                type = eType.King;
            }

            return(type);
        }
Beispiel #11
0
        private static string GetUIDAIOtp(string path, string aadhaarnum)
        {
            eSignObj                      = new eSign(path); //Get your own license file from e-Mudhra
            Settings.PfxPath              = "resources\\Docsigntest.pfx";
            Settings.PfxPassword          = "******";
            Settings.UIDAICertificatePath = "resources\\uidai_auth_prod.cer";
            Settings.AuthMode             = AuthMode.OTP;
            string   guid        = System.Guid.NewGuid().ToString();
            Response OTPResponse = eSignObj.GetOTP(aadhaarnum, guid);

            return(guid);
        }
        private bool checkIfPlayerLost(Board.Cell i_LastMove, byte i_PlayerIndex)
        {
            eSign playerSign = this.Players[i_PlayerIndex].Sign;

            bool gameFinishedFlag = this.checkRowOrColLose(i_LastMove, i_PlayerIndex, playerSign);

            if (!gameFinishedFlag && this.isCellOnDiagonal(i_LastMove))
            {
                gameFinishedFlag = this.checkDiagonalLose(i_LastMove, i_PlayerIndex, playerSign);
            }

            return(gameFinishedFlag);
        }
Beispiel #13
0
        private void getLegalDesiredCell(int i_PlayerIndex, ref bool io_QuitRequest, out Cell o_LegalOriginCell, out Cell o_LegalDestCell, ref bool o_Dideat, bool playerHasAnotherMove)
        {
            o_LegalOriginCell = null;
            o_LegalDestCell   = null;
            StringBuilder compStepStr = new StringBuilder();
            eSign         playerSign  = m_Players[i_PlayerIndex].Sign;
            ePlayerType   playerType  = m_Players[i_PlayerIndex].PlayerType;

            if (playerType == ePlayerType.Human)
            {
                getUserCellMove(i_PlayerIndex, playerSign, ref io_QuitRequest, out o_LegalOriginCell, out o_LegalDestCell, ref o_Dideat, playerHasAnotherMove);
            }
            else
            {
                m_GameLogic.SetComputerMove(i_PlayerIndex, out o_LegalOriginCell, out o_LegalDestCell, ref o_Dideat);
                s_PrevStep = compStepStr.Append(o_LegalOriginCell.GetCellStr()).Append(">").Append(o_LegalDestCell.GetCellStr()).ToString();
            }
        }
Beispiel #14
0
        //check if bingo in a row
        public bool IsBingoRow(Coin i_Coin)
        {
            int   m_IndexRow     = i_Coin.m_CoinRow;
            int   m_IndexColumn  = i_Coin.m_CoinColumn;
            eSign m_CoinSign     = i_Coin.Sign;
            int   m_CounterInRow = 0;

            for (int stepRight = 0; stepRight < 3 || ((m_IndexColumn + stepRight) < m_Columns); stepRight++)
            {
                if (GetBoardSpot(m_CounterInRow, m_IndexColumn + stepRight) == null)
                {
                    continue;
                }
                else if (GetBoardSpot(m_CounterInRow, m_IndexColumn + stepRight).Sign == m_CoinSign)
                {
                    m_CounterInRow++;
                }
                else
                {
                    break;
                }
            }
            for (int stepLeft = 0; stepLeft < 3 || ((m_IndexColumn - stepLeft) >= 0); stepLeft++)
            {
                if (GetBoardSpot(m_CounterInRow, m_IndexColumn - stepLeft) == null)
                {
                    continue;
                }
                else if (GetBoardSpot(m_CounterInRow, m_IndexColumn - stepLeft).Sign == m_CoinSign)
                {
                    m_CounterInRow++;
                }
                else
                {
                    break;
                }
            }
            if (m_CounterInRow >= 4)
            {
                return(true);
            }
            return(false);
        }
Beispiel #15
0
        // check if bingo in a diagonal /
        public bool IsBingoDiagonalA(Coin i_Coin)
        {
            int   m_IndexRow           = i_Coin.m_CoinRow;
            int   m_IndexColumn        = i_Coin.m_CoinColumn;
            eSign m_CoinSign           = i_Coin.Sign;
            int   m_CounterInDiagonalA = 0;

            for (int stepDiagonal = 0; stepDiagonal < 3 || ((m_IndexRow + stepDiagonal) > m_Rows) || ((m_IndexColumn + stepDiagonal) > m_Columns); stepDiagonal++)
            {
                if (GetBoardSpot(m_IndexRow + stepDiagonal, m_IndexColumn + stepDiagonal) == null)
                {
                    continue;
                }
                else if (GetBoardSpot(m_IndexRow + stepDiagonal, m_IndexColumn + stepDiagonal).Sign == m_CoinSign)
                {
                    m_CounterInDiagonalA++;
                }
                else
                {
                    break;
                }
            }
            for (int stepDiagonal = 0; stepDiagonal < 3 || ((m_IndexRow - stepDiagonal) <= 0) || ((m_IndexColumn - stepDiagonal) <= 0); stepDiagonal++)
            {
                if (GetBoardSpot(m_IndexRow - stepDiagonal, m_IndexColumn - stepDiagonal) == null)
                {
                    continue;
                }
                else if (GetBoardSpot(m_IndexRow - stepDiagonal, m_IndexColumn - stepDiagonal).Sign == m_CoinSign)
                {
                    m_CounterInDiagonalA++;
                }
                else
                {
                    break;
                }
            }
            if (m_CounterInDiagonalA >= 4)
            {
                return(true);
            }
            return(false);
        }
        private bool checkRowOrColLose(Board.Cell i_LastMove, byte i_PlayerIndex, eSign i_PlayerSign)
        {
            bool rowLoseFlag = true;
            bool colLoseFlag = true;
            byte currentCol  = i_LastMove.m_CellCol;
            byte currentRow  = i_LastMove.m_CellRow;

            for (byte colRowIndex = 0; colRowIndex < this.Board.BoardSize && (colLoseFlag || rowLoseFlag); colRowIndex++)
            {
                if (i_LastMove != this.Board[colRowIndex, currentCol])
                {
                    if (colLoseFlag && this.Board[colRowIndex, currentCol].m_CellSign != i_PlayerSign)
                    {
                        colLoseFlag = false;
                    }
                }

                if (i_LastMove != this.Board[currentRow, colRowIndex])
                {
                    if (rowLoseFlag && this.Board[currentRow, colRowIndex].m_CellSign != i_PlayerSign)
                    {
                        rowLoseFlag = false;
                    }
                }
            }

            bool rowOrColLoseFlag = rowLoseFlag || colLoseFlag;

            if (rowOrColLoseFlag)
            {
                this.Players[i_PlayerIndex].RoundStatus = rowLoseFlag ? eRoundStatus.RowLose : eRoundStatus.ColLose;
                this.Players[GetOtherPlayerIndex(i_PlayerIndex)].RoundStatus = eRoundStatus.Win;
            }

            return(rowOrColLoseFlag);
        }
 private void changeCellButtonAppearance(Button i_CellButton, eSign i_PlayerSign)
 {
     i_CellButton.Enabled               = false;
     i_CellButton.BackgroundImage       = i_PlayerSign == eSign.O ? Resources.O : Resources.X;
     i_CellButton.BackgroundImageLayout = ImageLayout.Stretch;
 }
Beispiel #18
0
 public Player(ePlayerType i_PlayerType, eSign i_Sign)
 {
     this.PlayerType = i_PlayerType;
     this.Sign       = i_Sign;
 }
Beispiel #19
0
        private void getUserCellMove(int i_PlayerIndex, eSign i_PlayerSign, ref bool io_QuitRequest, out Cell o_LegalOriginCell, out Cell o_LegalDestCell, ref bool o_DidEat, bool playerHasAnotherMove)
        {
            bool isLegalMove = false;

            o_LegalOriginCell = null;
            o_LegalDestCell   = null;
            int otherPlayerIndex;

            if (playerHasAnotherMove)
            {
                int tempSaverForCurrentPlayerIndex = i_PlayerIndex + 1;
                otherPlayerIndex = m_GameLogic.GetOtherPlayerIndex(tempSaverForCurrentPlayerIndex);
            }
            else
            {
                otherPlayerIndex = m_GameLogic.GetOtherPlayerIndex(i_PlayerIndex);
            }

            if (s_PrevStep != string.Empty)
            {
                System.Console.WriteLine($@"{m_Players[otherPlayerIndex].PlayerName}'s move was ({m_Players[otherPlayerIndex].Sign}): {s_PrevStep}");
            }

            System.Console.WriteLine($@"{m_Players[i_PlayerIndex].PlayerName}'s Turn ({m_Players[i_PlayerIndex].Sign}):
Enter your desirable coordinate as follows: PrevColPrevRow > ColRow");

            while (!isLegalMove)
            {
                string   userInput  = getUserInput(ref io_QuitRequest);
                string[] splitInput = userInput.Split('>');
                if (io_QuitRequest)
                {
                    if (m_GameLogic.IsPlayerEligToQuit(i_PlayerIndex))
                    {
                        System.Console.WriteLine("You chose to quite.");
                        break;
                    }
                    else
                    {
                        System.Console.WriteLine("Invalid input, please try again.");
                    }
                }

                if (splitInput.Length != 2)
                {
                    System.Console.WriteLine("Invalid input, please try again.");
                    continue;
                }

                if (!m_IsGameOver)
                {
                    if (Cell.Parse(splitInput[0], out o_LegalOriginCell) && Cell.Parse(splitInput[1], out o_LegalDestCell) && m_GameLogic.AreCellsLegal(o_LegalOriginCell, o_LegalDestCell, i_PlayerSign, ref o_DidEat))
                    {
                        if (m_GameLogic.CheckIfCellsInThePossibleList(o_LegalOriginCell, o_LegalDestCell, i_PlayerIndex))
                        {
                            s_PrevStep  = userInput;
                            isLegalMove = true;
                        }
                        else
                        {
                            invalidInputMessage(splitInput);
                        }
                    }
                    else
                    {
                        invalidInputMessage(splitInput);
                    }
                }
                else
                {
                    break;
                }
            }
        }
Beispiel #20
0
 public Coin(eSign i_Sign, int i_Row, int i_Column)
 {
     m_CoinColumn = i_Column;
     m_CoinRow    = i_Row;
     m_Sign       = i_Sign;
 }
Beispiel #21
0
 public Cell(byte i_CellRow, byte i_CellCol, eSign i_CellSign)
 {
     m_CellRow  = i_CellRow;
     m_CellCol  = i_CellCol;
     m_CellSign = i_CellSign;
 }
Beispiel #22
0
 public Player(string i_Name, bool i_IsPC, eSign i_PlayerSign)
 {
     m_PlayerSign = i_PlayerSign;
     m_IsPC       = i_IsPC;
     m_Name       = i_Name;
 }
 public CheckersMen(eSign i_Sign)
 {
     r_Sign  = i_Sign;
     r_Type  = getType(i_Sign);
     r_Value = getValue(r_Type);
 }