Ejemplo n.º 1
0
 public void Init(StatisticsMatchEntity statisticsMatch)
 {
     _statisticsMatch = statisticsMatch;
     _scoreContent    = string.Format("最终比分({0}:{1}) 总回合数:{2}  ", statisticsMatch.HomeScore, statisticsMatch.AwayScore, statisticsMatch.TotalRound);
     lblScore.Content = _scoreContent + "当前播放回合 0 ";
     ManagerControl1.SetData(_statisticsMatch.HomeManager);
     ManagerControl2.SetData(_statisticsMatch.AwayManager);
     _emulatorRound            = _statisticsMatch.HomeManager.MinRound;
     DataGridMatch.ItemsSource = statisticsMatch.StatisticsBallResults;
     txtRound.Text             = "";
 }
Ejemplo n.º 2
0
 static void MainLoop(IMatch match, StatisticsMatchEntity statisticsMatch)
 {
     match.SessionInit();
     while (match.Status.Round < match.Status.TotalRound)
     {
         doMatch(match);
     }
     match.SaveRptEnd();
     if (statisticsMatch != null)
     {
         statisticsMatch.SetTotal();
     }
 }
Ejemplo n.º 3
0
 public Main(MatchReport match, StatisticsMatchEntity statistics)
     : this()
 {
     _match           = match;
     _statisticsMatch = statistics;
     if (_match != null)
     {
         _timer.Stop();
         _round    = 0;
         _maxRound = GetMaxRound();
         ResetPlayer();
         //ResetBall();
         btnNewGame.IsEnabled = false;
         PlayGame(this, new EventArgs());
     }
 }
Ejemplo n.º 4
0
        void CreateMatch(MatchInput transfer, int matchTimes, bool needStatistics, CreateDelegate createDelegate, FinishDelegate finishDelegate)
        {
            int i    = 1;
            var hmid = transfer.HomeManager.Mid;
            var amid = transfer.AwayManager.Mid;

            while (i <= matchTimes)
            {
                if (transfer != null)
                {
                    var watch = new System.Diagnostics.Stopwatch();
                    watch.Start();
                    transfer.MatchId = ShareUtil.GenerateComb();

                    try
                    {
                        IMatch match = new MatchEntity(transfer);

                        if (needStatistics)
                        {
                            statisticsMatch = new StatisticsMatchEntity(match);
                        }
                        EmulatorHelper.CreateMatch(match, statisticsMatch);
                        var  result = match.Report;
                        long cost   = watch.ElapsedMilliseconds;

                        _testStatisticsDic.Add(i, statisticsMatch);
                        _testMatchEntityDic.Add(i, result);
                        Dispatcher.Invoke((Action) delegate { createDelegate(transfer.MatchId, i, cost, result); });
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Insert(ex);
                    }
                }
                i++;
            }
            Dispatcher.Invoke((Action) delegate { finishDelegate(); });
        }
Ejemplo n.º 5
0
 public static void CreateMatch(IMatch match, StatisticsMatchEntity statisticsMatch)
 {
     MainLoop(match, statisticsMatch);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Start a new match.
        /// (This method is working on another thread.)
        /// </summary>
        private void StartNewMatch(object o)
        {
            Interlocked.Exchange(ref this._isEndStart, 0);
            MatchInput matchIn = null;

            if (hmid == Guid.Empty && amid == Guid.Empty)
            {
                double time;
                if (!double.TryParse(o.ToString(), out time))
                {
                    time = 120;
                }
                matchIn = DataMgr.CreateDebugMatch((int)time);
            }
            else
            {
                matchIn = LocalHelper.GetLocalMatchInput(hmid, homeIsNpc, amid, awayIsNpc, _time);
            }
            if (matchIn == null)
            {
                MessageBox.Show("创建比赛失败,创建MatchInput失败,请检查输入账号.");
                return;
            }
            IMatch match = new MatchEntity(matchIn, StatisticsAddProcess);

            if (_openStatistics)
            {
                _statisticsMatch = new StatisticsMatchEntity(match);
            }
            using (var watch = new Games.NB.Match.Log.LogWatch())
            {
                EmulatorHelper.CreateMatch(match, _statisticsMatch);
                watch.LogCostTime(string.Format("Guid:{0}[{1}] vs Guid:{2}[{3}]. Result {4}:{5})",
                                                match.Input.HomeManager.Mid, match.Input.HomeManager.Name,
                                                match.Input.AwayManager.Mid, match.Input.AwayManager.Name,
                                                match.HomeScore, match.AwayScore));
                var bytes = IOUtil.BinWrite(match.Report, ReportAsset.RPTVerNo);
                watch.LogCostTime("BinWrite");
                _match = IOUtil.BinRead <MatchReport>(bytes, 0);
                watch.LogCostTime("BinRead");
            }
            if (_match == null)
            {
                MessageBox.Show("创建比赛失败");
                return;
            }
            else
            {
                MessageBox.Show("创建比赛成功");
            }
            DataMgr.FillFormData(_match);
            DataMgr.FillRoundData(_match);
            try
            {
                //_match = MatchFacade.CreateMatch(DataMgr.CreateDebugMatch((int)time * 60, 335, 300)).Report;
                this._maxRound = GetMaxRound();
                Interlocked.Exchange(ref this._isEndStart, 1);
                _loadingTimer.Start();
                _waitTimer.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ":\n" + ex.StackTrace, "系统错误");
            }
        }
Ejemplo n.º 7
0
 public StatisticsWindow(StatisticsMatchEntity statisticsMatch)
 {
     InitializeComponent();
     Init(statisticsMatch);
 }