コード例 #1
0
 public static RiotJsTransformer.JavascriptyGame TransformGame(GameDTO game, RiotAccount account, long accountId)
 {
     RiotJsTransformer.JavascriptyPlayer championId;
     if (game == null)
     {
         return new RiotJsTransformer.JavascriptyGame()
         {
             State = "none"
         };
     }
     GameTypeConfigDTO gameTypeConfigDTO = account.GameTypeConfigs.FirstOrDefault<GameTypeConfigDTO>((GameTypeConfigDTO x) => x.Id == (double)game.GameTypeConfigId) ?? new GameTypeConfigDTO();
     List<BannedChampion> bannedChampions = game.BannedChampions ?? new List<BannedChampion>(0);
     var variable = new
     {
         TeamOne =
             from x in bannedChampions
             where x.TeamId == 100
             select x,
         TeamTwo =
             from x in bannedChampions
             where x.TeamId == 200
             select x
     };
     RiotJsTransformer.JavascriptyGame javascriptyGame = new RiotJsTransformer.JavascriptyGame()
     {
         RealmId = account.RealmId,
         MatchId = (long)game.Id,
         Name = game.Name.Trim(),
         State = GameJsApiService.GetGameState(game.GameState),
         HeroSelectState = GameJsApiService.GetGameHeroSelectState(game.GameState),
         TeamOne = RiotJsTransformer.ToTeam(accountId, variable.TeamOne, 1, game.TeamOne),
         TeamTwo = RiotJsTransformer.ToTeam(accountId, variable.TeamTwo, 2, game.TeamTwo),
         IsOwner = (game.OwnerSummary == null ? false : (long)game.OwnerSummary.AccountId == accountId),
         ConferenceJid = string.Concat(game.RoomName, ".pvp.net"),
         ConferencePassword = game.RoomPassword,
         TurnHash = RiotJsTransformer.GetTurnHash(game),
         GameTypeConfigName = gameTypeConfigDTO.Name,
         QueueName = game.QueueTypeName,
         Created = game.CreationTime,
         ExpiryTime = DateTime.UtcNow + TimeSpan.FromMilliseconds(game.ExpiryTime),
         MapId = game.MapId
     };
     RiotJsTransformer.JavascriptyGame javascriptyGame1 = javascriptyGame;
     Dictionary<string, RiotJsTransformer.JavascriptyPlayer> dictionary = (
         from x in javascriptyGame1.TeamOne.Members.Concat<RiotJsTransformer.JavascriptyPlayer>(javascriptyGame1.TeamTwo.Members)
         where x.InternalName != null
         select x).ToDictionary<RiotJsTransformer.JavascriptyPlayer, string, RiotJsTransformer.JavascriptyPlayer>((RiotJsTransformer.JavascriptyPlayer x) => x.InternalName, (RiotJsTransformer.JavascriptyPlayer x) => x);
     foreach (PlayerChampionSelectionDTO playerChampionSelection in game.PlayerChampionSelections)
     {
         if (!dictionary.TryGetValue(playerChampionSelection.SummonerInternalName, out championId))
         {
             continue;
         }
         int[] spell1Id = new int[] { (int)playerChampionSelection.Spell1Id, (int)playerChampionSelection.Spell2Id };
         championId.SpellIds = spell1Id;
         championId.ChampionId = playerChampionSelection.ChampionId;
         championId.SkinId = championId.ChampionId * 1000 + playerChampionSelection.SelectedSkinIndex;
     }
     foreach (RiotJsTransformer.JavascriptyPlayer realmId in
         from x in dictionary
         select x.Value)
     {
         realmId.RealmId = account.RealmId;
         if (!(javascriptyGame1.HeroSelectState == "post") && (!(realmId.PickState == "pending") || realmId.ChampionId <= 0))
         {
             continue;
         }
         realmId.PickState = "completed";
     }
     return javascriptyGame1;
 }
コード例 #2
0
 public static RiotJsTransformer.JavascriptyGame TransformGame(GameDTO game, RiotAccount account, long accountId)
 {
   if (game == null)
   {
     return new RiotJsTransformer.JavascriptyGame()
     {
       State = "none"
     };
   }
   else
   {
     GameTypeConfigDTO gameTypeConfigDto = Enumerable.FirstOrDefault<GameTypeConfigDTO>((IEnumerable<GameTypeConfigDTO>) account.GameTypeConfigs, (Func<GameTypeConfigDTO, bool>) (x => x.Id == (double) game.GameTypeConfigId)) ?? new GameTypeConfigDTO();
     List<BannedChampion> list = game.BannedChampions ?? new List<BannedChampion>(0);
     var fAnonymousType34 = new
     {
       TeamOne = Enumerable.Where<BannedChampion>((IEnumerable<BannedChampion>) list, (Func<BannedChampion, bool>) (x => x.TeamId == 100)),
       TeamTwo = Enumerable.Where<BannedChampion>((IEnumerable<BannedChampion>) list, (Func<BannedChampion, bool>) (x => x.TeamId == 200))
     };
     RiotJsTransformer.JavascriptyGame javascriptyGame = new RiotJsTransformer.JavascriptyGame()
     {
       RealmId = account.RealmId,
       MatchId = (long) game.Id,
       Name = game.Name.Trim(),
       State = GameJsApiService.GetGameState(game.GameState),
       HeroSelectState = GameJsApiService.GetGameHeroSelectState(game.GameState),
       TeamOne = RiotJsTransformer.ToTeam(accountId, fAnonymousType34.TeamOne, 1, (IEnumerable<IParticipant>) game.TeamOne),
       TeamTwo = RiotJsTransformer.ToTeam(accountId, fAnonymousType34.TeamTwo, 2, (IEnumerable<IParticipant>) game.TeamTwo),
       IsOwner = game.OwnerSummary != null && (long) game.OwnerSummary.AccountId == accountId,
       ConferenceJid = game.RoomName + ".pvp.net",
       ConferencePassword = game.RoomPassword,
       TurnHash = RiotJsTransformer.GetTurnHash(game),
       GameTypeConfigName = gameTypeConfigDto.Name,
       QueueName = game.QueueTypeName,
       Created = game.CreationTime,
       ExpiryTime = DateTime.UtcNow + TimeSpan.FromMilliseconds(game.ExpiryTime),
       MapId = game.MapId
     };
     Dictionary<string, RiotJsTransformer.JavascriptyPlayer> dictionary = Enumerable.ToDictionary<RiotJsTransformer.JavascriptyPlayer, string, RiotJsTransformer.JavascriptyPlayer>(Enumerable.Where<RiotJsTransformer.JavascriptyPlayer>(Enumerable.Concat<RiotJsTransformer.JavascriptyPlayer>((IEnumerable<RiotJsTransformer.JavascriptyPlayer>) javascriptyGame.TeamOne.Members, (IEnumerable<RiotJsTransformer.JavascriptyPlayer>) javascriptyGame.TeamTwo.Members), (Func<RiotJsTransformer.JavascriptyPlayer, bool>) (x => x.InternalName != null)), (Func<RiotJsTransformer.JavascriptyPlayer, string>) (x => x.InternalName), (Func<RiotJsTransformer.JavascriptyPlayer, RiotJsTransformer.JavascriptyPlayer>) (x => x));
     foreach (PlayerChampionSelectionDTO championSelectionDto in game.PlayerChampionSelections)
     {
       RiotJsTransformer.JavascriptyPlayer javascriptyPlayer;
       if (dictionary.TryGetValue(championSelectionDto.SummonerInternalName, out javascriptyPlayer))
       {
         javascriptyPlayer.SpellIds = new int[2]
         {
           (int) championSelectionDto.Spell1Id,
           (int) championSelectionDto.Spell2Id
         };
         javascriptyPlayer.ChampionId = championSelectionDto.ChampionId;
         javascriptyPlayer.SkinId = javascriptyPlayer.ChampionId * 1000 + championSelectionDto.SelectedSkinIndex;
       }
     }
     foreach (RiotJsTransformer.JavascriptyPlayer javascriptyPlayer in Enumerable.Select<KeyValuePair<string, RiotJsTransformer.JavascriptyPlayer>, RiotJsTransformer.JavascriptyPlayer>((IEnumerable<KeyValuePair<string, RiotJsTransformer.JavascriptyPlayer>>) dictionary, (Func<KeyValuePair<string, RiotJsTransformer.JavascriptyPlayer>, RiotJsTransformer.JavascriptyPlayer>) (x => x.Value)))
     {
       javascriptyPlayer.RealmId = account.RealmId;
       if (javascriptyGame.HeroSelectState == "post" || javascriptyPlayer.PickState == "pending" && javascriptyPlayer.ChampionId > 0)
         javascriptyPlayer.PickState = "completed";
     }
     return javascriptyGame;
   }
 }