public bool Equals(InitialGameState other) { if ((object)other == null) return false; if (!this.Field.Equals(other.Field)) return false; if (!this.PlayersCount.Equals(other.PlayersCount)) return false; for (var i = 0; i < this.PlayersCount; ++i) { if (!this.Players[i].Equals(other.Players[i])) { return false; } } return true; }
public GameState Combine(InitialGameState gameState, IList<PlayerInfo> playerInfos) { if (playerInfos.Count > gameState.PlayersCount) { throw new ArgumentException(); } var players = new List<PlayerState>(); for (var i = 0; i < playerInfos.Count; ++i) { var init = gameState.Players[i]; var info = playerInfos[i]; players.Add(new PlayerState(i, info.Name, info.Color, init.Position, init.Direction, true)); } return new GameState(gameState.Field, players); }