public async Task <IEnumerable <PlayerDetail> > GetAll() { var results = new List <PlayerDetail>(); // Has to be a better way than to re-calculate the game/player score var allPlayers = _gameDataRepository.GetAll <Player>(); var allScores = _gameDataRepository.GetAll <Score>(); foreach (var player in allPlayers) { var playerScore = allScores .Where(x => x.PlayerId == player.Id) .Sum(x => x.Points); var playerFantasy = allScores .Where(x => x.PlayerId == player.Id) .Sum(x => { // Assume that a fantasy point is incremented by 1 for every score if (x.Points >= 3) { return(5); } else if (x.Points >= 2) { return(2); } else { // Free throws are worth nothing return(0); } }); var playerDetail = new PlayerDetail { Id = player.Id, Name = player.Name, Position = player.Position, TeamId = player.TeamId, TotalPoints = playerScore, FantasyPoints = playerFantasy, }; results.Add(playerDetail); } return(await Task.FromResult(results)); }
public async Task CompleteActiveRound() { var active = await _gameRoundRepository.GetActive(); if (active == null) { throw new Exception("Нет активного раунда"); } if (!active.Start.HasValue) { throw new Exception("Раунд еще не был запущен"); } active.End = DateTime.UtcNow; active.State = GameRoundState.Archived; active.Pause = null; await _gameRoundRepository.Update(active); var gameData = await _gameDataRepository.GetAll(); var archival = new ArchivalGameRound <EncodedGameData> { Id = active.Id, Name = active.Name, Players = active.Players, Created = active.Created, Start = active.Start.Value, End = active.End.Value, Duration = active.Duration, GameData = gameData, }; await _archivalGameRoundRepository.Add(archival); }
protected override void OnStart() { _gameDataRepository.Start(); // Initialize data in a in memory repository using (var writeContext = _gameDataRepository.BeginWrite()) { InitTeamAndPlayerData(writeContext); InitGameSchedule(writeContext); } // Load all games and start the clock var allGames = _gameDataRepository.GetAll <Game>(); foreach (var game in allGames) { var activeGame = new GameMetadata(game); _games.Add(activeGame); } // _clock.AccelerationFactor = 2m; _clock.Start(); // _startableThread.Start(); }
public LanguageService(IGameDataRepository <XIVData.Model.Language> repository, IFFXIVACTPluginWrapper ffxivACTPluginWrapper, ACTConfig actConfig) { _repository = repository; _languages = MapToLanguages(_repository.GetAll().ToList()); _ffxivACTPluginWrapper = ffxivACTPluginWrapper; _actConfig = actConfig; }
public void Initialize(Language language) { var xivDataClassJobs = _repository.GetAll(); foreach (var xivDataClassJob in xivDataClassJobs) { _classJobs.Add(MapToClassJob(xivDataClassJob, language)); } }
public async Task <IEnumerable <GameDetail> > GetAll() { var allGames = _gameDataRepository.GetAll <Game>() .OrderBy(x => x.Name); // Has to be a better way than to re-calculate the game score var allScores = _gameDataRepository.GetAll <Score>(); var results = new List <GameDetail>(); foreach (var item in allGames) { var gameDetail = GetDetailFromGame(item, allScores); results.Add(gameDetail); } return(await Task.FromResult(results)); }
public void Initialize(Language language) { var xivDataItems = _itemRepository.GetAll(); var itemActions = _itemActionRepository.GetAll(); foreach (var xivDataItem in xivDataItems) { var item = MapToItem(xivDataItem, language); _items.Add(item); _itemNames.Add(item.ProperName); if (item.IsCommon) { _commonItemNames.Add(item.ProperName); } // ReSharper disable once PossibleMultipleEnumeration var itemAction = itemActions.FirstOrDefault(action => action.Id == xivDataItem.ItemAction); if (itemAction != null && itemAction.Type == GameDataConstants.MountUnlock) { _mountItemNames.Add(item.ProperName); } } if (language.Id == 3) { foreach (var item in _items) { if (!string.IsNullOrEmpty(item.SingularREP)) { item.SingularRegex = new Regex(item.SingularREP, RegexOptions.Compiled); } else { item.SingularRegex = new Regex("^NO_GERMAN_LOCALIZATION", RegexOptions.Compiled); } if (!string.IsNullOrEmpty(item.PluralREP)) { item.PluralRegex = new Regex(item.PluralREP, RegexOptions.Compiled); } else { item.PluralRegex = new Regex("^NO_GERMAN_LOCALIZATION", RegexOptions.Compiled); } } } }
public void Initialize(Language language) { var contentFinderConditionList = _repository.GetAll(); contentFinderConditionList = contentFinderConditionList.OrderBy(content => content.Name); foreach (var contentFinderCondition in contentFinderConditionList) { var inPluginZones = false; foreach (var _ in _pluginZones.Where( pluginZone => pluginZone.Id == contentFinderCondition.TerritoryType)) { inPluginZones = true; } if (!inPluginZones) { continue; } var contentName = contentFinderCondition.Localized[language.Index]?.Name; if (contentName == null || contentName.Equals(string.Empty)) { continue; } var content = new Content { Id = contentFinderCondition.Id, TerritoryTypeId = contentFinderCondition.TerritoryType, IsHighEndDuty = contentFinderCondition.HighEndDuty, Name = contentName }; _content.Add(content); if (content.IsHighEndDuty) { _highEndContent.Add(content); } } }
public async Task <IEnumerable <Score> > GetAll() { return(await Task.FromResult( _gameDataRepository.GetAll <Score>() )); }
public List <World> GetWorlds() { return(MapToWorlds(_repository.GetAll().ToList())); }
public void Initialize(Language language) { var territoryList = _territoryTypeRepository.GetAll(); foreach (var territoryType in territoryList) { PlaceName regionPlaceName; try { var regionPlaceNameKey = territoryType.RegionPlaceNameId; var regionNameValue = _placeNameRepository.Find(pn => pn.Id == territoryType.RegionPlaceNameId) .First()?.Localized[language.Index].Name; regionPlaceName = new PlaceName(regionPlaceNameKey, regionNameValue); } catch (Exception) { regionPlaceName = null; } PlaceName zonePlaceName; try { var zonePlaceNameKey = territoryType.ZonePlaceNameId; var zoneNameValue = _placeNameRepository.Find(pn => pn.Id == territoryType.ZonePlaceNameId).First() ?.Localized[language.Index].Name; zonePlaceName = new PlaceName(zonePlaceNameKey, zoneNameValue); } catch (Exception) { zonePlaceName = null; } PlaceName mapPlaceName; try { var map = _mapRepository.Find(m => m.Id == territoryType.MapId).First(); var mapPlaceNameKey = map.MapPlaceNameId; var mapPlaceNameValue = _placeNameRepository.Find(pn => pn.Id == mapPlaceNameKey).First() ?.Localized[language.Index].Name; mapPlaceName = new PlaceName(mapPlaceNameKey, mapPlaceNameValue); } catch (Exception) { mapPlaceName = null; } PlaceName territoryPlaceName; try { var territoryPlaceNameKey = territoryType.TerritoryPlaceNameId; var territoryNameValue = _placeNameRepository .Find(pn => pn.Id == territoryType.TerritoryPlaceNameId) .First()?.Localized[language.Index].Name; territoryPlaceName = new PlaceName(territoryPlaceNameKey, territoryNameValue); } catch (Exception) { territoryPlaceName = null; } var location = new Location { TerritoryTypeId = territoryType.Id, Region = regionPlaceName, Zone = zonePlaceName, Territory = territoryPlaceName, Map = mapPlaceName }; if (location.Region == null && location.Zone == null) { continue; } _locations.Add(location); } }