예제 #1
0
		public async Task<List<PlayerStatsUpdate_2>> ParseMatch(DotaMatchInfo dotaMatchInfo,CancellationToken  token)
		{
			var playersStatsUp=new List<PlayerStatsUpdate_2>();
			var ResDpi = new ResouceDpi ();
			try{
				var players=dotaMatchInfo.Players;
				for(int i=0;i<players.Count();i++)
				{
					token.ThrowIfCancellationRequested ();
					var itemDb = new ItemDb ();
					var heroDb =new HeroDb();
					var player=players[i];
					var playerStatsUp = new PlayerStatsUpdate_2 ();
					var hero  = heroDb .GetHeroFromSQL (player.Hero_id);
					playerStatsUp.HeroImage = BitmapFactory.DecodeByteArray (hero.ImageHero, 0, hero.ImageHero.Length);
					playerStatsUp.Color = ColorsOnMatch.GetColorPlayer (i);
					playerStatsUp.HeroName = hero.LocalName;
					playerStatsUp.Hero_id = (int)player.Hero_id;
					playerStatsUp.Player_slot = i;
					playerStatsUp.Account_id = (int)player.Account_id;
					playerStatsUp.PlayerName=player.PlayerName;
					var item0 = itemDb.GetItemFromSQL (player.Item0Id);
					var item1 = itemDb.GetItemFromSQL (player.Item1Id);
					var item2 = itemDb.GetItemFromSQL (player.Item2Id);
					var item3 = itemDb.GetItemFromSQL (player.Item3Id);
					var item4 = itemDb.GetItemFromSQL (player.Item4Id);
					var item5 = itemDb.GetItemFromSQL (player.Item5Id);
					playerStatsUp.Item0 = BitmapFactory.DecodeByteArray (item0.ImageByte, 0, item0.ImageByte.Length);
					playerStatsUp.Item1 = BitmapFactory.DecodeByteArray (item1.ImageByte, 0, item1.ImageByte.Length);
					playerStatsUp.Item2 = BitmapFactory.DecodeByteArray (item2.ImageByte, 0, item2.ImageByte.Length);
					playerStatsUp.Item3 = BitmapFactory.DecodeByteArray (item3.ImageByte, 0, item3.ImageByte.Length);
					playerStatsUp.Item4 = BitmapFactory.DecodeByteArray (item4.ImageByte, 0, item4.ImageByte.Length);
					playerStatsUp.Item5 = BitmapFactory.DecodeByteArray (item5.ImageByte, 0, item5.ImageByte.Length);
					playerStatsUp.Item0Id = item0.ItemId;
					playerStatsUp.Item1Id = item1.ItemId;
					playerStatsUp.Item2Id = item2.ItemId;
					playerStatsUp.Item3Id = item3.ItemId;
					playerStatsUp.Item4Id = item4.ItemId;
					playerStatsUp.Item5Id = item5.ItemId;
					playerStatsUp.Gold = player.Gold;
					playerStatsUp.Level = player.Level;
					playerStatsUp.Assists = player.Assists;
					playerStatsUp.Death = player.Death;
					playerStatsUp.Denies = player.Denies;
					playerStatsUp.Gold_per_min = player.Gold_per_min;
					playerStatsUp.Kills = player.Kills;
					playerStatsUp.Last_hits = player.Last_hits;
					playerStatsUp.Net_worth = player.Net_worth;
					playerStatsUp.Xp_per_min = player.Xp_per_min;

					playersStatsUp.Add(playerStatsUp);
				}

			}catch{
				return playersStatsUp;
			}

			return playersStatsUp;
		}
예제 #2
0
		public async Task<DotaMatchInfo_2> ParseMatchTitle(MatchInfo matchInfo)
		{
			var dotaMatchInfo_2 = new DotaMatchInfo_2 ();
			TeamDb teamDb = new TeamDb ();
			var radiantWin=matchInfo.Winner;
			var radiantTeam= await teamDb.GetTeam(matchInfo.Team1Id,"DOTA2");
			var direTeam= await teamDb.GetTeam(matchInfo.Team2Id,"DOTA2");
			var dotaMatchInfo = matchInfo.DetailsMatch.Cast<DotaMatchInfo>().ToList();

			var duration=TimeSpan.FromSeconds(dotaMatchInfo[0].Duration);
			var id=matchInfo.MatchId;
			PicksBansOld radiantPB=new PicksBansOld();
			//var listPicksBans=radiantPB.ConvertJRecentToPickBan(jMatch.SelectToken("picks_bans"));
			var radTower=dotaMatchInfo[0].TowerStatusRadiant;
			var direTower = dotaMatchInfo[0].TowerStatusDire;
			var radBarr=dotaMatchInfo[0].BarracksStatusRadiant;
			var direBarr=dotaMatchInfo[0].BarracksStatusDire;
			var startTime=matchInfo.StartTime;
			var players=dotaMatchInfo[0].Players;
			var allRadGold = 0;
			var allDireGold = 0;
			var allRadXp = 0;
			var allDireXp = 0;
			var radiantScore=0;
			var direScore=0;
			var playersUp=new PlayerStatsUpdate_2();
			for (int i = 0; i < players.Count (); i++) {
				var player=players[i];
				var lvl =(int) player.Level;
				var deaths = (int)player.Death;
				var networth = (int)player.Net_worth;
				if(i<5) {
					direScore+=deaths;
					allRadGold += networth;
					allRadXp += GetXpLevel (lvl);
				}
				else {
					radiantScore+=deaths;
					allDireGold +=networth;
					allDireXp += GetXpLevel (lvl);
				}
			}
			dotaMatchInfo_2=new DotaMatchInfo_2(){
				Team1Win=radiantWin,
				Team1=radiantTeam,
				Team2=direTeam,
				Duration=duration,
				Team1Score=radiantScore,
				Team2Score=direScore,
				MatchId=id,
				TowerStatusRadiant=radTower,
				TowerStatusDire=direTower,
				BarracksStatusRadiant=radBarr,
				BarracksStatusDire=direBarr,
				StartTime=startTime,
				RadiantPicks=dotaMatchInfo[0].RadiantPicks,
				DirePicks=dotaMatchInfo[0].DirePicks,
				RadiantGold = allRadGold,
				DireGold = allDireGold,
				RadiantXp = allRadXp,
				DireXp = allDireXp
			};
			return dotaMatchInfo_2;
		}