public override void Expand(Domain.User user, Domain.Games.Game game, List <Domain.Games.Country> changedCountries) { Domain.Games.Team team = game.Teams.FirstOrDefault(t => t.Players.Any(x => x.UserId == user.Id)); if (team != null) { HashSet <Domain.Games.Country> countries = new HashSet <Domain.Games.Country>(changedCountries); HashSet <Domain.Games.Country> revealedCountries = new HashSet <Domain.Games.Country>(); var mapTemplate = this.MapTemplateProvider.GetTemplate(game.MapTemplateName); foreach (var changedCountry in changedCountries) { if (changedCountry.TeamId != team.Id) { // Country does not belong to team, do not expand continue; } // Add connected countries foreach (var connectedCountry in mapTemplate .GetConnectedCountries(changedCountry.CountryIdentifier) .Select(x => game.Map.GetCountry(x))) { if (!revealedCountries.Contains(connectedCountry) && !countries.Contains(connectedCountry)) { revealedCountries.Add(connectedCountry); } } } changedCountries.AddRange(revealedCountries); } }
public GameDTO(Domain.Games.Game game, PlayerDTO player) { GameId = game.Id; Me = player; bool isPlayerA = game.PlayerA == player.Id; Opponent = isPlayerA ? game.PlayerB : game.PlayerA; Board = isPlayerA ? game.BoardA : game.BoardB; EnemyBoard = game.IsEnded ? (isPlayerA ? game.BoardB : game.BoardA) : (isPlayerA ? game.BoardB.OnlySunkShips() : game.BoardA.OnlySunkShips()); GameState = isPlayerA ? game.PlayerAState : game.PlayerBState; }
public override void Expand(Domain.User user, Domain.Games.Game game, List <Domain.Games.Country> changedCountries) { // Do not modify anything }
public abstract void Expand(Domain.User user, Domain.Games.Game game, List <Domain.Games.Country> changedCountries);