private List <CellPoint> checkMove(int i_Row, int i_Col, int i_IndentRow, int i_IndentCol) { List <CellPoint> currentDiscs = new List <CellPoint>(); Game.ePlayerId currPlayerId = m_CurrentPlayerTurn; int size = m_Othelo.GameBoard.BoardSize; Game.ePlayerId cellId; int i = i_Row + i_IndentRow; int j = i_Col + i_IndentCol; while (i >= 0 && i < size && j >= 0 && j < size) { cellId = m_Othelo.GameBoard.BoardCells[i, j].Owner; if (cellId == currPlayerId) { return(currentDiscs); } else if (cellId == Game.ePlayerId.None) { return(null); } else { currentDiscs.Add(new CellPoint(i, j)); currentDiscs.Add(new CellPoint(i_Row, i_Col)); } i += i_IndentRow; j += i_IndentCol; } return(null); }
private static void printLastInsruction(Game.ePlayerId i_PlayerId, string i_Instruction) { string playerName; BoardCell.eSigns playerSign; if (i_Instruction.Length != UI.k_SingleLetter) { playerName = s_Game.GetPlayerNameById(i_PlayerId); playerSign = BoardCell.GetSignFromPlayerId(i_PlayerId); UI.PrintInsruction(playerSign, playerName, i_Instruction); } }
public static eSigns GetSignFromPlayerId(Game.ePlayerId i_PlayerId) { eSigns sign; if (i_PlayerId == Game.ePlayerId.None) { sign = eSigns.Empty; } else { sign = i_PlayerId == Game.ePlayerId.Player1 ? eSigns.FirstPlayerSign : eSigns.SecondPlayerSign; } return(sign); }
public void InitializeCell(Point i_Location, Game.ePlayerId i_OwnerId) { m_OwnerId = i_OwnerId; m_Sign = GetSignFromPlayerId(i_OwnerId); m_Location = i_Location; if (m_Sign != eSigns.Empty) { if (m_Sign == eSigns.FirstPlayerSign) { m_Direction = eDirection.Up; } else if (m_Sign == eSigns.SecondPlayerSign) { m_Direction = eDirection.Down; } m_MovingOptions = new Dictionary <Point, Game.eMoveType>(); } }
public void InitializeCell(int i_Row, int i_Col, Game.ePlayerId i_OwnerId) { m_OwnerId = i_OwnerId; m_Sign = GetSignFromPlayerId(i_OwnerId); m_Identifier = getCellIdByRowCol(i_Row, i_Col); if (m_Sign != eSigns.Empty) { if (m_Sign == eSigns.FirstPlayerSign) { m_Direction = eDirection.Up; } else if (m_Sign == eSigns.SecondPlayerSign) { m_Direction = eDirection.Down; } m_MovingOptions = new Dictionary <string, Game.eMoveType>(); } }
public void RandInstruction(List <CellPoint> i_Moves) { Random rnd = new Random(); int length = i_Moves.Count; int rndIndex = rnd.Next(0, length); List <CellPoint> cellsToUpdate = new List <CellPoint>(); if (length > 0) { TryMove(i_Moves[rndIndex].Row, i_Moves[rndIndex].Col, out cellsToUpdate); } if (cellsToUpdate.Count > 0) { UpdateBoard(cellsToUpdate); } m_CurrentPlayerTurn = m_Othelo.Players[k_FirstPlayer].Id; }
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); }
public static eSigns GetKingSignFromPlayerId(Game.ePlayerId i_PlayerId) { return(i_PlayerId == Game.ePlayerId.Player1 ? eSigns.FirstPlayerKingSign : eSigns.SecondPlayerKingSign); }
public Player(string i_Name, Game.ePlayerId i_PlayerId) { m_Name = i_Name; m_Id = i_PlayerId; m_OccupiedCells = new List <CellPoint>(); }
public OtheloGame(List <Player> i_Players, int i_BoardSize) { m_Othelo = new Game(i_Players, i_BoardSize); m_CurrentPlayerTurn = Game.ePlayerId.Player1; }
public Player(string i_Name, Game.ePlayerId i_PlayerSerial) { m_Name = i_Name; m_Id = i_PlayerSerial; m_PlayerCheckers = new List <string>(); }