示例#1
0
        private void btnStartTest_Click(object sender, RoutedEventArgs e)
        {
            int count = ConvertHelper.ConvertToInt(txtTestCount.Text);
            int time  = ConvertHelper.ConvertToInt(txtTime.Text);

            if (count < 1)
            {
                MessageBox.Show("场次不能小于1");
                return;
            }
            else if (count > 10000)
            {
                MessageBox.Show("场次不能大于10000");
                return;
            }
            if (time < 60 || time > 720 || time % 60 != 0)
            {
                MessageBox.Show("比赛时长取值范围 60-720,必须为60的倍数.");
                return;
            }

            _time = time;

            if (!miControl1.Check())
            {
                return;
            }
            if (!miControl2.Check())
            {
                return;
            }
            var transfer = LocalHelper.GetLocalMatchInput(miControl1.ManagerId, miControl1.IsNpc, miControl2.ManagerId, miControl2.IsNpc, _time);

            if (transfer == null)
            {
                MessageBox.Show("获取经理信息失败,请检查!");
                return;
            }
            StartTest(count, transfer);
        }
示例#2
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, "系统错误");
            }
        }