コード例 #1
0
ファイル: DemoParser.cs プロジェクト: steinn/demoinfo
		internal void RaiseSayText(SayTextEventArgs st)
		{
			if (SayText != null)
				SayText(this, st);
		}
コード例 #2
0
		protected void HandleSayText(object sender, SayTextEventArgs e)
		{
			// cleanup text
			e.Text = Regex.Replace(e.Text, @"[\u0001\u0005\u0004]", string.Empty);

			// Beginning of the match
			Match faceItLive = _faceItLiveRegex.Match(e.Text);
			if (e.Text == EBOT_LIVE || faceItLive.Success)
			{
				Demo.ResetStats(false);
				AddTeams();
				RoundCount = 0;
				CreateNewRound();
				IsMatchStarted = true;
			}

			Match scoreUpdateEbot = _scoreRegex.Match(e.Text);
			Match scoreUpdateFaceit = _faceitScoreRegex.Match(e.Text);
			// Score update
			if (scoreUpdateEbot.Success || scoreUpdateFaceit.Success)
			{
				// sometimes the parser doesn't have the right team's name when they have been swapped
				// use the first score update to know the right name of the teams
				if (!_isTeamsNameDetected)
				{
					_isTeamsNameDetected = true;
					if (Parser.CTClanName != Demo.ClanTagNameTeam1)
					{
						Demo.ClanTagNameTeam1 = Parser.CTClanName;
						Demo.ClanTagNameTeam2 = Parser.TClanName;
						Demo.Teams[0].Name = Parser.CTClanName;
						Demo.Teams[1].Name = Parser.TClanName;
					}
				}

				int score1;
				int score2;
				if (scoreUpdateEbot.Success)
				{
					score1 = Convert.ToInt32(scoreUpdateEbot.Groups["score1"].Value);
					score2 = Convert.ToInt32(scoreUpdateEbot.Groups["score2"].Value);
				}
				else
				{
					score1 = Convert.ToInt32(scoreUpdateFaceit.Groups["score1"].Value);
					score2 = Convert.ToInt32(scoreUpdateFaceit.Groups["score2"].Value);
					_isFaceit = true;
				}
				
				int scoreTotal = score1 + score2;
				if (scoreTotal == 15) IsSwapTeamRequired = true;
				// End of the match may have an overtime, init the 1st one
				if (scoreTotal == 30)
				{
					// Don't stop the match for Faceit demos because there isn't warmup between end of the match and OT
					if(!scoreUpdateFaceit.Success) IsMatchStarted = false;
					// Start the OT
					IsOvertime = true;
					IsHalfMatch = false;
					CurrentOvertime = new Overtime
					{
						Number = ++OvertimeCount
					};
				}
				return;
			}

			// End of the match (OT or not)
			Match matchEnd = _endMatchRegex.Match(e.Text);
			if (matchEnd.Success)
			{
				IsMatchStarted = false;
				return;
			}

			if (IsOvertime)
			{
				// if eBot is waiting for !ready, the match isn't started
				if (e.Text == PLEASE_WRITE_READY) IsMatchStarted = false;

				// announce the beginning of the 1st OT side
				if (e.Text == BEGIN_FIRST_SIDE_OVERTIME)
				{
					IsMatchStarted = true;
					// Add the last OT played and create a new one
					if (Demo.ScoreTeam1 + Demo.ScoreTeam2 > 30)
					{
						Application.Current.Dispatcher.Invoke(delegate
						{
							Demo.Overtimes.Add(CurrentOvertime);
						});
						CurrentOvertime = new Overtime
						{
							Number = ++OvertimeCount
						};
					}
					IsHalfMatch = Demo.Overtimes.Any();
				}

				// announce the beginning of the 2nd OT side
				if (e.Text == BEGIN_SECOND_SIDE_OVERTIME)
				{
					IsMatchStarted = true;
					IsHalfMatch = !Demo.Overtimes.Any();
					IsSwapTeamRequired = true;
				}
			}
		}