public static Team ConvertTeam(ConversionInput kwargs) { var newTeam = new Team(); List <Pick> picks = new List <Pick>(); kwargs.team.ForEach(cell => { var currentAction = kwargs.actions.Where(action => !action.completed).FirstOrDefault(); var pick = new Pick(cell.cellId); var spell1 = DataDragon.Instance.GetSummonerById(cell.spell1Id); pick.spell1 = new SummonerSpell() { id = cell.spell1Id + "", icon = spell1 != null ? spell1.icon : "" }; var spell2 = DataDragon.Instance.GetSummonerById(cell.spell2Id); pick.spell2 = new SummonerSpell() { id = cell.spell2Id + "", icon = spell2 != null ? spell2.icon : "" }; var champion = DataDragon.Instance.GetChampionById(cell.championId); pick.champion = champion; var summoner = StateController.GetSummonerById(cell.summonerId); if (summoner != null) { pick.displayName = summoner.displayName; } if (currentAction != null && currentAction.type == "pick" && currentAction.actorCellId == cell.cellId && !currentAction.completed) { pick.isActive = true; newTeam.isActive = true; } picks.Add(pick); }); newTeam.picks = picks; var IsBanDetermined = false; List <Ban> bans = new List <Ban>(); kwargs.actions.Where(action => action.type == "ban" && IsInThisTeam(kwargs, action.actorCellId)).ToList().ForEach(action => { var ban = new Ban(); if (!action.completed && !IsBanDetermined) { IsBanDetermined = true; ban.isActive = true; newTeam.isActive = true; ban.champion = new Champion(); bans.Add(ban); return; } var champion = DataDragon.Instance.GetChampionById(action.championId); ban.champion = champion; bans.Add(ban); return; }); newTeam.bans = bans; return(newTeam); }
private static bool IsInThisTeam(ConversionInput kwargs, int cellId) { return(kwargs.team.Where(cell => cell.cellId == cellId).Count() != 0); }