Exemplo n.º 1
0
		public async Task<List<CSMatchInfo_2>> ParseMatchTitle(MatchInfo matchInfo)
		{
			var matchInfo_2 = new MatchInfo_2 ();
			var listMatchDetail = new List<CSMatchInfo_2> ();
			TeamDb teamDb = new TeamDb ();
			CSMapDb mapDb = new CSMapDb ();
			LeagueDb leagDb = new LeagueDb ();
			var radiantWin = matchInfo.Winner;
			var team1 = await teamDb.GetTeam (matchInfo.Team1Id, "CSGO");
			var team2 = await teamDb.GetTeam (matchInfo.Team2Id, "CSGO");
			var leag = await leagDb.GetLeague (matchInfo.LeagueId, "CSGO");

			var csMatchDetail = matchInfo.DetailsMatch.Cast<CSMatchInfo> ().ToList ();
			foreach (var match in csMatchDetail) {
				var csMatchInfo_2 = new CSMatchInfo_2 ();
				csMatchInfo_2.Team1 = team1;
				csMatchInfo_2.Team2 = team2;
				csMatchInfo_2.DeteilScoreTeam1 = match.DeteilScoreTeam1;
				csMatchInfo_2.DeteilScoreTeam2 = match.DeteilScoreTeam2;
				csMatchInfo_2.Team1Score = match.Team1Score;
				csMatchInfo_2.Team2Score = match.Team2Score;
				csMatchInfo_2.StartTime = matchInfo.StartTime;
				csMatchInfo_2.Url = matchInfo.Url;
				csMatchInfo_2.Team1Win = matchInfo.Winner;
				csMatchInfo_2.MatchLeague = leag;
				csMatchInfo_2.Map = await mapDb.GetMap(match.CSMapId);
				listMatchDetail.Add (csMatchInfo_2);
			}


			return listMatchDetail;
		}
Exemplo n.º 2
0
		public async Task<List<HSMatchInfo_2>> ParseMatchTitle(MatchInfo matchInfo)
		{
			var matchInfo_2 = new MatchInfo_2 ();
			var listMatchDetail = new List<HSMatchInfo_2> ();
			TeamDb teamDb = new TeamDb ();
			DeckOfCardsDb deck = new DeckOfCardsDb();
			LeagueDb leagDb = new LeagueDb ();
			var radiantWin = matchInfo.Winner;
			var team1 = await teamDb.GetTeam (matchInfo.Team1Id, "Hearthstone");
			var team2 = await teamDb.GetTeam (matchInfo.Team2Id, "Hearthstone");
			var leag = await leagDb.GetLeague (matchInfo.LeagueId, "Hearthstone");

			var hsMatchDetail = matchInfo.DetailsMatch.Cast<HSMatchInfo> ().ToList ();
			foreach (var match in hsMatchDetail) {
				var hsMatchInfo_2 = new HSMatchInfo_2 ();
				hsMatchInfo_2.Team1 = team1;
				hsMatchInfo_2.Team2 = team2;
				hsMatchInfo_2.Team1Score = match.Team1Score;
				hsMatchInfo_2.Team2Score = match.Team2Score;
				hsMatchInfo_2.StartTime = matchInfo.StartTime;
				hsMatchInfo_2.Url = matchInfo.Url;
				hsMatchInfo_2.Team1Win = matchInfo.Winner;
				hsMatchInfo_2.Team1Deck = await deck.GetDeckFromSQL (match.Team1Deck);
				hsMatchInfo_2.Team2Deck = await deck.GetDeckFromSQL (match.Team2Deck);
				hsMatchInfo_2.MatchLeague = leag;
				listMatchDetail.Add (hsMatchInfo_2);
			}


			return listMatchDetail;
		}
Exemplo n.º 3
0
		public async Task<List<SimpleMatchInfo_2>> ConvertToSimple2 (List<SimpleMatchInfo> sm, CancellationToken token)
		{
			TeamDb team = new TeamDb ();
			LeagueDb oleag = new LeagueDb ();
			List<SimpleMatchInfo_2> listExMatchInfo = new List<SimpleMatchInfo_2> ();
			foreach (var simpleInfo in sm) {
				token.ThrowIfCancellationRequested ();
				var team1 = await team.GetTeam (simpleInfo.Team1Id, SettingsApp.GameName);
				var team2 = await team.GetTeam (simpleInfo.Team2Id, SettingsApp.GameName);
				var league = await oleag.GetLeague (simpleInfo.LeagueId, SettingsApp.GameName);
				var exMatchInfo = new SimpleMatchInfo_2 () {
					MatchId=simpleInfo.MatchId,
					League=league,
					StartTime=simpleInfo.StartTime,
					Team1=team1,
					Team2=team2,
					MatchUrl=simpleInfo.MatchUrl,
					GameId=simpleInfo.GameId,
					MatchType=simpleInfo.MatchType
				};
				listExMatchInfo.Add (exMatchInfo);
			}
			return listExMatchInfo;
		}
Exemplo n.º 4
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;
		}
Exemplo n.º 5
0
		protected override async void OnCreate (Bundle bundle)
		{
			//Window.RequestFeature(WindowFeatures.NoTitle);
			try{

				base.OnCreate (bundle);
				SetContentView (Resource.Layout.PicksLayout);
				pb = FindViewById<ProgressBar> (Resource.Id.progressBar3);
				ActionBarTitle.SetTitle (this,Resource.Layout.ActionBarLayout,Resources.GetString(Resource.String.capitanMod),"DOTA 2");
				buttonRefresh=FindViewById<Button>(Resource.Id.buttonRefreshActionBar);
				buttonRefresh.Click+=ButtonRefreshClick;
				buttonRefresh.Visibility=ViewStates.Invisible;
				var buttonBack=FindViewById<Button>(Resource.Id.buttonBackActionBar);
				buttonBack.Click+=ButtonBackClick;
				pb=FindViewById<ProgressBar> (Resource.Id.progressBar3);
				pb.Visibility= ViewStates.Visible;
				APIRequest ApiReq = new APIRequest ();
				PicksBansOld pickBans=new PicksBansOld();
				Player playerReq=new Player();
				gameInfo=Intent.GetStringExtra("matchDetail");
				var jDetailMatchInfo= JsonConvert.DeserializeObject<JDetailMatchInfo>(gameInfo);
				var jMatchDetails=JToken.Parse(jDetailMatchInfo.JMatchDetails);
				matchInfo=JsonConvert.DeserializeObject<MatchInfo>(jMatchDetails.ToString());
				dotaMatchInfo=JsonConvert.DeserializeObject<List<DotaMatchInfo>>(jMatchDetails.SelectToken("DetailsMatch").ToString());
				List<DetailInfo> listDetail=new List<DetailInfo>();
				listDetail.AddRange(dotaMatchInfo);
				matchInfo.DetailsMatch=listDetail;

				liveFlag=Intent.GetStringExtra("liveFlag");
				title=Intent.GetStringExtra("title");



			TextView radiantName, direName,textRadiant,textDire;
			ImageView radiantLogo, direLogo;
			LinearLayout llradiantTeam, lldireTeam;
				radiantName=FindViewById<TextView>(Resource.Id.radiantTeamName);
				direName=FindViewById<TextView>(Resource.Id.direTeamName);
				radiantLogo=FindViewById<ImageView>(Resource.Id.logoRadiantTeam);
				direLogo=FindViewById<ImageView>(Resource.Id.logoDireTeam);
				llradiantTeam=FindViewById<LinearLayout>(Resource.Id.llradiantTeam);
				lldireTeam=FindViewById<LinearLayout>(Resource.Id.lldireTeam);
					textRadiant=FindViewById<TextView>(Resource.Id.textTeamFP);
					textDire=FindViewById<TextView>(Resource.Id.textTeamSP);

				var analisPick=new AnalysisPick();
				var value=analisPick.GetAnalysisTeam(dotaMatchInfo[0].RadiantPicks.ListPicks,dotaMatchInfo[0].DirePicks.ListPicks);
				textRadiant.Text=Resources.GetString(Resource.String.radiant)+"  "+value[0].ToString();
				textDire.Text=Resources.GetString(Resource.String.dire)+"  "+(value[1].ToString());
				textRadiant.SetTextAppearance(this,Resource.Style.RadiantName);
				textDire.SetTextAppearance(this,Resource.Style.DireName);

				TeamDb teamDb=new TeamDb();
				var radiantTeam= await teamDb.GetTeam(matchInfo.Team1Id,"DOTA2");
				var direTeam= await teamDb.GetTeam(matchInfo.Team2Id,"DOTA2");
				if(radiantTeam != null){
					radiantName.Text=radiantTeam.Name;
					if(radiantTeam.LogoByte!=null){
						Bitmap bmp1= BitmapFactory.DecodeByteArray (radiantTeam.LogoByte, 0, radiantTeam.LogoByte.Length);
						radiantLogo.SetImageBitmap(bmp1);
					}
				}
				if(direTeam != null){
					direName.Text=direTeam.Name;
					if(direTeam.LogoByte!=null){
						Bitmap bmp2= BitmapFactory.DecodeByteArray (direTeam.LogoByte, 0, direTeam.LogoByte.Length);
						direLogo.SetImageBitmap(bmp2);
					}
				}
				var bluePlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer1);
				var cyanPlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer2);
				var purpurePlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer3);
				var yellowPlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer4);
				var orangePlayer=llradiantTeam.FindViewById<TextView>(Resource.Id.textPlayer5);
			 
			var pinkPlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer1);
			var olivePlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer2);
			var aquaPlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer3);
			var darkgreenPlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer4);
			var chokolatePlayer=lldireTeam.FindViewById<TextView>(Resource.Id.textPlayer5);
				var listTextView = new List<TextView> (){bluePlayer,cyanPlayer,purpurePlayer,yellowPlayer,orangePlayer,
				pinkPlayer,olivePlayer,aquaPlayer,darkgreenPlayer,chokolatePlayer};
			
				var allPlayerInfo = dotaMatchInfo[0].Players;
			for (var i = 0; i < allPlayerInfo.Count(); i++) {
					int color=ColorsOnMatch.GetColorPlayer(i);
				listTextView [i].Text = allPlayerInfo [i].PlayerName;
				listTextView[i].SetTextColor(Resources.GetColor(color));
			}
				radiantPB = pickBans.ParseJsonToRadPick (dotaMatchInfo[0].RadiantPicks);
				direPB = pickBans.ParseJsonToDirePick (dotaMatchInfo[0].DirePicks);
				cts=new CancellationTokenSource();
				cts.Token.ThrowIfCancellationRequested ();
				await SetHeroesImageInLayout (cts.Token);
				cts = null;
			}
			catch(Exception e){
				Console.WriteLine (e);
			}
			pb.Visibility= ViewStates.Gone;
			buttonRefresh.Visibility = ViewStates.Visible;
		}