Exemple #1
0
        private void button8_Click(object sender, EventArgs e)
        {
            match match = new match();

            match.Show();
            match.TopMost = true;
        }
    public void clicked()
    {
        if (!Global.inQueue) // checks if already in queue somehow
        {
            // sends serve request to put user in matchmaking queue
            match  user = new match("enterQueue", Global.getID(), Global.getToken());
            string json = JsonConvert.SerializeObject(user);
            Byte[] data = System.Text.Encoding.ASCII.GetBytes(json);
            Global.stream.Write(data, 0, data.Length);
            data = new Byte[256];

            string responseData = string.Empty;
            Int32  bytes        = Global.stream.Read(data, 0, data.Length);
            responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
            if (String.Equals(responseData, "added to queue"))
            {
                Global.inQueue = true;
                SceneManager.LoadScene(8);
            }
            else
            {
                Debug.Log(responseData);
            }
        }
    }
Exemple #3
0
        public async Task <ActionResult> Create([Bind(Include = "matchID,teamA,teamB,stadium,league,date")] match match)
        {
            string result = "";

            if (ModelState.IsValid)
            {
                match dbMatch = await db.matches.FindAsync(match.matchID);

                if (dbMatch == null)
                {
                    db.matches.Add(match);
                    await db.SaveChangesAsync();

                    result = "true";
                }
                else
                {
                    result = "false";
                }
            }

            ViewBag.teamA = new SelectList(db.teams, "teamName", "teamName", match.teamA);
            ViewBag.teamB = new SelectList(db.teams, "teamName", "teamName", match.teamB);
            //return View(match);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        //Handles team manager create match
        public int managerCreateMatch([FromBody] match nMatch, int teamId)
        {
            var cs      = Services.ContentService;
            int matchId = new int();

            var matchName = "Kamp mod: " + nMatch.enemyTeam;

            var match = cs.GetChildren(teamId);

            try
            {
                var newMatch = cs.CreateContent(matchName, teamId, "match");

                newMatch.SetValue("enemyTeam", nMatch.enemyTeam);
                newMatch.SetValue("matchLocation", nMatch.matchLocation);
                newMatch.SetValue("matchDate", nMatch.matchTime);

                cs.SaveAndPublishWithStatus(newMatch);
                matchId = newMatch.Id;
            }
            catch
            {
                matchId = 0;
            }

            return(matchId);
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "id,start_time,map,result,is_broadcasted,is_registration_open,fk_first_team,fk_second_team,fk_tournament,fk_place,fk_betting,fk_ticket")] match match)
        {
            int d;

            if (ModelState.IsValid)
            {
                if (Session["TournamentId"] != null)
                {
                    match.fk_tournament = (int)Session["TournamentId"];
                    d = (int)Session["TournamentId"];
                    Session.Remove("TounamentId");
                    db.matches.Add(match);
                    db.SaveChanges();
                    return(RedirectToAction("Details", "Tournaments", new { id = d }));
                }
                else
                {
                    return(HttpNotFound());
                }
            }

            ViewBag.fk_betting     = new SelectList(db.bettings, "id", "id", match.fk_betting);
            ViewBag.fk_tournament  = new SelectList(db.tournaments, "id", "name", match.fk_tournament);
            ViewBag.fk_ticket      = new SelectList(db.tickets, "id", "description", match.fk_ticket);
            ViewBag.fk_place       = new SelectList(db.places, "id", "id", match.fk_place);
            ViewBag.fk_ticket      = new SelectList(db.tickets, "id", "description", match.fk_ticket);
            ViewBag.fk_first_team  = new SelectList(db.teams, "id", "name", match.fk_first_team);
            ViewBag.fk_second_team = new SelectList(db.teams, "id", "name", match.fk_second_team);
            return(View(match));
        }
Exemple #6
0
        public PlayersFromMatch(match m)
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();

            match = m;
        }
        public ActionResult Create(match match)
        {
            if (ModelState.IsValid)
            {
                var dao = new match_dao();

                string errorMessage = "";
                var    result       = dao.Insert(ref errorMessage, match);

                if (result == 1)
                {
                    SetAlert(StaticResources.Resources.Pub_InsertSuccess, "success");
                    return(RedirectToAction("Index", "Match", new { season_id = match.season_id, round_id = match.round_id }));
                }
                else if (result == -2)
                {
                    ModelState.AddModelError("", errorMessage);
                }
                else if (result == -3)
                {
                    ModelState.AddModelError("", errorMessage);
                }
                else
                {
                    ModelState.AddModelError("", StaticResources.Resources.InsertMatchFailed);
                }
            }
            SetListClub(match.home_club, match.guest_club, match.season_id);
            SetListRound(match.round_id);
            SetListSeason(match.season_id);
            return(View());
        }
        public ManOfTheMatch(match cMatch)
        {
            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();

            match = cMatch;
        }
Exemple #9
0
        public static int GetTodaysMatches(MatchType mt)
        {
            var    api         = new APIService(Settings.MatchStatsAPIMatches);
            string jsonMatches = api.GetResponse();

            try
            {
                JObject        csgostatsMatches = JObject.Parse(jsonMatches);
                IList <JToken> results          = csgostatsMatches[mt.ToString().ToLower()].Children().ToList();

                // Serialize
                IList <CSGOStatsMatch> matches =
                    results.Select(result => JsonConvert.DeserializeObject <CSGOStatsMatch>(result.ToString())).ToList();

                foreach (CSGOStatsMatch m in matches)
                {
                    match matchEntity = DBService.GetOrCreateMatch(m.CSGOlid, m.Time, m.Team1, m.Team2, m.Winner);
                }
            }
            catch
            {
                return(0);
            }

            return(1);
        }
Exemple #10
0
    void Start()
    {
        matchobj = GameObject.Find("match");
        match m = matchobj.GetComponent <match>();

        m.main();
    }
        public async Task <ActionResult> Buy(int id)
        {
            match temp = await db.matches.FindAsync(id);

            List <ticket> tickets = temp.tickets.ToList();

            return(View(tickets.ToList()));
        }
Exemple #12
0
 public WrapMatch(match match)
 {
     Match = match ?? new match();
     if (match != null)
     {
         LoadData();
     }
 }
 public void CreateMatch(match match)
 {
     using (var db = new fightClubEntities())
     {
         db.match.Add(match);
         db.SaveChanges();
     }
 }
Exemple #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            match match = db.matches.Find(id);

            db.matches.Remove(match);
            db.SaveChanges();
            return(RedirectToAction("Index", "Tournaments"));
        }
Exemple #15
0
        public MatchWebResponse(match m, int team1Id, int team2Id)
        {
            this.Id = m.id;

            var result1 = m.results.FirstOrDefault(x => x.teamId == team1Id);
            var result2 = m.results.FirstOrDefault(x => x.teamId == team2Id);

            this.Result1 = result1 == null ? null : new ResultWebResponse(result1);
            this.Result2 = result2 == null ? null : new ResultWebResponse(result2);
        }
Exemple #16
0
        public static Match GetDetails(int id)
        {
            var apiCallTask = ApiHelper.Get(id);
            var result      = apiCallTask.Result;

            JObject jsonResponse = JsonConvert.DeserializeObject <JObject>(result);
            match   match        = JsonConvert.DeserializeObject <Match>(jsonResponse.ToString());

            return(match);
        }
Exemple #17
0
        public ActionResult Delete(int id, match match)
        {
            if (ModelState.IsValid)

            {
                match = service.GetById(id);
                service.delete(match);
                service.Commit();
            }
            return(RedirectToAction("Index"));
        }
Exemple #18
0
        private static void updateELOs(match currentMatch, double redChancetoWin, bool didRedWin)
        {
            double blueELODelta = 0;
            double redELODelta  = 0;

            if (redChancetoWin >= 50 && didRedWin) //blue was expected to lose, and did lose
            {
                blueELODelta = 32 * (0 - ((100 - redChancetoWin) / 100));
                redELODelta  = 32 * (1 - (redChancetoWin / 100));
            }
            else if (redChancetoWin >= 50 && !didRedWin) // blue was expected to lose, but won
            {
                redELODelta  = 32 * (0 - (redChancetoWin / 100));
                blueELODelta = 32 * (1 - ((100 - redChancetoWin) / 100));
            }
            else if (redChancetoWin <= 50 && didRedWin) //red was expected to lose, but won
            {
                redELODelta  = 32 * (1 - ((100 - redChancetoWin) / 100));
                blueELODelta = 32 * (0 - (redChancetoWin / 100));
            }
            else if (redChancetoWin <= 50 && !didRedWin) // red was expected to lose, and did lose
            {
                redELODelta  = 32 * (0 - (redChancetoWin / 100));
                blueELODelta = 32 * (1 - ((100 - redChancetoWin) / 100));
            }

            if (currentMatch.blueTeam.Count() > 1)
            {
                currentMatch.blueTeam[0].eloDelta = blueELODelta;
                currentMatch.blueTeam[1].eloDelta = blueELODelta;
                currentMatch.blueTeam[0].updateELO(mySqlCon);
                currentMatch.blueTeam[1].updateELO(mySqlCon);
            }
            else
            {
                currentMatch.blueTeam[0].eloDelta = blueELODelta;
                currentMatch.blueTeam[0].updateELO(mySqlCon);
            }

            if (currentMatch.redTeam.Count() > 1)
            {
                currentMatch.redTeam[0].eloDelta = redELODelta;
                currentMatch.redTeam[1].eloDelta = redELODelta;
                currentMatch.redTeam[0].updateELO(mySqlCon);
                currentMatch.redTeam[1].updateELO(mySqlCon);
            }
            else
            {
                currentMatch.redTeam[0].eloDelta = redELODelta;
                currentMatch.redTeam[0].updateELO(mySqlCon);
            }
        }
 public void UpdateMatch(match match)
 {
     using (var db = new fightClubEntities())
     {
         var oldMatch = db.match.Single(a => a.id == match.id);
         if (oldMatch == null)
         {
             throw new Exception("not found");
         }
         db.Entry(oldMatch).CurrentValues.SetValues(match);
         db.SaveChanges();
     }
 }
Exemple #20
0
 protected override void OnParameterChanged(object parameter)
 {
     if (parameter is WrapTeam)
     {
         wrapTeam      = parameter as WrapTeam;
         TeamName      = wrapTeam.Team.Name;
         Introduce     = wrapTeam.Team.Introduce;
         TeacherName   = wrapTeam.Teacher.Name;
         TeamLeader    = wrapTeam.Team.TeamLeader;
         TeamMembers   = wrapTeam.Team.TeamMembers;
         SelectedMatch = wrapTeam.Match;
     }
 }
Exemple #21
0
        public IHttpActionResult UpdateMatch([FromBody] MatchDTO matchDTO)
        {
            match matchMap = AutoMapper.Mapper.Map <MatchDTO, match>(matchDTO);
            match _match;

            using (var context = new escorcenterdbEntities())
            {
                _match = (from m in context.matches where m.Id == matchMap.Id select m).FirstOrDefault();
                _match = matchMap;
                context.SaveChanges();
            }
            return(Ok(_match));
        }
        public async Task <ActionResult> Create(int matchID, int seatNumber, int cost, string seatType, string amount)
        {
            string result = "";

            if (ModelState.IsValid)
            {
                int   quanity   = Int32.Parse(amount);
                int[] ticketsID = new int[quanity];
                int   counter   = 0;
                for (int i = 0; counter < quanity; i++)
                {
                    ticket temp = new ticket();
                    temp = await db.tickets.FindAsync(i);

                    if (temp == null)
                    {
                        ticketsID[counter] = i;
                        counter++;
                    }
                }
                match tempMatch = await db.matches.FindAsync(matchID);

                IList <ticket> ticketsToMatch  = tempMatch.tickets.ToList();
                int            seatNumberIndex = seatNumber;
                for (int j = 0; j < quanity; j++)
                {
                    ticket ticket = new ticket();
                    ticket.matchID    = tempMatch.matchID;
                    ticket.cost       = cost;
                    ticket.seatType   = seatType;
                    ticket.seatNumber = seatNumberIndex;
                    for (int k = 0; k < ticketsToMatch.Count; k++)
                    {
                        if (ticketsToMatch.ElementAt(k).seatNumber == ticket.seatNumber)
                        {
                            ticket.seatNumber++;
                            seatNumberIndex++;
                            k--;
                        }
                    }
                    seatNumberIndex++;
                    ticket.ticketID = ticketsID[j];
                    db.tickets.Add(ticket);
                    await db.SaveChangesAsync();
                }
                await db.SaveChangesAsync();

                result = "true";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #23
0
 private result CreateNewResult(match parentMatch, int teamId, ResultWebResponse clientResult, year year, int priorHandicap)
 {
     return(new result
     {
         match = parentMatch,
         score = clientResult.Score,
         points = clientResult.Points,
         scoreVariant = clientResult.EquitableScore,
         priorHandicap = priorHandicap,
         teamId = teamId,
         year = year,
         playerId = clientResult.PlayerId.Value
     });
 }
Exemple #24
0
        // GET: Matches/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            match match = db.matches.Find(id);

            if (match == null)
            {
                return(HttpNotFound());
            }
            return(View(match));
        }
Exemple #25
0
        public IHttpActionResult CreateMatch(MatchDTO _match)
        {
            int   weekId = WeeksApiController.getWeekId(_match.Id);
            match m      = new match {
                date = DateTime.Parse(_match.Date), details = _match.Details, enabled = true, field = (int)_match.Field.Id, scoreTeam1 = (sbyte)_match.ScoreTeam1, scoreTeam2 = (sbyte)_match.ScoreTeam2, team1 = (int)_match.Team1.Id, team2 = (int)_match.Team2.Id, week = weekId
            };

            using (var context = new escorcenterdbEntities())
            {
                context.matches.Add(m);
                context.SaveChanges();
            }
            return(Ok(m));
        }
Exemple #26
0
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            match match = await db.matches.FindAsync(id);

            if (match == null)
            {
                return(HttpNotFound());
            }
            return(View(match));
        }
Exemple #27
0
        public ActionResult Edit(int id, match matchmodel)
        {
            match c = service.GetById(id);

            // c.SubCategoryId
            c.player1   = matchmodel.player1;
            c.player2   = matchmodel.player2;
            c.dateMatch = matchmodel.dateMatch;
            c.idComp    = matchmodel.idComp;


            service.update(c);
            service.Commit();
            return(RedirectToAction("Index"));
        }
Exemple #28
0
        private match generate_match(List <team> teams, int index1, int index2) //Match generator
        {
            match new_match = new match();                                      //Generate the new match object

            new_match.team1 = teams[index1];                                    //Assign the first team
            new_match.team2 = teams[index2];                                    //Assign the second team
            Label match_label = new Label();                                    //Create a new label for the match

            match_label.Width    = 210;
            match_label.Location = new Point(433, 38 + (25 * team_data.matches.Count)); //Set the location
            match_label.Text     = $"{new_match.team1.name} v. {new_match.team2.name}"; //Set the text to show the two teams
            this.Controls.Add(match_label);                                             //Display on screen
            new_match.label = match_label;                                              //Assign this label to the team object
            return(new_match);
        }
Exemple #29
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            {
                using (DataClasses1DataContext db = new DataClasses1DataContext())
                {
                    try
                    {
                        var match = new match();
                        match.match_id           = Convert.ToInt32(TextBox1.Text);
                        match.stadium_id         = Convert.ToInt32(TextBox2.Text);
                        match.team1_id           = Convert.ToInt32(TextBox3.Text);
                        match.team2_id           = Convert.ToInt32(TextBox5.Text);
                        match.season_id          = Convert.ToInt32(TextBox6.Text);
                        match.match_date         = Convert.ToDateTime(TextBox7.Text);
                        match.id_referee         = Convert.ToInt32(TextBox8.Text);
                        match.id_assist_referee1 = Convert.ToInt32(TextBox9.Text);
                        match.id_assist_referee2 = Convert.ToInt32(TextBox10.Text);
                        if (CheckBox1.Checked)
                        {
                            match.stage = 'G';
                        }
                        else if (CheckBox2.Checked)
                        {
                            match.stage = 'R';
                        }
                        else if (CheckBox3.Checked)
                        {
                            match.stage = 'Q';
                        }

                        else if (CheckBox4.Checked)
                        {
                            match.stage = 'F';
                        }

                        db.matches.InsertOnSubmit(match);
                        db.SubmitChanges();

                        BindGridView();
                    }

                    catch (System.Exception excep)
                    {
                        ch_();
                    }
                }
            }
        }
Exemple #30
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            match match = await db.matches.FindAsync(id);

            if (match == null)
            {
                return(HttpNotFound());
            }
            ViewBag.teamA = new SelectList(db.teams, "teamName", "teamName", match.teamA);
            ViewBag.teamB = new SelectList(db.teams, "teamName", "teamName", match.teamB);
            return(View(match));
        }
Exemple #31
0
        public void AddMatch(string mdbCol, string sqlCol, string sqlType, int flag)
        {
            match m = new match();
            m.mdbCol = mdbCol;
            m.sqlCol = sqlCol;
            m.sqlType = sqlType;
            m.flag = flag;

            //开始添加新列
            if (flag == 2)
            {
                this.mdbDao.DoMdbUpdate("alter table [" + mdbTbl + "] add ["
                    + mdbCol + "] " + sqlType + ";");
                m.flag = 0; //非连接键
            }

            mats.Add(m);
        }
Exemple #32
0
        private void MatchSync(int EventId)
        {
            StatusChange("Syncing Matches");

            var TeamsListUpdated = new Dictionary<string, team>();
            var lst = matchRepo.GetMatchesByEvent(EventId);
            string LastSeries = "";
            int gameInSeriesCount = 0;
            int gameCount = 0;
            int SeriesCount = 1;
            StatusChange("There are " + MatchList.Count().ToString()  + " matches to syncronize");

            foreach (DateTime matchDateTime in MatchList.Keys)
            {

                string sGameUid = "";
                if ((gameCount > 0) && (gameCount % 20 == 0)) StatusChange("Processed match " + gameCount.ToString() + " out of " + MatchList.Count().ToString());
                gameInSeriesCount++;
                gameCount++;
                LsrXlsMatchData matchData = MatchList[matchDateTime];
                match foundMatch = new match();
                if (LastSeries.Length == 0) LastSeries = matchData.SeriesName;
                if (!LastSeries.Equals(matchData.SeriesName)) gameInSeriesCount = 1;
                bool found = false;

                if (lst.Count() > 0)
                {
                    found = (lst.Any(x => x.scheduled.Equals(matchDateTime)));
                }
                if (!found)
                {
                    var newMatch = new match();
                    newMatch.lsevent_id = EventId;
                    newMatch.scheduled = matchDateTime;
                    var SeriesNameOnlyCapitalLetters = new String(matchData.SeriesName.Where(c => Char.IsLetter(c) && Char.IsUpper(c)).ToArray());
                    if (SeriesNameOnlyCapitalLetters.Length == 0)
                    {
                        sGameUid = "SE" + SeriesCount.ToString().PadLeft(2) + "MA" + gameInSeriesCount.ToString().PadLeft(2, '0');
                    }
                    else
                    {
                        sGameUid = SeriesNameOnlyCapitalLetters + gameInSeriesCount.ToString().PadLeft(2, '0');
                    }
                    newMatch.guid = sGameUid;
                    if (SeriesList.ContainsKey(matchData.SeriesName))
                    {
                        var oSeries = SeriesList[matchData.SeriesName];
                        newMatch.series_id = oSeries.id;
                    }
                    foundMatch = matchRepo.Insert(newMatch);
                }
                else
                {
                    foundMatch = (lst.First(x => x.scheduled.Equals(matchDateTime)));
                }
                if (foundMatch != null)
                {
                    MatchList[matchDateTime].MatchObject = foundMatch;
                    foreach (var teamDataInMatch in matchData.TeamData)
                    {
                        team teamInMatch = TeamList[teamDataInMatch.Key];
                        match_team matchTeam = matchTeamsRepo.GetMatchTeam(foundMatch.id, teamInMatch.id);
                        if (matchTeam == null)
                        {
                            match_team newMatchTeam = new match_team() { match_id = foundMatch.id, team_id = teamInMatch.id};
                            if (teamDataInMatch.Value.TeamScore!=null) {
                                newMatchTeam.score_override = teamDataInMatch.Value.TeamScore;
                            }
                            if (teamDataInMatch.Value.PackSet != null)
                            {
                                packset packSet = PackSetList[teamDataInMatch.Value.PackSet];
                                newMatchTeam.packset_id = packSet.id;
                            }
                            matchTeamsRepo.Insert(newMatchTeam);
                        }
                        else
                        {
                            if (teamDataInMatch.Value.TeamScore != null)
                            {
                                matchTeam.score_override = teamDataInMatch.Value.TeamScore;
                            }
                            if (teamDataInMatch.Value.PackSet != null)
                            {
                                packset packSet = PackSetList[teamDataInMatch.Value.PackSet];
                                matchTeam.packset_id = packSet.id;
                            }
                            matchTeamsRepo.Update(matchTeam);
                        }
                    }
                }
                if (!LastSeries.Equals(matchData.SeriesName))
                {
                    LastSeries = matchData.SeriesName;
                    SeriesCount++;
                }
            }
            //this.TeamList = TeamsListUpdated;
        }
Exemple #33
0
 public match_list(match empty_match) {
     this.empty_match = empty_match;
 }
Exemple #34
0
 public void insert(int insert_idx, match m) {
     lock(this)
         matches_.Insert(insert_idx, m);
 }
Exemple #35
0
            public int index_of(match m) {
                if (m.line_idx < 0)
                    // it's the empty match
                    return -1;

                lock (this) {
                    //return matches_.IndexOf(m);
                    int idx = matches_.binary_search_closest(x => reverse_order ? -x.line_idx : x.line_idx, reverse_order ? -m.line_idx : m.line_idx).Item2;
                    // 1.6.10 - this seems to generate a lot of asserts for event viewer, even though logically the code is correct
                    //          I will take a look at a later time
                    //if ( idx >= 0 && !reverse_order)
                      //  Debug.Assert(matches_[idx] == m);
                    return idx;
                }
            }
Exemple #36
0
    public string getMatch(string id, string server, string playerId)
    {
        match _match = new match();

        string matchListDetailUrl = "http://lolbox.duowan.com/matchList/ajaxMatchDetail2.php?matchId=" + id + "&serverName=" + server + "&playerName=" + playerId;
        var getMatchHistoryDetailWeb = new HtmlWeb();
        var MatchDetaildoc = getMatchHistoryDetailWeb.Load(matchListDetailUrl);
        IEnumerable<HtmlNode> headerNodes = MatchDetaildoc.DocumentNode.Descendants().Where(x => x.Name == "div" && x.Attributes.Contains("class")
            && x.Attributes["class"].Value.Split().Contains("r-top"));
        foreach (HtmlNode child in headerNodes)
        {
            string mode = "";
            string duration = "";
            string endTime = "";
            string kills = "";
            string gold = "";
            foreach (HtmlNode spanNode in child.SelectNodes("span"))
            {
                if (spanNode.InnerText.Contains("类型"))
                {
                    mode = spanNode.InnerText.Replace("类型:", "");
                }
                if (spanNode.InnerText.Contains("时长"))
                {
                    duration = spanNode.InnerText.Replace("时长:", "");
                }
                if (spanNode.InnerText.Contains("结束"))
                {
                    endTime = spanNode.InnerText.Replace("结束:", "");
                }
                if (spanNode.InnerText.Contains("人头"))
                {
                    kills = spanNode.InnerText.Replace("人头:", "");
                }
                if (spanNode.InnerText.Contains("金钱"))
                {
                    gold = spanNode.InnerText.Replace("金钱:", "");
                }
            }
            _match.mode = mode;
            _match.duration = duration;
            _match.endTime = endTime;
            _match.kills = kills;
            _match.gold = gold;
        }

        _match.match_details_win = new List<matchDetails>();
        IEnumerable<HtmlNode> tableADivNodes = MatchDetaildoc.DocumentNode.Descendants().Where(x => x.Name == "div" && x.Attributes.Contains("id")
            && x.Attributes["id"].Value.Split().Contains("zj-table--A"));
        foreach (HtmlNode child in tableADivNodes)
        {
            IEnumerable<HtmlNode> tableNodes = child.Descendants().Where(x => x.Name == "table");
            foreach (HtmlNode table in tableNodes)
            {
                foreach (HtmlNode row in table.SelectNodes("tr"))
                {
                    string player = "";
                    string gold = "";
                    string KDA = "";
                    string itemIcon1 = "";
                    string itemName1 = "";
                    string itemDescription1 = "";
                    string itemIcon2 = "";
                    string itemName2 = "";
                    string itemDescription2 = "";
                    string itemIcon3 = "";
                    string itemName3 = "";
                    string itemDescription3 = "";
                    string itemIcon4 = "";
                    string itemName4 = "";
                    string itemDescription4 = "";
                    string itemIcon5 = "";
                    string itemName5 = "";
                    string itemDescription5 = "";
                    string itemIcon6 = "";
                    string itemName6 = "";
                    string itemDescription6 = "";
                    string itemIcon7 = "";
                    string itemName7 = "";
                    string itemDescription7 = "";
                    HtmlNode teamNameDivNode = row.SelectSingleNode("td[@class='col1']").SelectSingleNode("div");
                    HtmlNode playerNode = teamNameDivNode.SelectSingleNode("span[@class='avatar']").SelectSingleNode("img");
                    player = playerNode.Attributes["data-playername"].Value;
                    HtmlNodeCollection honourNodes = teamNameDivNode.SelectNodes("em");
                    HtmlNode goldNode = row.SelectSingleNode("td[@class='col2']");
                    gold = goldNode.InnerText;
                    HtmlNode KDANode = row.SelectSingleNode("td[@class='col3']");
                    KDA = KDANode.InnerText;
                    HtmlNode itemNode = row.SelectSingleNode("td[@class='col4']").SelectSingleNode("div[@class='u-weapon']").SelectSingleNode("ul[@class='chuzhuang']");
                    HtmlNodeCollection itemNodes = itemNode.SelectNodes("li");
                    foreach (HtmlNode node in itemNodes)
                    {
                        if (itemNodes.Count > 0)
                        {
                            itemIcon1 = Regex.Match(itemNodes[0].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName1 = Regex.Match(itemNodes[0].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription1 = itemNodes[0].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 1)
                        {
                            itemIcon2 = Regex.Match(itemNodes[1].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName2 = Regex.Match(itemNodes[1].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription2 = itemNodes[1].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 2)
                        {
                            itemIcon3 = Regex.Match(itemNodes[2].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName3 = Regex.Match(itemNodes[2].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription3 = itemNodes[2].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 3)
                        {
                            itemIcon4 = Regex.Match(itemNodes[3].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName4 = Regex.Match(itemNodes[3].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription4 = itemNodes[3].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 4)
                        {
                            itemIcon5 = Regex.Match(itemNodes[4].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName5 = Regex.Match(itemNodes[4].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription5 = itemNodes[4].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 5)
                        {
                            itemIcon6 = Regex.Match(itemNodes[5].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName6 = Regex.Match(itemNodes[5].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription6 = itemNodes[5].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 6)
                        {
                            itemIcon7 = Regex.Match(itemNodes[6].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName7 = Regex.Match(itemNodes[6].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription7 = itemNodes[6].SelectSingleNode("img").Attributes["title"].Value;
                        }
                    }
                    List<items> _itemA = new List<items>();
                    _itemA.Add(new items
                    {
                        playerId = player,
                        matchId = id,
                        itemIcon1 = itemIcon1,
                        itemName1 = itemName1,
                        itemDesc1 = itemDescription1,
                        itemIcon2 = itemIcon2,
                        itemName2 = itemName2,
                        itemDesc2 = itemDescription2,
                        itemIcon3 = itemIcon3,
                        itemName3 = itemName3,
                        itemDesc3 = itemDescription3,
                        itemIcon4 = itemIcon4,
                        itemName4 = itemName4,
                        itemDesc4 = itemDescription4,
                        itemIcon5 = itemIcon5,
                        itemName5 = itemName5,
                        itemDesc5 = itemDescription5,
                        itemIcon6 = itemIcon6,
                        itemName6 = itemName6,
                        itemDesc6 = itemDescription6,
                        itemIcon7 = itemIcon7,
                        itemName7 = itemName7,
                        itemDesc7 = itemDescription7
                    });
                    _match.match_details_win.Add(new matchDetails
                    {
                        playerId = player,
                        matchId = id,
                        gold = gold,
                        KDA = KDA,
                        items_list = _itemA
                    });
                }
            }
        }

        _match.match_details_lost = new List<matchDetails>();
        IEnumerable<HtmlNode> tableBDivNodes = MatchDetaildoc.DocumentNode.Descendants().Where(x => x.Name == "div" && x.Attributes.Contains("id")
            && x.Attributes["id"].Value.Split().Contains("zj-table--B"));
        foreach (HtmlNode child in tableBDivNodes)
        {
            IEnumerable<HtmlNode> tableNodes = child.Descendants().Where(x => x.Name == "table");
            foreach (HtmlNode table in tableNodes)
            {
                foreach (HtmlNode row in table.SelectNodes("tr"))
                {
                    string player = "";
                    string gold = "";
                    string KDA = "";
                    string itemIcon1 = "";
                    string itemName1 = "";
                    string itemDescription1 = "";
                    string itemIcon2 = "";
                    string itemName2 = "";
                    string itemDescription2 = "";
                    string itemIcon3 = "";
                    string itemName3 = "";
                    string itemDescription3 = "";
                    string itemIcon4 = "";
                    string itemName4 = "";
                    string itemDescription4 = "";
                    string itemIcon5 = "";
                    string itemName5 = "";
                    string itemDescription5 = "";
                    string itemIcon6 = "";
                    string itemName6 = "";
                    string itemDescription6 = "";
                    string itemIcon7 = "";
                    string itemName7 = "";
                    string itemDescription7 = "";
                    HtmlNode teamNameDivNode = row.SelectSingleNode("td[@class='col1']").SelectSingleNode("div");
                    HtmlNode playerNode = teamNameDivNode.SelectSingleNode("span[@class='avatar']").SelectSingleNode("img");
                    player = playerNode.Attributes["data-playername"].Value;
                    HtmlNodeCollection honourNodes = teamNameDivNode.SelectNodes("em");
                    HtmlNode goldNode = row.SelectSingleNode("td[@class='col2']");
                    gold = goldNode.InnerText;
                    HtmlNode KDANode = row.SelectSingleNode("td[@class='col3']");
                    KDA = KDANode.InnerText;
                    HtmlNode itemNode = row.SelectSingleNode("td[@class='col4']").SelectSingleNode("div[@class='u-weapon']").SelectSingleNode("ul[@class='chuzhuang']");
                    HtmlNodeCollection itemNodes = itemNode.SelectNodes("li");
                    foreach (HtmlNode node in itemNodes)
                    {
                        if (itemNodes.Count > 0)
                        {
                            itemIcon1 = Regex.Match(itemNodes[0].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName1 = Regex.Match(itemNodes[0].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription1 = itemNodes[0].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 1)
                        {
                            itemIcon2 = Regex.Match(itemNodes[1].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName2 = Regex.Match(itemNodes[1].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription2 = itemNodes[1].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 2)
                        {
                            itemIcon3 = Regex.Match(itemNodes[2].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName3 = Regex.Match(itemNodes[2].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription3 = itemNodes[2].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 3)
                        {
                            itemIcon4 = Regex.Match(itemNodes[3].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName4 = Regex.Match(itemNodes[3].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription4 = itemNodes[3].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 4)
                        {
                            itemIcon5 = Regex.Match(itemNodes[4].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName5 = Regex.Match(itemNodes[4].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription5 = itemNodes[4].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 5)
                        {
                            itemIcon6 = Regex.Match(itemNodes[5].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName6 = Regex.Match(itemNodes[5].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription6 = itemNodes[5].SelectSingleNode("img").Attributes["title"].Value;
                        }
                        if (itemNodes.Count > 6)
                        {
                            itemIcon7 = Regex.Match(itemNodes[6].InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
                            itemName7 = Regex.Match(itemNodes[6].SelectSingleNode("img").Attributes["title"].Value, @".+\s").Value.Replace(" ", "");
                            itemDescription7 = itemNodes[6].SelectSingleNode("img").Attributes["title"].Value;
                        }
                    }
                    List<items> _itemB = new List<items>();
                    _itemB.Add(new items
                    {
                        playerId = player,
                        matchId = id,
                        itemIcon1 = itemIcon1,
                        itemName1 = itemName1,
                        itemDesc1 = itemDescription1,
                        itemIcon2 = itemIcon2,
                        itemName2 = itemName2,
                        itemDesc2 = itemDescription2,
                        itemIcon3 = itemIcon3,
                        itemName3 = itemName3,
                        itemDesc3 = itemDescription3,
                        itemIcon4 = itemIcon4,
                        itemName4 = itemName4,
                        itemDesc4 = itemDescription4,
                        itemIcon5 = itemIcon5,
                        itemName5 = itemName5,
                        itemDesc5 = itemDescription5,
                        itemIcon6 = itemIcon6,
                        itemName6 = itemName6,
                        itemDesc6 = itemDescription6,
                        itemIcon7 = itemIcon7,
                        itemName7 = itemName7,
                        itemDesc7 = itemDescription7
                    });
                    _match.match_details_lost.Add(new matchDetails
                    {
                        playerId = player,
                        matchId = id,
                        gold = gold,
                        KDA = KDA,
                        items_list = _itemB
                    });
                }
            }
        }

        IList<playerMatchDetails> _playerMatchDetails = new List<playerMatchDetails>();
        IEnumerable<HtmlNode> playerTipsNodes = MatchDetaildoc.DocumentNode.Descendants().Where(x => x.Name == "div" && x.Attributes.Contains("class")
            && x.Attributes["class"].Value.Split().Contains("layer"));
        foreach (HtmlNode child in playerTipsNodes)
        {
            string warScore = "";
            string lastHits = "";
            string creeps = "";
            string towersDestroyed = "";
            string barracksDestroyed = "";
            string wards = "";
            string dewards = "";
            string maxContKills = "";
            string maxMultiKills = "";
            string maxCrit = "";
            string totalHeal = "";
            string totalDmg = "";
            string totalTank = "";
            string totalHeroDmg = "";
            string totalHeroPhyDmg = "";
            string totalHeroMagicDmg = "";
            string totalHeroTrueDmg = "";
            HtmlNode divModTipsMain = child.SelectSingleNode("div[@class='mod-tips-main']");
            HtmlNode divTopLeft = child.SelectSingleNode("div[@class='mod-tips-top']").SelectSingleNode("div[@class='tip-topleft']");
            MatchCollection matches = Regex.Matches(divTopLeft.InnerHtml, "<img.+?src=[\"'](.+?)spell(.+?)[\"'].*?>", RegexOptions.IgnoreCase);
            string champIcon = Regex.Match(divTopLeft.InnerHtml, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
            string firstSpellIcon = Regex.Match(matches[0].Value, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
            string secondSpellIcon = Regex.Match(matches[1].Value, "<img.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
            IEnumerable<HtmlNode> tableNodes = divModTipsMain.Descendants().Where(x => x.Name == "table");
            foreach (HtmlNode table in tableNodes)
            {
                foreach (HtmlNode row in table.SelectNodes("tr"))
                {
                    HtmlNodeCollection cell = row.SelectNodes("td");
                    if (cell != null)
                    {
                        if (cell.Count >= 2 && cell[0].InnerText == "战局评分:")
                        {
                            warScore = cell[1].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[0].InnerText == "补兵:")
                        {
                            lastHits = cell[1].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[2].InnerText == "野怪:")
                        {
                            creeps = cell[3].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[0].InnerText == "推塔:")
                        {
                            towersDestroyed = cell[1].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[2].InnerText == "兵营:")
                        {
                            barracksDestroyed = cell[3].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[0].InnerText == "放眼数:")
                        {
                            wards = cell[1].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[2].InnerText == "排眼数:")
                        {
                            dewards = cell[3].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[0].InnerText == "最大连杀:")
                        {
                            maxContKills = cell[1].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[2].InnerText == "最大多杀:")
                        {
                            maxMultiKills = cell[3].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[0].InnerText == "最大暴击:")
                        {
                            maxCrit = cell[1].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[2].InnerText == "总治疗:")
                        {
                            totalHeal = cell[3].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[0].InnerText == "输出伤害:")
                        {
                            totalDmg = cell[1].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                        if (cell.Count >= 4 && cell[2].InnerText == "承受敌害:")
                        {
                            totalTank = cell[3].InnerText.Replace(" ", "").Replace("\r\n", "");
                        }
                    }
                }
            }
            HtmlNodeCollection pNodes = divModTipsMain.SelectNodes("p");
            foreach (HtmlNode node in pNodes)
            {
                if (node.InnerHtml.Contains("给对方英雄造成总伤害:"))
                {
                    totalHeroDmg = node.InnerText.Replace("给对方英雄造成总伤害:", "").Replace(" ", "").Replace("\r\n", "");
                }
                if (node.InnerHtml.Contains("给对方英雄的物理伤害:"))
                {
                    totalHeroPhyDmg = node.InnerText.Replace("给对方英雄的物理伤害:", "").Replace(" ", "").Replace("\r\n", "");
                }
                if (node.InnerHtml.Contains("给对方英雄的魔法伤害:"))
                {
                    totalHeroMagicDmg = node.InnerText.Replace("给对方英雄的魔法伤害:", "").Replace(" ", "").Replace("\r\n", "");
                }
                if (node.InnerHtml.Contains("给对方英雄的真实伤害:"))
                {
                    totalHeroTrueDmg = node.InnerText.Replace("给对方英雄的真实伤害:", "").Replace(" ", "").Replace("\r\n", "");
                }
            }
            string pId = divTopLeft.SelectSingleNode("p[@class='tip-user-name']").InnerText.Replace(" ", "").Replace("\r\n", "");
            for (int i = 0; i < _match.match_details_win.Count; i++)
            {
                if (_match.match_details_win[i].playerId == pId)
                {
                    _match.match_details_win[i].champion_name_ch = divTopLeft.SelectSingleNode("div[@class='tip-user-detail']").SelectSingleNode("span[@class='tip-tip-user-name2']").InnerText;
                    _match.match_details_win[i].champIcon = champIcon;
                    _match.match_details_win[i].firstSpellIcon = firstSpellIcon;
                    _match.match_details_win[i].secondSpellIcon = secondSpellIcon;
                    _match.match_details_win[i].warScore = warScore;
                    _match.match_details_win[i].lastHits = lastHits;
                    _match.match_details_win[i].creeps = creeps;
                    _match.match_details_win[i].towersDestroyed = towersDestroyed;
                    _match.match_details_win[i].barracksDestroyed = barracksDestroyed;
                    _match.match_details_win[i].wards = wards;
                    _match.match_details_win[i].dewards = dewards;
                    _match.match_details_win[i].maxContKills = maxContKills;
                    _match.match_details_win[i].maxMultiKills = maxMultiKills;
                    _match.match_details_win[i].maxCrit = maxCrit;
                    _match.match_details_win[i].totalHeal = totalHeal;
                    _match.match_details_win[i].totalDmg = totalDmg;
                    _match.match_details_win[i].totalTank = totalTank;
                    _match.match_details_win[i].totalHeroDmg = totalHeroDmg;
                    _match.match_details_win[i].totalHeroPhyDmg = totalHeroPhyDmg;
                    _match.match_details_win[i].totalHeroMagicDmg = totalHeroMagicDmg;
                    _match.match_details_win[i].totalHeroTrueDmg = totalHeroTrueDmg;
                }
                if (_match.match_details_lost[i].playerId == pId)
                {
                    _match.match_details_lost[i].champion_name_ch = divTopLeft.SelectSingleNode("div[@class='tip-user-detail']").SelectSingleNode("span[@class='tip-tip-user-name2']").InnerText;
                    _match.match_details_lost[i].champIcon = champIcon;
                    _match.match_details_lost[i].firstSpellIcon = firstSpellIcon;
                    _match.match_details_lost[i].secondSpellIcon = secondSpellIcon;
                    _match.match_details_lost[i].warScore = warScore;
                    _match.match_details_lost[i].lastHits = lastHits;
                    _match.match_details_lost[i].creeps = creeps;
                    _match.match_details_lost[i].towersDestroyed = towersDestroyed;
                    _match.match_details_lost[i].barracksDestroyed = barracksDestroyed;
                    _match.match_details_lost[i].wards = wards;
                    _match.match_details_lost[i].dewards = dewards;
                    _match.match_details_lost[i].maxContKills = maxContKills;
                    _match.match_details_lost[i].maxMultiKills = maxMultiKills;
                    _match.match_details_lost[i].maxCrit = maxCrit;
                    _match.match_details_lost[i].totalHeal = totalHeal;
                    _match.match_details_lost[i].totalDmg = totalDmg;
                    _match.match_details_lost[i].totalTank = totalTank;
                    _match.match_details_lost[i].totalHeroDmg = totalHeroDmg;
                    _match.match_details_lost[i].totalHeroPhyDmg = totalHeroPhyDmg;
                    _match.match_details_lost[i].totalHeroMagicDmg = totalHeroMagicDmg;
                    _match.match_details_lost[i].totalHeroTrueDmg = totalHeroTrueDmg;
                }
            }
        }

        return new JavaScriptSerializer().Serialize(_match);
    }
Exemple #37
0
            // 1.0.84 note: if this is proves too slow, i'll do a binary search by m.line_idx !!!
            public int index_of(match m) {
                if (m.line_idx < 0)
                    // it's the empty match
                    return -1;

                lock (this) {
                    //return matches_.IndexOf(m);
                    int idx = matches_.binary_search_closest(x => x.line_idx, m.line_idx).Item2;
                    if ( idx >= 0)
                        Debug.Assert(matches_[idx] == m);
                    return idx;
                }
            }