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 = ""; }
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(); } }
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()); } }
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(); }); }
public static void CreateMatch(IMatch match, StatisticsMatchEntity statisticsMatch) { MainLoop(match, statisticsMatch); }
/// <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, "系统错误"); } }
public StatisticsWindow(StatisticsMatchEntity statisticsMatch) { InitializeComponent(); Init(statisticsMatch); }