Пример #1
0
    public void GetMatchList(Action <bool, string> func)
    {
        Backend.Match.GetMatchList(callback =>
        {
            if (callback.IsSuccess() == false)
            {
                Debug.Log("매칭 카드 불러오기 실패");
                Dispatcher.Current.BeginInvoke(() =>
                {
                    GetMatchList(func);
                }
                                               );
                return;
            }
            foreach (LitJson.JsonData row in callback.Rows())
            {
                MatchInfo info = new MatchInfo();
                info.indate    = row["inDate"]["S"].ToString();
                foreach (MatchType type in Enum.GetValues(typeof(MatchType)))
                {
                    info.matchType = type;
                }
                foreach (MatchModeType type in Enum.GetValues(typeof(MatchModeType)))
                {
                    info.matchModeType = type;
                }

                MatchInfos.Add(info);
            }
            Debug.Log("매치 카드 생성 완료");
            func(true, string.Empty);
        });
    }
Пример #2
0
    public MatchInfo GetMatchInfo(string indate)
    {
        var result = MatchInfos.FirstOrDefault(x => x.indate == indate);

        if (result.Equals(default(MatchInfo)) == true)
        {
            return(null);
        }
        return(result);
    }
        //public List<MatchViewModel> BuildSoloQHistories(List<Match> matches)
        //{
        //    List<MatchViewModel> lmvm = new List<MatchViewModel>();
        //    SoloQServices sqs = new SoloQServices();
        //    foreach (var match in matches)
        //    {
        //        MatchViewModel mvm = new MatchViewModel();
        //        mvm.championId = match.championId;
        //        mvm.lane = match.lane;
        //        mvm.timestamp = match.timestamp;
        //        mvm.role = match.role;
        //        mvm.lane = match.lane;

        //        mvm.matchInfo = new MatchInfosViewModel();
        //        MatchInfos matchInfo = sqs.GetMatchInfo(match.gameId.ToString());
        //        mvm.matchInfo.gameCreation = matchInfo.gameCreation;
        //        mvm.matchInfo.gameDuration = matchInfo.gameDuration;

        //        Participant participant = matchInfo.participants.Where(x => x.championId == match.championId).FirstOrDefault();
        //        mvm.participant = BuildParticipantViewModel(participant);
        //        mvm.participant.stats = BuildStatsViewModel(participant.stats);
        //        lmvm.Add(mvm);
        //    }

        //    return lmvm;
        //}

        public MatchInfosViewModel BuildMatchInfosViewModel(MatchInfos matchInfos)
        {
            MatchInfosViewModel mivm = new MatchInfosViewModel();

            mivm.gameCreation = matchInfos.gameCreation;
            mivm.gameDuration = matchInfos.gameDuration;
            mivm.gameId       = matchInfos.gameId;
            mivm.gameVersion  = matchInfos.gameVersion;
            mivm.teams        = BuildListTeamViewModel(matchInfos.teams);

            return(mivm);
        }
Пример #4
0
        /// <summary>
        /// 获取sql中包含的参数,sql中的参数形式为[xxx]样式
        /// </summary>
        /// <param name="sourceSql"></param>
        /// <param name="splitChar"></param>
        /// <returns>返回获取到的参数字符串,返回形式为:参数1,参数2,参数3...</returns>
        static public string GetSqlPars(string sourceSql, string splitChar = ",")
        {
            MatchInfos matchs = GetMinMatchData(sourceSql, "[", "]", '\'', '\'');

            string result = "";

            foreach (MatchInfo mi in matchs)
            {
                if (string.IsNullOrEmpty(result) == false)
                {
                    result = result + splitChar;
                }
                result = result + mi.MatchContext;
            }
            return(result);
        }
Пример #5
0
        public TimelineViewModel BuildTimelineViewModel(MatchInfos matchInfos, Player player)
        {
            TimelineViewModel   tvm = new TimelineViewModel();
            PerformanceServices ps  = new PerformanceServices();
            TimelineServices    ts  = new TimelineServices();
            SoloQServices       sq  = new SoloQServices();
            int participantId       = ps.GetParticipantId(matchInfos, player);
            var participant         = ps.GetParticipantById(matchInfos, participantId);

            var opponent = ps.GetOpponentNameByOpponentId(matchInfos, player);
            var oppponentParticipantId = opponent.Item2;
            var opponantParticipant    = ps.GetParticipantById(matchInfos, oppponentParticipantId);
            var frames = sq.GetTimeLinesMatchInfos(matchInfos.gameId.ToString());

            var timeline = matchInfos.participants.Where(x => x.participantId == participantId).FirstOrDefault().timeline;

            tvm.participantId = timeline.participantId;

            tvm.kills        = matchInfos.participants.Where(x => x.participantId == participantId).FirstOrDefault().stats.kills;
            tvm.deaths       = matchInfos.participants.Where(x => x.participantId == participantId).FirstOrDefault().stats.deaths;
            tvm.assists      = matchInfos.participants.Where(x => x.participantId == participantId).FirstOrDefault().stats.assists;
            tvm.opponentName = opponent.Item1;
            tvm.timestamp    = matchInfos.gameCreation;
            tvm.gameId       = matchInfos.gameId;

            var spell         = ps.GetSummonerSpellsByParticipantId(matchInfos, participantId);
            var opponentSpell = ps.GetSummonerSpellsByParticipantId(matchInfos, oppponentParticipantId);

            tvm.spell1Id         = spell.Item1;
            tvm.spell2Id         = spell.Item2;
            tvm.opponentSpell1Id = opponentSpell.Item1;
            tvm.opponentSpell2Id = opponentSpell.Item2;

            tvm.primaryKey              = ps.GetPrimaryRune(matchInfos, participantId);
            tvm.primaryKeyStyle         = ps.GetPrimaryStyleRune(matchInfos, participantId);
            tvm.opponentPrimaryKey      = ps.GetPrimaryRune(matchInfos, oppponentParticipantId);
            tvm.opponentPrimaryKeyStyle = ps.GetPrimaryStyleRune(matchInfos, oppponentParticipantId);


            tvm.creepsPerMinDeltas = new CreepsPerMinDeltasViewModel();
            tvm.creepsPerMinDeltas.firstPartTime  = timeline.creepsPerMinDeltas?.firstPartTime;
            tvm.creepsPerMinDeltas.secondPartTime = timeline.creepsPerMinDeltas?.secondPartTime;

            tvm.csDiffPerMinDeltas = new CsDiffPerMinDeltasViewModel();

            //results are not working well or bad calculated
            //tvm.csDiffPerMinDeltas.firstPartTime = timeline.csDiffPerMinDeltas?.firstPartTime;
            //tvm.csDiffPerMinDeltas.secondPartTime = timeline.csDiffPerMinDeltas?.secondPartTime;

            tvm.csDiffPerMinDeltas.fiveMin    = ts.getCsDiffByTimingMark(frames, participantId, oppponentParticipantId, 5);
            tvm.csDiffPerMinDeltas.tenMin     = ts.getCsDiffByTimingMark(frames, participantId, oppponentParticipantId, 10);
            tvm.csDiffPerMinDeltas.fifteenMin = ts.getCsDiffByTimingMark(frames, participantId, oppponentParticipantId, 15);
            tvm.csDiffPerMinDeltas.twentyMin  = ts.getCsDiffByTimingMark(frames, participantId, oppponentParticipantId, 20);

            tvm.goldPerMinDeltas = new GoldPerMinDeltasViewModel();
            tvm.goldPerMinDeltas.firstPartTime  = timeline.goldPerMinDeltas?.firstPartTime;
            tvm.goldPerMinDeltas.secondPartTime = timeline.goldPerMinDeltas?.secondPartTime;

            tvm.damageTakenDiffPerMinDeltas = new DamageTakenDiffPerMinDeltasViewModel();
            tvm.damageTakenDiffPerMinDeltas.firstPartTime  = timeline.damageTakenDiffPerMinDeltas?.firstPartTime;
            tvm.damageTakenDiffPerMinDeltas.secondPartTime = timeline.damageTakenDiffPerMinDeltas?.secondPartTime;

            tvm.damageTakenPerMinDeltas = new DamageTakenPerMinDeltasViewModel();
            tvm.damageTakenPerMinDeltas.firstPartTime  = timeline.damageTakenPerMinDeltas?.firstPartTime;
            tvm.damageTakenPerMinDeltas.secondPartTime = timeline.damageTakenPerMinDeltas?.secondPartTime;

            tvm.xpDiffPerMinDeltas = new XpDiffPerMinDeltasViewModel();
            //tvm.xpDiffPerMinDeltas.firstPartTime = timeline.xpDiffPerMinDeltas?.firstPartTime;
            //tvm.xpDiffPerMinDeltas.secondPartTime = timeline.xpDiffPerMinDeltas?.secondPartTime;

            tvm.xpDiffPerMinDeltas.fiveMin    = ts.getXpDiffByTimingMark(frames, participantId, oppponentParticipantId, 5);
            tvm.xpDiffPerMinDeltas.tenMin     = ts.getXpDiffByTimingMark(frames, participantId, oppponentParticipantId, 10);
            tvm.xpDiffPerMinDeltas.fifteenMin = ts.getXpDiffByTimingMark(frames, participantId, oppponentParticipantId, 15);
            tvm.xpDiffPerMinDeltas.twentyMin  = ts.getXpDiffByTimingMark(frames, participantId, oppponentParticipantId, 20);

            tvm.XpPerMinDeltas = new XpPerMinDeltasViewModel();
            tvm.XpPerMinDeltas.firstPartTime  = timeline.XpPerMinDeltas?.firstPartTime;
            tvm.XpPerMinDeltas.secondPartTime = timeline.XpPerMinDeltas?.secondPartTime;

            tvm.deathCount               = new DeathCountViewModel();
            tvm.deathCount.fiveMin       = ts.GetNbDeathBetweenTimingMark(frames, participantId, 0, 5);
            tvm.deathCount.tenMin        = ts.GetNbDeathBetweenTimingMark(frames, participantId, 5, 10);
            tvm.deathCount.fifteenMin    = ts.GetNbDeathBetweenTimingMark(frames, participantId, 10, 15);
            tvm.deathCount.twentyMin     = ts.GetNbDeathBetweenTimingMark(frames, participantId, 15, 20);
            tvm.deathCount.twentyFiveMin = ts.GetNbDeathBetweenTimingMark(frames, participantId, 20, 0);
            //tvm.deathCount.thirtyMin = ts.GetNbDeathBetweenTimingMark(frames, participantId, 25, 30);

            if (player.Role == 5)
            {
                tvm.wardDestroyedCount = new WardDestroyedCountViewModel();

                tvm.wardDestroyedCount.tenMin         = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 0, 10);
                tvm.wardDestroyedCount.fifteenMin     = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 10, 15);
                tvm.wardDestroyedCount.twentyMin      = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 15, 20);
                tvm.wardDestroyedCount.twentyTwoMin   = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 20, 22);
                tvm.wardDestroyedCount.twentyFourMin  = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 22, 24);
                tvm.wardDestroyedCount.twentySixMin   = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 24, 26);
                tvm.wardDestroyedCount.twentyEightMin = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 26, 28);
                tvm.wardDestroyedCount.thirtyrMin     = ts.GetNbWardDestroyedBetweenTimingMark(frames, participantId, 28, 30);

                tvm.wardPutCount = new WardPutCountViewModel();

                tvm.wardPutCount.tenMin         = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 0, 10);
                tvm.wardPutCount.fifteenMin     = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 10, 15);
                tvm.wardPutCount.twentyMin      = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 15, 20);
                tvm.wardPutCount.twentyTwoMin   = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 20, 22);
                tvm.wardPutCount.twentyFourMin  = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 22, 24);
                tvm.wardPutCount.twentySixMin   = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 24, 26);
                tvm.wardPutCount.twentyEightMin = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 26, 28);
                tvm.wardPutCount.thirtyrMin     = ts.GetNbWardPutBetweenTimingMark(frames, participantId, 28, 30);

                tvm.pinkPutCount                = new PinkPutCountViewModel();
                tvm.pinkPutCount.tenMin         = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 0, 10);
                tvm.pinkPutCount.fifteenMin     = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 10, 15);
                tvm.pinkPutCount.twentyMin      = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 15, 20);
                tvm.pinkPutCount.twentyTwoMin   = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 20, 22);
                tvm.pinkPutCount.twentyFourMin  = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 22, 24);
                tvm.pinkPutCount.twentySixMin   = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 24, 26);
                tvm.pinkPutCount.twentyEightMin = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 26, 28);
                tvm.pinkPutCount.thirtyrMin     = ts.GetNbPinkPutBetweenTimingMark(frames, participantId, 28, 30);
            }

            tvm.lane          = timeline.lane;
            tvm.role          = timeline.role;
            tvm.participantId = timeline.participantId;


            return(tvm);
        }
Пример #6
0
        public void CalculateDraftPosition(WinratesViewModel wrm, MatchInfos match, int participantId, bool isBlueSideWin)
        {
            switch (participantId)
            {
            case 1:
                wrm.blueSide.nbPick1++;
                if (isBlueSideWin)
                {
                    wrm.blueSide.nbWinPick1++;
                }
                break;

            case 2:
                wrm.blueSide.nbPick2++;
                if (isBlueSideWin)
                {
                    wrm.blueSide.nbWinPick2++;
                }
                break;

            case 3:
                wrm.blueSide.nbPick3++;
                if (isBlueSideWin)
                {
                    wrm.blueSide.nbWinPick3++;
                }
                break;

            case 4:
                wrm.blueSide.nbPick4++;
                if (isBlueSideWin)
                {
                    wrm.blueSide.nbWinPick4++;
                }
                break;

            case 5:
                wrm.blueSide.nbPick5++;
                if (isBlueSideWin)
                {
                    wrm.blueSide.nbWinPick5++;
                }
                break;

            case 6:
                wrm.redSide.nbPick6++;
                if (!isBlueSideWin)
                {
                    wrm.redSide.nbWinPick6++;
                }
                break;

            case 7:
                wrm.redSide.nbPick7++;
                if (!isBlueSideWin)
                {
                    wrm.redSide.nbWinPick7++;
                }
                break;

            case 8:
                wrm.redSide.nbPick8++;
                if (!isBlueSideWin)
                {
                    wrm.redSide.nbWinPick8++;
                }
                break;

            case 9:
                wrm.redSide.nbPick9++;
                if (!isBlueSideWin)
                {
                    wrm.redSide.nbWinPick9++;
                }
                break;

            case 10:
                wrm.redSide.nbPick10++;
                if (!isBlueSideWin)
                {
                    wrm.redSide.nbWinPick10++;
                }
                break;

            default:
                break;
            }
        }
Пример #7
0
        static private MatchInfos GetMinMatchData(string source, string startMatch, string endMatch,
                                                  char exceptSChr, char exceptEChr)
        {
            MatchInfos result = new MatchInfos();

            string rStart = "<";
            string rEnd   = ">";

            if (rStart == startMatch)
            {
                rStart = "(";
            }
            if (rEnd == endMatch)
            {
                rEnd = ")";
            }

            MatchCollection mc = null;

            if ((exceptSChr != '\0') && (exceptEChr != '\0'))
            {
                mc = Regex.Matches(source, "[\\" + exceptSChr + "](.*?)[\\" + exceptEChr + "]");

                for (int i = 0; i <= mc.Count - 1; i++)
                {
                    source = source.Replace(mc[i].Value, rStart + "@" + i + "/" + rEnd);
                }
            }

            string tmp = source;

            int startMatchLen = startMatch.Length;
            int endMatchLen   = endMatch.Length;

            int indexStart = tmp.IndexOf(startMatch);

            if (indexStart < 0)
            {
                return(result);               //没有匹配项,则直接退出
            }
            int indexEnd  = tmp.IndexOf(endMatch);
            int indexNext = tmp.IndexOf(startMatch, indexStart + startMatchLen);

            if (indexNext <= 0)
            {
                indexNext = tmp.Length;
            }

            while (indexStart >= 0)
            {
                if (indexStart >= 0 && indexEnd > 0 && indexEnd > indexStart && indexEnd < indexNext)//满足[xxx]这种形式,过滤[xxx[bbb]这种形式
                {
                    string context = tmp.Substring(indexStart + startMatchLen, indexEnd - indexStart - startMatchLen);

                    if (mc != null && context.IndexOf("<@") >= 0)
                    {
                        for (int i = 0; i <= mc.Count - 1; i++)
                        {
                            context = context.Replace(rStart + "@" + i + "/" + rEnd, mc[i].Value);
                        }
                    }

                    result.Add(new MatchInfo(context, indexStart));

                    tmp = tmp.Substring(indexEnd + endMatchLen);
                }
                else
                {
                    tmp = tmp.Substring(indexStart + startMatchLen);
                }

                if (tmp.Length <= 0)
                {
                    break;
                }

                indexStart = tmp.IndexOf(startMatch);
                indexEnd   = tmp.IndexOf(endMatch);

                indexNext = tmp.IndexOf(startMatch, (indexStart < 0) ? 0 : indexStart + startMatchLen);

                if (indexNext <= 0)
                {
                    indexNext = tmp.Length;
                }
            }

            return(result);
        }