public void StartGame(ref CheckersBoard io_CheckersBoard) { m_CheckersBoard = io_CheckersBoard; m_CheckersBoard.InitialPiecePlacement(); // initialize piece placement m_PrevPlayer = m_SecondPlayer; // player whose turn is up next (previous after first turn) m_CurrentPlayer = m_FirstPlayer; // switch between current and prev player m_CurrentPlayer.PlayerMove = null; // holds comment of current player's turn, make sure it is empty m_PrevPlayer.PlayerMove = null; // holds comment of previous player's turn, make sure it is empty }
public void PlayerTurn(int i_CurrRow, int i_CurrCol, int i_NextRow, int i_NextCol) { ePlayerStatus currPlayerStatus; DialogResult result = DialogResult.None; currPlayerStatus = checkAvailableMoves(); // check available moves for player (mustjump, mustmove) if (currPlayerStatus != ePlayerStatus.UnableToMove) { if (m_CurrentPlayer.IsHuman) { currPlayerTurn(currPlayerStatus, i_CurrRow, i_CurrCol, i_NextRow, i_NextCol); // get valid move, implement it and update board } else { currAIPlayerTurn(currPlayerStatus, i_CurrRow, i_CurrCol, i_NextRow, i_NextCol); } } currPlayerStatus = checkAvailableMoves(); if (m_GameStatus == eGameStatus.PlayerOneWin) { result = showMessageBox(1); // send player 1 num } else if (m_GameStatus == eGameStatus.PlayerTwoWin) { result = showMessageBox(2); // send player 2 num } else if (m_GameStatus == eGameStatus.Draw) { MessageBox.Show("Tie! Another Round?", "Congratulations...?", MessageBoxButtons.YesNo, MessageBoxIcon.Information); } if (result == DialogResult.Yes) { m_CheckersBoard.InitialPiecePlacement(); StartGame(ref m_CheckersBoard); } }