public void StartMoves(out ExitOrCont o_ExitOrCont) { eCurrentPlayer currPlayer = eCurrentPlayer.Player1; o_ExitOrCont = ExitOrCont.Continue; while (!m_PlayGame.IsEndOfGame() && o_ExitOrCont == ExitOrCont.Continue) { Ex02.ConsoleUtils.Screen.Clear(); showBoard(); if (currPlayer == eCurrentPlayer.Player1) { TurnOfPlayer(currPlayer, out o_ExitOrCont); currPlayer = eCurrentPlayer.Player2; } else if (m_PlayGame.GameType == eGameType.AgainstComp) { TurnOfPc(); currPlayer = eCurrentPlayer.Player1; } else { TurnOfPlayer(currPlayer, out o_ExitOrCont); currPlayer = eCurrentPlayer.Player1; } } if (o_ExitOrCont == ExitOrCont.Continue) { WinnerDecleration(); } }
private void changePlayer() { if (m_CurrPlayer == eCurrentPlayer.Player1) { m_CurrPlayer = eCurrentPlayer.Player2; this.m_CurrentPlayerLabel.Text = "Current Player: " + m_PlayGame.SecondPlayer.Name; this.m_CurrentPlayerLabel.BackColor = this.m_SecondPlayerLabel.BackColor; } else { m_CurrPlayer = eCurrentPlayer.Player1; this.m_CurrentPlayerLabel.Text = "Current Player: " + m_PlayGame.FirstPlayer.Name; this.m_CurrentPlayerLabel.BackColor = this.m_FirstPlayerLabel.BackColor; } }
private void EndTurn() { mCurrentPlayer = ChangePlayer(); mGame.ChangePlayer(); refreshBoard(); if (mGame.IsGameOver()) { GameOver(); } // Plays the computer's turn if it's vs computer. if (mGame.CurrentPlayer == mGame.Player2 && mGame.IsVSComputer) { wait(800); mGame.PlayComputerTurn(mGame.CurrentPlayer); EndTurn(); } }
private void ClearAll(string i_Name1, string i_Name2) { m_PlayGame = new PlayGame(i_Name1, i_Name2, m_PlayGame.GameBoard.Rows, m_PlayGame.GameBoard.Cols, m_PlayGame.GameType); Board Board = m_PlayGame.BoardGame; for (int i = 0; i < Board.Rows; i++) { for (int j = 0; j < Board.Cols; j++) { GameCell GameCell = Board.BoardGameMat[i, j]; m_Buttons[i, j].BackColor = System.Drawing.SystemColors.ControlDark; m_Buttons[i, j].Click += m_Button_Click; } } updateScore(); m_CurrPlayer = eCurrentPlayer.Player1; this.m_CurrentPlayerLabel.Text = "Current Player: " + m_PlayGame.FirstPlayer.Name; this.m_CurrentPlayerLabel.BackColor = this.m_FirstPlayerLabel.BackColor; }
private void TurnOfPlayer(eCurrentPlayer i_CurrPlayer, out ExitOrCont o_ExitOrCont) { // string turn; int row1, col1, row2, col2; Console.WriteLine("Please enter the first card for " + i_CurrPlayer); PlayerStepInputAndShowBoard(out row1, out col1, out o_ExitOrCont); if (o_ExitOrCont == ExitOrCont.Continue) { Console.WriteLine("Please enter the second card"); PlayerStepInputAndShowBoard(out row2, out col2, out o_ExitOrCont); if (m_PlayGame.AddPointsIfCorrectAns(row1, col1, row2, col2, i_CurrPlayer)) { Console.WriteLine("Congrats! Right Choise"); } else { Console.WriteLine("Not bad. Maybe Next Time"); } } System.Threading.Thread.Sleep(2000); }
public bool UnmarkCellIfIncorrectOrAddPoint(int i_ChosenFirstRow, int i_ChosenFirstCol, int i_ChosenSecondRow, int i_ChosenSecondCol, eCurrentPlayer i_CurrPlayer) { bool isEqual = false; if (r_GameType == eGameType.AgainstComp) { m_AiOfPc.MemorizeCell(i_ChosenFirstRow, i_ChosenFirstCol); m_AiOfPc.MemorizeCell(i_ChosenSecondRow, i_ChosenSecondCol); } if (m_GameBoard.CheckIfEqual(i_ChosenFirstRow, i_ChosenFirstCol, i_ChosenSecondRow, i_ChosenSecondCol)) { if (i_CurrPlayer == eCurrentPlayer.Player1) { m_FirstPlayer.Score++; } if (i_CurrPlayer == eCurrentPlayer.Player2) { m_SecondPlayer.Score++; } isEqual = true; } else { UnmarkCell(i_ChosenFirstRow, i_ChosenFirstCol); UnmarkCell(i_ChosenSecondRow, i_ChosenSecondCol); } return isEqual; }
public FormGame(int iBoardSize, bool iIsVSComputer, string iPlayer1Name, string iPlayer2Name) { mGame = new Game(new Player(iPlayer1Name), new Player(iPlayer2Name), iIsVSComputer, new Board(iBoardSize)); mCurrentPlayer = eCurrentPlayer.Player1; InitializeComponentCustom(iBoardSize); }