public void ToggleActive(Guid ladderId, bool isActive) { Domain.Ladders.Ladder ladder = GetLadder(ladderId); ladder.ToggleActive(isActive); this.UnitOfWork.Commit(); }
public DTO.Ladder.Ladder Get(Guid ladderId) { Domain.Ladders.Ladder ladder = GetLadder(ladderId); var mappedLadder = Mapper.Map <DTO.Ladder.Ladder>(ladder); // Fill in standings here for now mappedLadder.Standings = Mapper.Map <DTO.Ladder.LadderStanding[]>(GetStandings(ladderId, 0).ToArray()); return(mappedLadder); }
public void UpdateMapTemplates(Guid id, IEnumerable <string> mapTemplateNames) { Domain.Ladders.Ladder ladder = GetLadder(id); foreach (var mapTemplateName in mapTemplateNames) { // Ensure MapTemplates exist if (this.UnitOfWork.MapTemplateDescriptors.Get(mapTemplateName) == null) { throw new Exceptions.ApplicationException("Cannot find map template", ErrorCode.CannotFindMapTemplate); } } ladder.MapTemplates.Clear(); ladder.MapTemplates.AddRange(mapTemplateNames); this.UnitOfWork.Commit(); }
public void UpdateGameOptions(Guid id, DTO.Games.GameOptions gameOptions) { Domain.Ladders.Ladder ladder = GetLadder(id); ladder.Options.AttacksPerTurn = gameOptions.AttacksPerTurn; ladder.Options.InitialCountryUnits = gameOptions.InitialCountryUnits; ladder.Options.MapDistribution = Mapper.Map <Domain.Enums.MapDistribution>(gameOptions.MapDistribution); ladder.Options.MaximumNumberOfCards = gameOptions.MaximumNumberOfCards; ladder.Options.MinUnitsPerCountry = gameOptions.MinUnitsPerCountry; ladder.Options.MovesPerTurn = gameOptions.MovesPerTurn; ladder.Options.NewUnitsPerTurn = gameOptions.NewUnitsPerTurn; ladder.Options.TimeoutInSeconds = gameOptions.TimeoutInSeconds; ladder.Options.VictoryConditions.Clear(); ladder.Options.VictoryConditions.AddRange(Mapper.Map <IEnumerable <Domain.Enums.VictoryConditionType> >(gameOptions.VictoryConditions)); ladder.Options.VisibilityModifier.Clear(); ladder.Options.VisibilityModifier.AddRange(Mapper.Map <IEnumerable <Domain.Enums.VisibilityModifierType> >(gameOptions.VisibilityModifier)); this.UnitOfWork.Commit(); }
public void Handle(GameEndedEvent evt) { var game = evt.Game; if (game.Type == Domain.Enums.GameType.Ranking) { TraceContext.Trace("Score ranking game", () => { if (game.LadderId == null) { Log.Error().Message("Ranking game '{0}' has ended, but ladder id is empty", game.Id).Write(); return; } Domain.Ladders.Ladder ladder = this.unitOfWork.Ladders.GetById(game.LadderId.Value); // Score game this.scoringService.Score(ladder, game); this.unitOfWork.Commit(); }); } }