public bool[,] GetFieldAsBoolsForPlayer(Player player) { var arrOut = new bool[FieldSize, FieldSize]; for (int i = 0; i < FieldSize; i += 1) { for (int j = 0; j < FieldSize; j += 1) { if (_fieldData[i, j] == player) arrOut[i, j] = true; } } return arrOut; }
private void SetPlayerWon(Player player) { var pos = GameField.Instance.WritablePositionStart; Console.SetCursorPosition(pos.X, pos.Y + 4); Console.WriteLine("Player {0} won the game.", player.Icon); GameActive = false; }
private void RequestTurn(Player player) { if (!GameActive) return; var validTurn = false; while(!validTurn && GameActive) { var newPos = player.Turn(); if (!GameField.Instance.CheckPositionAvailable(newPos)) continue; _turnList.Add(string.Format("{0} {1}", player.Icon, newPos.ToString())); validTurn = GameField.Instance.SetPositionForPlayer(newPos, player); } }
// Sets a player to a given position. public bool SetPositionForPlayer(Position position, Player player) { if (position == null || !CheckPositionAvailable(position)) return false; _fieldData[position.X, position.Y] = player; FieldsSet += 1; return true; }
public GameFieldEventArgs(GameField.Position position, Player player) { Position = position; Player = player; }