public void MoveCheckerOnBoard(string i_CurrentCellId, string i_NextCellId) { if (needToBeKing(i_NextCellId)) { this[i_NextCellId].Sign = BoardCell.GetKingSignFromPlayerId(this[i_CurrentCellId].OwnerId); this[i_NextCellId].Direction = BoardCell.eDirection.UpAndDown; } else { this[i_NextCellId].Sign = this[i_CurrentCellId].Sign; this[i_NextCellId].Direction = this[i_CurrentCellId].Direction; } this[i_NextCellId].OwnerId = this[i_CurrentCellId].OwnerId; if (this[i_NextCellId].OptionsList == null) { this[i_NextCellId].OptionsList = new Dictionary <string, Game.eMoveType>(); } MakeCellEmpty(this[i_CurrentCellId]); }
private void initializePlayer(int i_From, int i_To, ePlayerId i_PlayerId) { BoardCell.eSigns sign = BoardCell.GetSignFromPlayerId(i_PlayerId); bool needToInitialize = i_From != Board.k_FirstRow; m_Players[(int)i_PlayerId].ChekersList.Clear(); for (int i = i_From; i < i_To; i++) { for (int j = 0; j < m_Board.BoardSize; j++) { m_Board[i, j] = new BoardCell(); if (!isEmptyRow(i) && needToSetChecker(i, j)) { m_Board[i, j].InitializeCell(i, j, i_PlayerId); m_Players[(int)i_PlayerId].AddChecker(m_Board[i, j].Id); } else { m_Board[i, j].InitializeCell(i, j, ePlayerId.None); } } } }
private static Game.eMessage play(Game.ePlayerId i_PlayerId) { bool isTurnFinished = false; string input = string.Empty; string playerName = s_Game.GetPlayerNameById(i_PlayerId); BoardCell.eSigns playerSign = BoardCell.GetSignFromPlayerId(i_PlayerId); Game.eMessage outputMessage = Game.eMessage.StartGame; while (!isTurnFinished) { if (i_PlayerId == Game.ePlayerId.Computer) { Thread.Sleep(k_SleepTime); input = s_Game.GetComputerInstruction(); } else { input = UI.GetInstruction(playerName, playerSign); } outputMessage = s_Game.PlayTurn(input, i_PlayerId); isTurnFinished = isPlayerTurnFinished(outputMessage); if (outputMessage == Game.eMessage.MustJumpOverAgain) { printUpdatedBoard(); printLastInsruction(i_PlayerId, input); UI.PrintMessage(outputMessage); } } printUpdatedBoard(); printLastInsruction(i_PlayerId, input); return(outputMessage); }
private bool isOpponentCell(BoardCell i_StartCell, BoardCell i_DestinationCell) { bool isOpponentCell = i_StartCell.OwnerId != i_DestinationCell.OwnerId; return(isOpponentCell && i_DestinationCell.OwnerId != Game.ePlayerId.None); }