From 459d63975a331f15b082be703cb0bfd20d744223 Mon Sep 17 00:00:00 2001 From: AkiVer Date: Mon, 25 Nov 2024 20:26:42 +0100 Subject: [PATCH] feat: MatchZy demos support - fix incorrect round end reason when bomb exploded after round end https://github.com/akiver/cs-demo-manager/issues/896 ref https://github.com/akiver/cs-demo-manager/issues/751 --- internal/demo/demo.go | 8 + internal/slice/slice.go | 11 + js/src/constants.ts | 1 + pkg/api/analyzer.go | 31 +- pkg/api/constants/demo_source.go | 2 + pkg/api/ebot.go | 4 +- pkg/api/esportal.go | 4 +- pkg/api/match.go | 172 ++-- pkg/api/matchzy.go | 110 ++ pkg/api/valve.go | 4 +- tests/assertion/assert_rounds.go | 20 +- .../cs2_ebot_monte_vs_og_2023_anubis_test.go | 2 +- ...hzy_aurora_vs_3dmax_m3_2024_anubis_test.go | 184 ++++ ...zy_bleed_vs_parivision_2024_mirage_test.go | 937 ++++++++++++++++++ ...hzy_iskandear_vs_kirill_2024_train_test.go | 520 ++++++++++ ...tchzy_pressure_vs_cyphin_2024_nuke_test.go | 543 ++++++++++ ...s_north_iem_katowice_2017_overpass_test.go | 2 +- ..._vs_faze_iem_oakland_2017_overpass_test.go | 2 +- ...56765125919145_0103110035_190_nuke_test.go | 4 +- 19 files changed, 2457 insertions(+), 104 deletions(-) create mode 100644 pkg/api/matchzy.go create mode 100644 tests/cs2_matchzy_aurora_vs_3dmax_m3_2024_anubis_test.go create mode 100644 tests/cs2_matchzy_bleed_vs_parivision_2024_mirage_test.go create mode 100644 tests/cs2_matchzy_iskandear_vs_kirill_2024_train_test.go create mode 100644 tests/cs2_matchzy_pressure_vs_cyphin_2024_nuke_test.go diff --git a/internal/demo/demo.go b/internal/demo/demo.go index 2d10a35..124fbc6 100644 --- a/internal/demo/demo.go +++ b/internal/demo/demo.go @@ -45,6 +45,10 @@ var faceItDemoNameRegex = regexp.MustCompile(`/[0-9]+_team[a-z0-9-]+-Team[a-z0-9 var ebotDemoNameRegex = regexp.MustCompile(`/([0-9]*)_(.*?)-(.*?)_(.*?)(.dem)/`) var fiveEPlayDemoNameRegex = regexp.MustCompile(`^g\d+-(.*)[a-zA-Z0-9_]*$`) +// Default format: {TIME}_{MATCH_ID}_{MAP}_{TEAM1}_vs_{TEAM2} +// https://shobhit-pathak.github.io/MatchZy/gotv/#recording-demos +var matchZyDemoNameRegex = regexp.MustCompile(`^(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})_(\d+)_([a-zA-Z0-9_]+)_(.+?)_vs_(.+)$`) + // Reads the .info file associated with a demo if it exists and returns its content as bytes. func getMatchInfoProtoBytes(demoFilePath string) []byte { infoFilePath := demoFilePath + ".info" @@ -295,6 +299,10 @@ func GetDemoSource(demo *Demo) constants.DemoSource { return constants.DemoSourceGamersclub } + if strings.Contains(serverName, "matchzy") || matchZyDemoNameRegex.MatchString(demoName) { + return constants.DemoSourceMatchZy + } + if strings.Contains(serverName, "valve") { return constants.DemoSourceValve } diff --git a/internal/slice/slice.go b/internal/slice/slice.go index 00ffd56..46a2069 100644 --- a/internal/slice/slice.go +++ b/internal/slice/slice.go @@ -42,3 +42,14 @@ func Filter[T comparable](s []T, predicate func(item T, index int) bool) []T { return result } + +func Find[T comparable](collection []T, predicate func(item T) bool) (T, bool) { + for i := range collection { + if predicate(collection[i]) { + return collection[i], true + } + } + + var result T + return result, false +} diff --git a/js/src/constants.ts b/js/src/constants.ts index d248426..0720c3a 100644 --- a/js/src/constants.ts +++ b/js/src/constants.ts @@ -16,6 +16,7 @@ export const DemoSource = { Fastcup: 'fastcup', FiveEPlay: '5eplay', Gamersclub: 'gamersclub', + MatchZy: 'matchzy', PerfectWorld: 'perfectworld', Popflash: 'popflash', Unknown: 'unknown', diff --git a/pkg/api/analyzer.go b/pkg/api/analyzer.go index e9a9648..60685e4 100644 --- a/pkg/api/analyzer.go +++ b/pkg/api/analyzer.go @@ -181,6 +181,8 @@ func analyzeDemo(demoPath string, options AnalyzeDemoOptions) (*Match, error) { case constants.DemoSourceGamersclub: // Looks like they use an eBot fork but rounds are not detected properly. return nil, errors.New("gamersclub demos are not supported (GamersClubNotSupported)") + case constants.DemoSourceMatchZy: + createMatchZyAnalyzer(analyzer) case constants.DemoSourcePopFlash: // TODO notImplemented Unsure how demos from PopFlash are nowadays, need to find some to test. // Even latest CSGO demos from PopFlash may not really work because their recording system has probably changed @@ -204,11 +206,25 @@ func analyzeDemo(demoPath string, options AnalyzeDemoOptions) (*Match, error) { } // Required for CS2 demos, the following data are available only at the end of the parsing in the CDemoFileInfo message. + // The parser updates the header values when the CDemoFileInfo message is parsed. + // Unfortunately, some CS2 demos may not contain this message and so the header values are not updated. + // We fallback to the parser's internal values in such cases. header := parser.Header() match.TickCount = header.PlaybackTicks + if match.TickCount == 0 { + match.TickCount = analyzer.currentTick() + } + match.Duration = header.PlaybackTime + if match.Duration == 0 { + match.Duration = parser.CurrentTime() + } if match.Duration > 0 { - match.FrameRate = float64(header.PlaybackFrames) / header.PlaybackTime.Seconds() + frames := int(header.PlaybackFrames) + if frames == 0 { + frames = parser.CurrentFrame() + } + match.FrameRate = float64(frames) / match.Duration.Seconds() } analyzer.postProcess(analyzer) @@ -292,6 +308,12 @@ func (analyzer *Analyzer) reset() { TeamBName: analyzer.match.TeamB.Name, weaponsBoughtUniqueIds: nil, } + analyzer.createPlayersEconomies() +} + +func (analyzer *Analyzer) resetCurrentRound() { + analyzer.match.resetRound(analyzer.currentRound.Number) + analyzer.createPlayersEconomies() } func (analyzer *Analyzer) registerPlayer(player *common.Player, teamState *common.TeamState) { @@ -560,6 +582,10 @@ func (analyzer *Analyzer) defaultRoundEndOfficiallyHandler(event events.RoundEnd analyzer.match.Rounds = append(analyzer.match.Rounds, analyzer.currentRound) } +func (analyzer *Analyzer) defaultAnnouncementWinPanelMatchHandler(event events.AnnouncementWinPanelMatch) { + analyzer.updatePlayersScores() +} + func (analyzer *Analyzer) registerCommonHandlers(includePositions bool) { parser := analyzer.parser match := analyzer.match @@ -885,9 +911,6 @@ func (analyzer *Analyzer) registerCommonHandlers(includePositions bool) { bombExploded := newBombExploded(analyzer, event) match.BombsExploded = append(match.BombsExploded, bombExploded) - // Update the round end reason because sometimes when the bomb exploded, the round end event indicates - // RoundEndReasonTerroristsWin instead of RoundEndReasonTargetBombed. - analyzer.currentRound.EndReason = events.RoundEndReasonTargetBombed }) parser.RegisterEventHandler(func(event events.BombPlantBegin) { diff --git a/pkg/api/constants/demo_source.go b/pkg/api/constants/demo_source.go index 7cb279a..6cb9238 100644 --- a/pkg/api/constants/demo_source.go +++ b/pkg/api/constants/demo_source.go @@ -18,6 +18,7 @@ const ( DemoSourceFiveEPlay DemoSource = "5eplay" DemoSourceGamersclub DemoSource = "gamersclub" // "Perfect World" (完美世界) is a Chinese company that Valve partnered with to release CS:GO in China. + DemoSourceMatchZy DemoSource = "matchzy" DemoSourcePerfectWorld DemoSource = "perfectworld" DemoSourcePopFlash DemoSource = "popflash" DemoSourceUnknown DemoSource = "unknown" @@ -36,4 +37,5 @@ var SupportedDemoSources = []DemoSource{ DemoSourcePerfectWorld, DemoSourcePopFlash, DemoSourceValve, + DemoSourceMatchZy, } diff --git a/pkg/api/ebot.go b/pkg/api/ebot.go index d4fe49b..6fdf822 100644 --- a/pkg/api/ebot.go +++ b/pkg/api/ebot.go @@ -185,7 +185,5 @@ func createEbotAnalyzer(analyzer *Analyzer) { match.Rounds = append(match.Rounds, analyzer.currentRound) }) - parser.RegisterEventHandler(func(event events.AnnouncementWinPanelMatch) { - analyzer.updatePlayersScores() - }) + parser.RegisterEventHandler(analyzer.defaultAnnouncementWinPanelMatchHandler) } diff --git a/pkg/api/esportal.go b/pkg/api/esportal.go index 90334c1..39e379b 100644 --- a/pkg/api/esportal.go +++ b/pkg/api/esportal.go @@ -28,7 +28,5 @@ func createEsportalAnalyzer(analyzer *Analyzer) { parser.RegisterEventHandler(analyzer.defaultRoundEndOfficiallyHandler) - parser.RegisterEventHandler(func(event events.AnnouncementWinPanelMatch) { - analyzer.updatePlayersScores() - }) + parser.RegisterEventHandler(analyzer.defaultAnnouncementWinPanelMatchHandler) } diff --git a/pkg/api/match.go b/pkg/api/match.go index 0be6736..b619a3a 100644 --- a/pkg/api/match.go +++ b/pkg/api/match.go @@ -359,6 +359,93 @@ func (match *Match) reset() { match.initTeams() } +func (match *Match) resetRound(roundNumber int) { + match.BombsPlantStart = slice.Filter(match.BombsPlantStart, func(event *BombPlantStart, index int) bool { + return event.RoundNumber != roundNumber + }) + match.BombsPlanted = slice.Filter(match.BombsPlanted, func(event *BombPlanted, index int) bool { + return event.RoundNumber != roundNumber + }) + match.BombsDefuseStart = slice.Filter(match.BombsDefuseStart, func(event *BombDefuseStart, index int) bool { + return event.RoundNumber != roundNumber + }) + match.BombsDefused = slice.Filter(match.BombsDefused, func(event *BombDefused, index int) bool { + return event.RoundNumber != roundNumber + }) + match.BombsExploded = slice.Filter(match.BombsExploded, func(event *BombExploded, index int) bool { + return event.RoundNumber != roundNumber + }) + match.ChatMessages = slice.Filter(match.ChatMessages, func(msg *ChatMessage, index int) bool { + return msg.RoundNumber != roundNumber + }) + match.ChickenDeaths = slice.Filter(match.ChickenDeaths, func(death *ChickenDeath, index int) bool { + return death.RoundNumber != roundNumber + }) + match.ChickenPositions = slice.Filter(match.ChickenPositions, func(position *ChickenPosition, index int) bool { + return position.RoundNumber != roundNumber + }) + match.Clutches = slice.Filter(match.Clutches, func(clutch *Clutch, index int) bool { + return clutch.RoundNumber != roundNumber + }) + match.Damages = slice.Filter(match.Damages, func(damage *Damage, index int) bool { + return damage.RoundNumber != roundNumber + }) + match.DecoysStart = slice.Filter(match.DecoysStart, func(decoy *DecoyStart, index int) bool { + return decoy.RoundNumber != roundNumber + }) + match.FlashbangsExplode = slice.Filter(match.FlashbangsExplode, func(flash *FlashbangExplode, index int) bool { + return flash.RoundNumber != roundNumber + }) + match.GrenadeBounces = slice.Filter(match.GrenadeBounces, func(grenade *GrenadeBounce, index int) bool { + return grenade.RoundNumber != roundNumber + }) + match.GrenadePositions = slice.Filter(match.GrenadePositions, func(position *GrenadePosition, index int) bool { + return position.RoundNumber != roundNumber + }) + match.GrenadeProjectilesDestroy = slice.Filter(match.GrenadeProjectilesDestroy, func(grenade *GrenadeProjectileDestroy, index int) bool { + return grenade.RoundNumber != roundNumber + }) + match.HeGrenadesExplode = slice.Filter(match.HeGrenadesExplode, func(grenade *HeGrenadeExplode, index int) bool { + return grenade.RoundNumber != roundNumber + }) + match.HostagePickUpStart = slice.Filter(match.HostagePickUpStart, func(hostage *HostagePickUpStart, index int) bool { + return hostage.RoundNumber != roundNumber + }) + match.HostagePickedUp = slice.Filter(match.HostagePickedUp, func(hostage *HostagePickedUp, index int) bool { + return hostage.RoundNumber != roundNumber + }) + match.HostagePositions = slice.Filter(match.HostagePositions, func(position *HostagePosition, index int) bool { + return position.RoundNumber != roundNumber + }) + match.HostageRescued = slice.Filter(match.HostageRescued, func(hostage *HostageRescued, index int) bool { + return hostage.RoundNumber != roundNumber + }) + match.InfernoPositions = slice.Filter(match.InfernoPositions, func(position *InfernoPosition, index int) bool { + return position.RoundNumber != roundNumber + }) + match.Kills = slice.Filter(match.Kills, func(kill *Kill, index int) bool { + return kill.RoundNumber != roundNumber + }) + match.PlayerEconomies = slice.Filter(match.PlayerEconomies, func(eco *PlayerEconomy, index int) bool { + return eco.RoundNumber != roundNumber + }) + match.PlayerPositions = slice.Filter(match.PlayerPositions, func(position *PlayerPosition, index int) bool { + return position.RoundNumber != roundNumber + }) + match.PlayersBuy = slice.Filter(match.PlayersBuy, func(event *PlayerBuy, index int) bool { + return event.RoundNumber != roundNumber + }) + match.PlayersFlashed = slice.Filter(match.PlayersFlashed, func(event *PlayerFlashed, index int) bool { + return event.RoundNumber != roundNumber + }) + match.Shots = slice.Filter(match.Shots, func(event *Shot, index int) bool { + return event.RoundNumber != roundNumber + }) + match.SmokesStart = slice.Filter(match.SmokesStart, func(event *SmokeStart, index int) bool { + return event.RoundNumber != roundNumber + }) +} + func (match *Match) deleteIncompleteRounds() { for i := len(match.Rounds) - 1; i >= 0; i-- { round := match.Rounds[i] @@ -370,89 +457,6 @@ func (match *Match) deleteIncompleteRounds() { match.Rounds = append(match.Rounds[:i], match.Rounds[i+1:]...) - match.BombsPlantStart = slice.Filter(match.BombsPlantStart, func(event *BombPlantStart, index int) bool { - return event.RoundNumber != round.Number - }) - match.BombsPlanted = slice.Filter(match.BombsPlanted, func(event *BombPlanted, index int) bool { - return event.RoundNumber != round.Number - }) - match.BombsDefuseStart = slice.Filter(match.BombsDefuseStart, func(event *BombDefuseStart, index int) bool { - return event.RoundNumber != round.Number - }) - match.BombsDefused = slice.Filter(match.BombsDefused, func(event *BombDefused, index int) bool { - return event.RoundNumber != round.Number - }) - match.BombsExploded = slice.Filter(match.BombsExploded, func(event *BombExploded, index int) bool { - return event.RoundNumber != round.Number - }) - match.ChatMessages = slice.Filter(match.ChatMessages, func(msg *ChatMessage, index int) bool { - return msg.RoundNumber != round.Number - }) - match.ChickenDeaths = slice.Filter(match.ChickenDeaths, func(death *ChickenDeath, index int) bool { - return death.RoundNumber != round.Number - }) - match.ChickenPositions = slice.Filter(match.ChickenPositions, func(position *ChickenPosition, index int) bool { - return position.RoundNumber != round.Number - }) - match.Clutches = slice.Filter(match.Clutches, func(clutch *Clutch, index int) bool { - return clutch.RoundNumber != round.Number - }) - match.Damages = slice.Filter(match.Damages, func(damage *Damage, index int) bool { - return damage.RoundNumber != round.Number - }) - match.DecoysStart = slice.Filter(match.DecoysStart, func(decoy *DecoyStart, index int) bool { - return decoy.RoundNumber != round.Number - }) - match.FlashbangsExplode = slice.Filter(match.FlashbangsExplode, func(flash *FlashbangExplode, index int) bool { - return flash.RoundNumber != round.Number - }) - match.GrenadeBounces = slice.Filter(match.GrenadeBounces, func(grenade *GrenadeBounce, index int) bool { - return grenade.RoundNumber != round.Number - }) - match.GrenadePositions = slice.Filter(match.GrenadePositions, func(position *GrenadePosition, index int) bool { - return position.RoundNumber != round.Number - }) - match.GrenadeProjectilesDestroy = slice.Filter(match.GrenadeProjectilesDestroy, func(grenade *GrenadeProjectileDestroy, index int) bool { - return grenade.RoundNumber != round.Number - }) - match.HeGrenadesExplode = slice.Filter(match.HeGrenadesExplode, func(grenade *HeGrenadeExplode, index int) bool { - return grenade.RoundNumber != round.Number - }) - match.HostagePickUpStart = slice.Filter(match.HostagePickUpStart, func(hostage *HostagePickUpStart, index int) bool { - return hostage.RoundNumber != round.Number - }) - match.HostagePickedUp = slice.Filter(match.HostagePickedUp, func(hostage *HostagePickedUp, index int) bool { - return hostage.RoundNumber != round.Number - }) - match.HostagePositions = slice.Filter(match.HostagePositions, func(position *HostagePosition, index int) bool { - return position.RoundNumber != round.Number - }) - match.HostageRescued = slice.Filter(match.HostageRescued, func(hostage *HostageRescued, index int) bool { - return hostage.RoundNumber != round.Number - }) - match.InfernoPositions = slice.Filter(match.InfernoPositions, func(position *InfernoPosition, index int) bool { - return position.RoundNumber != round.Number - }) - match.Kills = slice.Filter(match.Kills, func(kill *Kill, index int) bool { - return kill.RoundNumber != round.Number - }) - match.PlayerEconomies = slice.Filter(match.PlayerEconomies, func(eco *PlayerEconomy, index int) bool { - return eco.RoundNumber != round.Number - }) - match.PlayerPositions = slice.Filter(match.PlayerPositions, func(position *PlayerPosition, index int) bool { - return position.RoundNumber != round.Number - }) - match.PlayersBuy = slice.Filter(match.PlayersBuy, func(event *PlayerBuy, index int) bool { - return event.RoundNumber != round.Number - }) - match.PlayersFlashed = slice.Filter(match.PlayersFlashed, func(event *PlayerFlashed, index int) bool { - return event.RoundNumber != round.Number - }) - match.Shots = slice.Filter(match.Shots, func(event *Shot, index int) bool { - return event.RoundNumber != round.Number - }) - match.SmokesStart = slice.Filter(match.SmokesStart, func(event *SmokeStart, index int) bool { - return event.RoundNumber != round.Number - }) + match.resetRound(round.Number) } } diff --git a/pkg/api/matchzy.go b/pkg/api/matchzy.go new file mode 100644 index 0000000..94a53cc --- /dev/null +++ b/pkg/api/matchzy.go @@ -0,0 +1,110 @@ +package api + +import ( + "github.com/akiver/cs-demo-analyzer/pkg/api/constants" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common" + events "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events" + sendtables "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/sendtables" +) + +func createMatchZyAnalyzer(analyzer *Analyzer) { + match := analyzer.match + match.gameModeStr = constants.GameModeStrCompetitive + parser := analyzer.parser + matchStarted := true + // Track the end of the game to not re-compute the last round players economy as the freeze time start event is + // triggered before the final round end event. + gameEndTick := -1 + // Used to detect when the game is paused and then resumed after a backup restore + isPausedDueToBackupRestore := false + analyzer.matchStarted = func() bool { + return matchStarted + } + + parser.RegisterEventHandler(func(events.DataTablesParsed) { + serverClasses := parser.ServerClasses() + serverClasses.FindByName("CCSTeam").OnEntityCreated(func(entity sendtables.Entity) { + entity.Property("m_szClanTeamname").OnUpdate(func(value sendtables.PropertyValue) { + analyzer.updateTeamNames() + }) + }) + + serverClasses.FindByName("CCSGameRulesProxy").OnEntityCreated(func(entity sendtables.Entity) { + entity.Property("m_pGameRules.m_eRoundEndReason").OnUpdate(func(value sendtables.PropertyValue) { + if value.Int() == int(events.RoundEndReasonDraw) { + roundEndWinnerTeam := entity.PropertyValueMust("m_pGameRules.m_iRoundEndWinnerTeam").Int() + if roundEndWinnerTeam == int(common.TeamSpectators) { + // backup restore, the match is now paused, the match will resume when m_bMatchWaitingForResume is set to false + matchStarted = false + isPausedDueToBackupRestore = true + roundPlayedCount := entity.PropertyValueMust("m_pGameRules.m_totalRoundsPlayed").Int() + if roundPlayedCount == 0 { + analyzer.reset() + } else { + analyzer.resetCurrentRound() + } + } + } + }) + + entity.Property("m_pGameRules.m_bMatchWaitingForResume").OnUpdate(func(value sendtables.PropertyValue) { + // Resume the match when the backup restore is done + if isPausedDueToBackupRestore && !value.BoolVal() { + matchStarted = true + isPausedDueToBackupRestore = false + currentRound := analyzer.currentRound + currentRound.StartFrame = parser.CurrentFrame() + currentRound.StartTick = analyzer.currentTick() + } + }) + + entity.Property("m_pGameRules.m_gamePhase").OnUpdate(func(value sendtables.PropertyValue) { + if value.Int() == int(common.GamePhaseGameEnded) { + gameEndTick = analyzer.currentTick() + } + }) + }) + + parser.RegisterEventHandler(func(event events.MatchStartedChanged) { + analyzer.registerUnknownPlayers() + matchStarted = event.NewIsStarted + if matchStarted { + analyzer.reset() + currentRound := analyzer.currentRound + currentRound.StartFrame = parser.CurrentFrame() + currentRound.StartTick = analyzer.currentTick() + } else { + matchStarted = false + } + }) + + parser.RegisterEventHandler(func(event events.RoundFreezetimeChanged) { + if !analyzer.matchStarted() || gameEndTick == analyzer.currentTick() { + return + } + + // It may not be accurate to create players economy on round start because it's possible to buy + // a few ticks before the round start event and so may results in incorrect values. + // Do it when the freeze time starts, it's updated just before round start events. + if event.NewIsFreezetime { + analyzer.createPlayersEconomies() + } else { + analyzer.currentRound.FreezeTimeEndTick = analyzer.currentTick() + analyzer.currentRound.FreezeTimeEndFrame = parser.CurrentFrame() + analyzer.lastFreezeTimeEndTick = analyzer.currentTick() + } + }) + }) + + parser.RegisterEventHandler(func(event events.RoundStart) { + if !analyzer.matchStarted() || analyzer.currentTick() == 0 || len(match.Rounds) == 0 { + return + } + + analyzer.createRound() + }) + + parser.RegisterEventHandler(analyzer.defaultRoundEndOfficiallyHandler) + + parser.RegisterEventHandler(analyzer.defaultAnnouncementWinPanelMatchHandler) +} diff --git a/pkg/api/valve.go b/pkg/api/valve.go index 11ee2d5..8ce0123 100644 --- a/pkg/api/valve.go +++ b/pkg/api/valve.go @@ -41,7 +41,5 @@ func createValveAnalyzer(analyzer *Analyzer) { parser.RegisterEventHandler(analyzer.defaultRoundEndOfficiallyHandler) - parser.RegisterEventHandler(func(event events.AnnouncementWinPanelMatch) { - analyzer.updatePlayersScores() - }) + parser.RegisterEventHandler(analyzer.defaultAnnouncementWinPanelMatchHandler) } diff --git a/tests/assertion/assert_rounds.go b/tests/assertion/assert_rounds.go index 347d49d..5208782 100644 --- a/tests/assertion/assert_rounds.go +++ b/tests/assertion/assert_rounds.go @@ -3,13 +3,22 @@ package assertion import ( "testing" + "github.com/akiver/cs-demo-analyzer/internal/slice" "github.com/akiver/cs-demo-analyzer/pkg/api" "github.com/akiver/cs-demo-analyzer/tests/fake" ) func AssertRounds(t *testing.T, match *api.Match, rounds []fake.FakeRound) { - for index, expectedRound := range rounds { - round := match.Rounds[index] + for _, expectedRound := range rounds { + round, found := slice.Find(match.Rounds, func(round *api.Round) bool { + return round.Number == expectedRound.Number + }) + + if !found { + t.Errorf("round %d not found", expectedRound.Number) + continue + } + if round.Number != expectedRound.Number { t.Errorf("expected round number %d but got %d", expectedRound.Number, round.Number) } @@ -87,3 +96,10 @@ func AssertRounds(t *testing.T, match *api.Match, rounds []fake.FakeRound) { } } } + +func AssertKillCountAtRound(t *testing.T, match *api.Match, roundNumber int, killCount int) { + roundKillCount := len(match.KillsByRound()[roundNumber]) + if roundKillCount != killCount { + t.Errorf("expected %d kills round %d but got %d", killCount, roundNumber, roundKillCount) + } +} diff --git a/tests/cs2_ebot_monte_vs_og_2023_anubis_test.go b/tests/cs2_ebot_monte_vs_og_2023_anubis_test.go index 42323d2..b72e64f 100644 --- a/tests/cs2_ebot_monte_vs_og_2023_anubis_test.go +++ b/tests/cs2_ebot_monte_vs_og_2023_anubis_test.go @@ -264,7 +264,7 @@ func TestEbot_Monte_VS_OG_Roobet_Cup_2023_Anubis(t *testing.T) { TeamBStartMoney: 17100, TeamAEconomyType: constants.EconomyTypeFull, TeamBEconomyType: constants.EconomyTypeForceBuy, - EndReason: events.RoundEndReasonTargetBombed, + EndReason: events.RoundEndReasonTerroristsWin, WinnerSide: common.TeamTerrorists, TeamAScore: 3, TeamBScore: 7, diff --git a/tests/cs2_matchzy_aurora_vs_3dmax_m3_2024_anubis_test.go b/tests/cs2_matchzy_aurora_vs_3dmax_m3_2024_anubis_test.go new file mode 100644 index 0000000..200e03b --- /dev/null +++ b/tests/cs2_matchzy_aurora_vs_3dmax_m3_2024_anubis_test.go @@ -0,0 +1,184 @@ +package tests + +import ( + "testing" + + "github.com/akiver/cs-demo-analyzer/pkg/api" + "github.com/akiver/cs-demo-analyzer/pkg/api/constants" + "github.com/akiver/cs-demo-analyzer/tests/assertion" + "github.com/akiver/cs-demo-analyzer/tests/fake" + "github.com/akiver/cs-demo-analyzer/tests/testsutils" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events" +) + +// https://www.hltv.org/stats/matches/mapstatsid/179910/aurora-vs-3dmax +// - Contains a round backup restore at round 15 +// - Teams stay after knife round +func Test_MatchZy_Aurora_vs_3dmax_m3_2024_Anubis(t *testing.T) { + demoName := "matchzy_aurora_vs_3dmax_m3_anubis" + demoPath := testsutils.GetDemoPath("cs2", demoName) + match, err := api.AnalyzeDemo(demoPath, api.AnalyzeDemoOptions{ + Source: constants.DemoSourceMatchZy, + }) + if err != nil { + t.Error(err) + } + + expectedRoundCount := 24 + expectedPlayerCount := 10 + expectedScoreTeamA := 11 + expectedScoreTeamB := 13 + expectedScoreFirstHalfTeamA := 6 + expectedScoreFirstHalfTeamB := 6 + expectedScoreSecondHalfTeamA := 5 + expectedScoreSecondHalfTeamB := 7 + expectedTeamNameA := "Aurora" + expectedTeamNameB := "3DMAX" + expectedWinnerName := expectedTeamNameB + expectedMaxRounds := 24 + + if len(match.Rounds) != expectedRoundCount { + t.Errorf("expected %d rounds but got %d", expectedRoundCount, len(match.Rounds)) + } + if len(match.Players()) != expectedPlayerCount { + t.Errorf("expected %d players but got %d", expectedPlayerCount, len(match.Players())) + } + if match.TeamA.Score != expectedScoreTeamA { + t.Errorf("expected score team A to be %d got %d", expectedScoreTeamA, match.TeamA.Score) + } + if match.TeamB.Score != expectedScoreTeamB { + t.Errorf("expected score team B to be %d got %d", expectedScoreTeamB, match.TeamB.Score) + } + if match.TeamA.Name != expectedTeamNameA { + t.Errorf("expected team name A to be %s got %s", expectedTeamNameA, match.TeamA.Name) + } + if match.TeamB.Name != expectedTeamNameB { + t.Errorf("expected team name B to be %s got %s", expectedTeamNameB, match.TeamB.Name) + } + if match.TeamA.ScoreFirstHalf != expectedScoreFirstHalfTeamA { + t.Errorf("expected score first half team A to be %d got %d", expectedScoreFirstHalfTeamA, match.TeamA.ScoreFirstHalf) + } + if match.TeamB.ScoreFirstHalf != expectedScoreFirstHalfTeamB { + t.Errorf("expected score first half team B to be %d got %d", expectedScoreFirstHalfTeamB, match.TeamB.ScoreFirstHalf) + } + if match.TeamA.ScoreSecondHalf != expectedScoreSecondHalfTeamA { + t.Errorf("expected score second half team A to be %d got %d", expectedScoreSecondHalfTeamA, match.TeamA.ScoreSecondHalf) + } + if match.TeamB.ScoreSecondHalf != expectedScoreSecondHalfTeamB { + t.Errorf("expected score second half team B to be %d got %d", expectedScoreSecondHalfTeamB, match.TeamB.ScoreSecondHalf) + } + if match.Winner.Name != expectedWinnerName { + t.Errorf("expected winner to be %s but got %s", expectedWinnerName, match.Winner.Name) + } + if match.MaxRounds != expectedMaxRounds { + t.Errorf("expected max rounds to be %d but got %d", expectedMaxRounds, match.MaxRounds) + } + + var rounds = []fake.FakeRound{ + { + Number: 1, + StartTick: 5109, + StartFrame: 6155, + EndTick: 23865, + FreezeTimeEndTick: 19425, + TeamAStartMoney: 4000, + TeamBStartMoney: 4000, + TeamAEconomyType: constants.EconomyTypePistol, + TeamBEconomyType: constants.EconomyTypePistol, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 1, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 14, + StartTick: 151097, + StartFrame: 186965, + EndTick: 155102, + FreezeTimeEndTick: 152377, + TeamAStartMoney: 18300, + TeamBStartMoney: 11150, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeEco, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 8, + TeamBScore: 6, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 15, + StartTick: 160717, // end of pause after backup restore + StartFrame: 199370, + EndTick: 168197, + FreezeTimeEndTick: 161996, + TeamAStartMoney: 20000, + TeamBStartMoney: 23050, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 9, + TeamBScore: 6, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 23, + StartTick: 230999, + StartFrame: 285576, + EndTick: 236189, + FreezeTimeEndTick: 232279, + TeamAStartMoney: 18700, + TeamBStartMoney: 20550, + TeamAEconomyType: constants.EconomyTypeForceBuy, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 11, + TeamBScore: 12, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 24, + StartTick: 238429, + StartFrame: 295448, + EndTick: 245633, + FreezeTimeEndTick: 239709, + TeamAStartMoney: 20350, + TeamBStartMoney: 21750, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 11, + TeamBScore: 13, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + } + + assertion.AssertKillCountAtRound(t, match, 15, 6) + + assertion.AssertRounds(t, match, rounds) +} diff --git a/tests/cs2_matchzy_bleed_vs_parivision_2024_mirage_test.go b/tests/cs2_matchzy_bleed_vs_parivision_2024_mirage_test.go new file mode 100644 index 0000000..6e3884d --- /dev/null +++ b/tests/cs2_matchzy_bleed_vs_parivision_2024_mirage_test.go @@ -0,0 +1,937 @@ +package tests + +import ( + "testing" + + "github.com/akiver/cs-demo-analyzer/pkg/api" + "github.com/akiver/cs-demo-analyzer/pkg/api/constants" + "github.com/akiver/cs-demo-analyzer/tests/assertion" + "github.com/akiver/cs-demo-analyzer/tests/fake" + "github.com/akiver/cs-demo-analyzer/tests/testsutils" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events" +) + +// https://www.hltv.org/matches/2373609/bleed-vs-parivision-skyesports-championship-2024 +// - 2 overtimes +func Test_MatchZy_Bleed_vs_Parivision_2024_Mirage(t *testing.T) { + demoName := "matchzy_bleed_vs_parivision_2024_mirage" + demoPath := testsutils.GetDemoPath("cs2", demoName) + match, err := api.AnalyzeDemo(demoPath, api.AnalyzeDemoOptions{ + Source: constants.DemoSourceMatchZy, + }) + if err != nil { + t.Error(err) + } + + expectedRoundCount := 36 + expectedPlayerCount := 10 + expectedScoreTeamA := 17 + expectedScoreTeamB := 19 + expectedScoreFirstHalfTeamA := 7 + expectedScoreFirstHalfTeamB := 5 + expectedScoreSecondHalfTeamA := 5 + expectedScoreSecondHalfTeamB := 7 + expectedTeamNameA := "Parivision" + expectedTeamNameB := "Bleed Esports" + expectedWinnerName := expectedTeamNameB + expectedMaxRounds := 24 + + if len(match.Rounds) != expectedRoundCount { + t.Errorf("expected %d rounds but got %d", expectedRoundCount, len(match.Rounds)) + } + if len(match.Players()) != expectedPlayerCount { + t.Errorf("expected %d players but got %d", expectedPlayerCount, len(match.Players())) + } + if match.TeamA.Score != expectedScoreTeamA { + t.Errorf("expected score team A to be %d got %d", expectedScoreTeamA, match.TeamA.Score) + } + if match.TeamB.Score != expectedScoreTeamB { + t.Errorf("expected score team B to be %d got %d", expectedScoreTeamB, match.TeamB.Score) + } + if match.TeamA.Name != expectedTeamNameA { + t.Errorf("expected team name A to be %s got %s", expectedTeamNameA, match.TeamA.Name) + } + if match.TeamB.Name != expectedTeamNameB { + t.Errorf("expected team name B to be %s got %s", expectedTeamNameB, match.TeamB.Name) + } + if match.TeamA.ScoreFirstHalf != expectedScoreFirstHalfTeamA { + t.Errorf("expected score first half team A to be %d got %d", expectedScoreFirstHalfTeamA, match.TeamA.ScoreFirstHalf) + } + if match.TeamB.ScoreFirstHalf != expectedScoreFirstHalfTeamB { + t.Errorf("expected score first half team B to be %d got %d", expectedScoreFirstHalfTeamB, match.TeamB.ScoreFirstHalf) + } + if match.TeamA.ScoreSecondHalf != expectedScoreSecondHalfTeamA { + t.Errorf("expected score second half team A to be %d got %d", expectedScoreSecondHalfTeamA, match.TeamA.ScoreSecondHalf) + } + if match.TeamB.ScoreSecondHalf != expectedScoreSecondHalfTeamB { + t.Errorf("expected score second half team B to be %d got %d", expectedScoreSecondHalfTeamB, match.TeamB.ScoreSecondHalf) + } + if match.Winner.Name != expectedWinnerName { + t.Errorf("expected winner to be %s but got %s", expectedWinnerName, match.Winner.Name) + } + if match.MaxRounds != expectedMaxRounds { + t.Errorf("expected max rounds to be %d but got %d", expectedMaxRounds, match.MaxRounds) + } + + var rounds = []fake.FakeRound{ + { + Number: 1, + StartTick: 6967, + StartFrame: 8229, + EndTick: 16385, + FreezeTimeEndTick: 10198, + TeamAStartMoney: 4000, + TeamBStartMoney: 4000, + TeamAEconomyType: constants.EconomyTypePistol, + TeamBEconomyType: constants.EconomyTypePistol, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 1, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 2, + StartTick: 16705, + StartFrame: 19919, + EndTick: 25016, + FreezeTimeEndTick: 19871, + TeamAStartMoney: 18450, + TeamBStartMoney: 11000, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeForceBuy, + EndReason: events.RoundEndReasonTargetBombed, + WinnerSide: common.TeamTerrorists, + TeamAScore: 1, + TeamBScore: 1, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 3, + StartTick: 25336, + StartFrame: 30935, + EndTick: 31351, + FreezeTimeEndTick: 26616, + TeamAStartMoney: 9200, + TeamBStartMoney: 20000, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 2, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 4, + StartTick: 31671, + StartFrame: 38805, + EndTick: 38708, + FreezeTimeEndTick: 36513, + TeamAStartMoney: 20350, + TeamBStartMoney: 9700, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeForceBuy, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 3, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 5, + StartTick: 39028, + StartFrame: 48662, + EndTick: 45799, + FreezeTimeEndTick: 40308, + TeamAStartMoney: 27000, + TeamBStartMoney: 10550, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeEco, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 4, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 6, + StartTick: 46119, + StartFrame: 57429, + EndTick: 54517, + FreezeTimeEndTick: 47399, + TeamAStartMoney: 31600, + TeamBStartMoney: 22450, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTargetBombed, + WinnerSide: common.TeamTerrorists, + TeamAScore: 4, + TeamBScore: 2, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 7, + StartTick: 54837, + StartFrame: 68123, + EndTick: 62418, + FreezeTimeEndTick: 56117, + TeamAStartMoney: 25150, + TeamBStartMoney: 19450, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTargetBombed, + WinnerSide: common.TeamTerrorists, + TeamAScore: 4, + TeamBScore: 3, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 8, + StartTick: 62738, + StartFrame: 78227, + EndTick: 72005, + FreezeTimeEndTick: 64018, + TeamAStartMoney: 14450, + TeamBStartMoney: 25550, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 4, + TeamBScore: 4, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 9, + StartTick: 74245, + StartFrame: 92636, + EndTick: 79460, + FreezeTimeEndTick: 75525, + TeamAStartMoney: 17650, + TeamBStartMoney: 34900, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 4, + TeamBScore: 5, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 10, + StartTick: 79780, + StartFrame: 99813, + EndTick: 89031, + FreezeTimeEndTick: 81060, + TeamAStartMoney: 24850, + TeamBStartMoney: 37150, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 5, + TeamBScore: 5, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 11, + StartTick: 91873, + StartFrame: 115229, + EndTick: 98932, + FreezeTimeEndTick: 93153, + TeamAStartMoney: 19750, + TeamBStartMoney: 35850, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 6, + TeamBScore: 5, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 12, + StartTick: 99252, + StartFrame: 124420, + EndTick: 106566, + FreezeTimeEndTick: 100532, + TeamAStartMoney: 21250, + TeamBStartMoney: 19700, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeForceBuy, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 7, + TeamBScore: 5, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 13, + StartTick: 107526, + StartFrame: 134753, + EndTick: 118996, + FreezeTimeEndTick: 116384, + TeamAStartMoney: 4000, + TeamBStartMoney: 4000, + TeamAEconomyType: constants.EconomyTypePistol, + TeamBEconomyType: constants.EconomyTypePistol, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 8, + TeamBScore: 5, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 14, + StartTick: 119316, + StartFrame: 150214, + EndTick: 123731, + FreezeTimeEndTick: 120596, + TeamAStartMoney: 18650, + TeamBStartMoney: 10800, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeEco, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 9, + TeamBScore: 5, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 15, + StartTick: 124051, + StartFrame: 156183, + EndTick: 129940, + FreezeTimeEndTick: 125331, + TeamAStartMoney: 18000, + TeamBStartMoney: 23100, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 9, + TeamBScore: 6, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 16, + StartTick: 130260, + StartFrame: 164295, + EndTick: 137524, + FreezeTimeEndTick: 131540, + TeamAStartMoney: 17000, + TeamBStartMoney: 18000, + TeamAEconomyType: constants.EconomyTypeEco, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 9, + TeamBScore: 7, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 17, + StartTick: 137844, + StartFrame: 173916, + EndTick: 144446, + FreezeTimeEndTick: 139124, + TeamAStartMoney: 24150, + TeamBStartMoney: 26000, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTargetBombed, + WinnerSide: common.TeamTerrorists, + TeamAScore: 10, + TeamBScore: 7, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 18, + StartTick: 144766, + StartFrame: 182846, + EndTick: 150390, + FreezeTimeEndTick: 146046, + TeamAStartMoney: 19850, + TeamBStartMoney: 19700, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 8, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 19, + StartTick: 150710, + StartFrame: 190651, + EndTick: 156034, + FreezeTimeEndTick: 151990, + TeamAStartMoney: 18850, + TeamBStartMoney: 28800, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 9, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 20, + StartTick: 156354, + StartFrame: 197690, + EndTick: 163278, + FreezeTimeEndTick: 157634, + TeamAStartMoney: 23750, + TeamBStartMoney: 31200, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 10, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 21, + StartTick: 165518, + StartFrame: 209479, + EndTick: 171756, + FreezeTimeEndTick: 166798, + TeamAStartMoney: 14200, + TeamBStartMoney: 40850, + TeamAEconomyType: constants.EconomyTypeEco, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 11, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 22, + StartTick: 173996, + StartFrame: 220229, + EndTick: 181067, + FreezeTimeEndTick: 175276, + TeamAStartMoney: 26700, + TeamBStartMoney: 43100, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 11, + TeamBScore: 11, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 23, + StartTick: 181387, + StartFrame: 229600, + EndTick: 192176, + FreezeTimeEndTick: 182667, + TeamAStartMoney: 18600, + TeamBStartMoney: 31400, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTargetBombed, + WinnerSide: common.TeamTerrorists, + TeamAScore: 12, + TeamBScore: 11, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 24, + StartTick: 192496, + StartFrame: 242971, + EndTick: 198452, + FreezeTimeEndTick: 193776, + TeamAStartMoney: 24600, + TeamBStartMoney: 15200, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeForceBuy, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 12, + TeamBScore: 12, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 25, + StartTick: 199412, + StartFrame: 251751, + EndTick: 208087, + FreezeTimeEndTick: 200692, + TeamAStartMoney: 50000, + TeamBStartMoney: 50000, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 13, + TeamBScore: 12, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 1, + }, + { + Number: 26, + StartTick: 208407, + StartFrame: 262765, + EndTick: 216449, + FreezeTimeEndTick: 209687, + TeamAStartMoney: 40800, + TeamBStartMoney: 33150, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 14, + TeamBScore: 12, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 1, + }, + { + Number: 27, + StartTick: 216769, + StartFrame: 273276, + EndTick: 222637, + FreezeTimeEndTick: 218049, + TeamAStartMoney: 37350, + TeamBStartMoney: 19100, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeForceBuy, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 14, + TeamBScore: 13, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 1, + }, + { + Number: 28, + StartTick: 223597, + StartFrame: 281957, + EndTick: 231422, + FreezeTimeEndTick: 224877, + TeamAStartMoney: 50000, + TeamBStartMoney: 50000, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 14, + TeamBScore: 14, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 1, + }, + { + Number: 29, + StartTick: 231742, + StartFrame: 292365, + EndTick: 238411, + FreezeTimeEndTick: 233022, + TeamAStartMoney: 30400, + TeamBStartMoney: 41500, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 15, + TeamBScore: 14, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 1, + }, + { + Number: 30, + StartTick: 238731, + StartFrame: 301234, + EndTick: 245277, + FreezeTimeEndTick: 240011, + TeamAStartMoney: 20650, + TeamBStartMoney: 39150, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 15, + TeamBScore: 15, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 1, + }, + { + Number: 31, + StartTick: 246237, + StartFrame: 310597, + EndTick: 252225, + FreezeTimeEndTick: 247517, + TeamAStartMoney: 50000, + TeamBStartMoney: 50000, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 16, + TeamBScore: 15, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 2, + }, + { + Number: 32, + StartTick: 252545, + StartFrame: 318659, + EndTick: 259368, + FreezeTimeEndTick: 253825, + TeamAStartMoney: 39600, + TeamBStartMoney: 34050, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 16, + TeamBScore: 16, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 2, + }, + { + Number: 33, + StartTick: 259688, + StartFrame: 327835, + EndTick: 267515, + FreezeTimeEndTick: 260968, + TeamAStartMoney: 24000, + TeamBStartMoney: 27500, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 17, + TeamBScore: 16, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 2, + }, + { + Number: 34, + StartTick: 268475, + StartFrame: 338686, + EndTick: 276950, + FreezeTimeEndTick: 269755, + TeamAStartMoney: 50000, + TeamBStartMoney: 50000, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 17, + TeamBScore: 17, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 2, + }, + { + Number: 35, + StartTick: 279280, + StartFrame: 352413, + EndTick: 288023, + FreezeTimeEndTick: 280560, + TeamAStartMoney: 33750, + TeamBStartMoney: 39300, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 17, + TeamBScore: 18, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 2, + }, + { + Number: 36, + StartTick: 288343, + StartFrame: 363626, + EndTick: 295814, + FreezeTimeEndTick: 289623, + TeamAStartMoney: 23100, + TeamBStartMoney: 38800, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 17, + TeamBScore: 19, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + OvertimeNumber: 2, + }, + } + + var players = []fake.FakePlayer{ + { + SteamID64: 76561198156778414, + Name: "ArtFr0st", + KillCount: 34, + AssistCount: 1, + DeathCount: 24, + Score: 78, + Team: match.TeamA, + HeadshotCount: 5, + MvpCount: 7, + UtilityDamage: 145, + }, + { + SteamID64: 76561198127236290, + Name: "Qikert", + KillCount: 26, + AssistCount: 6, + DeathCount: 24, + Score: 65, + Team: match.TeamA, + HeadshotCount: 16, + MvpCount: 6, + UtilityDamage: 62, + }, + { + SteamID64: 76561198253670517, + Name: "BELCHONOKK", + KillCount: 19, + AssistCount: 10, + DeathCount: 24, + Score: 54, + Team: match.TeamA, + HeadshotCount: 9, + MvpCount: 2, + UtilityDamage: 199, + }, + { + SteamID64: 76561198288540801, + Name: "Patsi", + KillCount: 22, + AssistCount: 8, + DeathCount: 28, + Score: 53, + Team: match.TeamA, + HeadshotCount: 5, + MvpCount: 2, + UtilityDamage: 156, + }, + { + SteamID64: 76561198845426189, + Name: "alpha", + KillCount: 20, + AssistCount: 8, + DeathCount: 31, + Score: 53, + Team: match.TeamA, + HeadshotCount: 15, + MvpCount: 0, + UtilityDamage: 99, + }, + { + SteamID64: 76561198002708642, + Name: "jkaem", + KillCount: 37, + AssistCount: 10, + DeathCount: 24, + Score: 88, + Team: match.TeamB, + HeadshotCount: 21, + MvpCount: 7, + UtilityDamage: 204, + }, + { + SteamID64: 76561198153651861, + Name: "nawwk", + KillCount: 28, + AssistCount: 4, + DeathCount: 21, + Score: 69, + Team: match.TeamB, + HeadshotCount: 9, + MvpCount: 2, + UtilityDamage: 49, + }, + { + SteamID64: 76561197999825422, + Name: "nexa", + KillCount: 24, + AssistCount: 9, + DeathCount: 25, + Score: 64, + Team: match.TeamB, + HeadshotCount: 9, + MvpCount: 1, + UtilityDamage: 193, + }, + { + SteamID64: 76561198251984554, + Name: "CYPHER", + KillCount: 25, + AssistCount: 16, + DeathCount: 28, + Score: 74, + Team: match.TeamB, + HeadshotCount: 12, + MvpCount: 4, + UtilityDamage: 140, + }, + { + SteamID64: 76561198086945950, + Name: "hampus", + KillCount: 17, + AssistCount: 8, + DeathCount: 23, + Score: 53, + Team: match.TeamB, + HeadshotCount: 7, + MvpCount: 5, + UtilityDamage: 62, + }, + } + + assertion.AssertRounds(t, match, rounds) + assertion.AssertPlayers(t, match, players) +} diff --git a/tests/cs2_matchzy_iskandear_vs_kirill_2024_train_test.go b/tests/cs2_matchzy_iskandear_vs_kirill_2024_train_test.go new file mode 100644 index 0000000..8c56c5b --- /dev/null +++ b/tests/cs2_matchzy_iskandear_vs_kirill_2024_train_test.go @@ -0,0 +1,520 @@ +package tests + +import ( + "testing" + + "github.com/akiver/cs-demo-analyzer/pkg/api" + "github.com/akiver/cs-demo-analyzer/pkg/api/constants" + "github.com/akiver/cs-demo-analyzer/tests/assertion" + "github.com/akiver/cs-demo-analyzer/tests/fake" + "github.com/akiver/cs-demo-analyzer/tests/testsutils" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events" +) + +// - Recording started after the end of the knife round +func Test_MatchZy_Iskandear_vs_Kirill_2024_Train(t *testing.T) { + demoName := "matchzy_iskandear_vs_kirill_2024_train" + demoPath := testsutils.GetDemoPath("cs2", demoName) + match, err := api.AnalyzeDemo(demoPath, api.AnalyzeDemoOptions{ + Source: constants.DemoSourceMatchZy, + }) + if err != nil { + t.Error(err) + } + + expectedRoundCount := 22 + expectedPlayerCount := 10 + expectedScoreTeamA := 13 + expectedScoreTeamB := 9 + expectedScoreFirstHalfTeamA := 9 + expectedScoreFirstHalfTeamB := 3 + expectedScoreSecondHalfTeamA := 4 + expectedScoreSecondHalfTeamB := 6 + expectedTeamNameA := "2011_Iskandear" + expectedTeamNameB := "2011_Kirill" + expectedWinnerName := expectedTeamNameA + expectedMaxRounds := 24 + + if len(match.Rounds) != expectedRoundCount { + t.Errorf("expected %d rounds but got %d", expectedRoundCount, len(match.Rounds)) + } + if len(match.Players()) != expectedPlayerCount { + t.Errorf("expected %d players but got %d", expectedPlayerCount, len(match.Players())) + } + if match.TeamA.Score != expectedScoreTeamA { + t.Errorf("expected score team A to be %d got %d", expectedScoreTeamA, match.TeamA.Score) + } + if match.TeamB.Score != expectedScoreTeamB { + t.Errorf("expected score team B to be %d got %d", expectedScoreTeamB, match.TeamB.Score) + } + if match.TeamA.Name != expectedTeamNameA { + t.Errorf("expected team name A to be %s got %s", expectedTeamNameA, match.TeamA.Name) + } + if match.TeamB.Name != expectedTeamNameB { + t.Errorf("expected team name B to be %s got %s", expectedTeamNameB, match.TeamB.Name) + } + if match.TeamA.ScoreFirstHalf != expectedScoreFirstHalfTeamA { + t.Errorf("expected score first half team A to be %d got %d", expectedScoreFirstHalfTeamA, match.TeamA.ScoreFirstHalf) + } + if match.TeamB.ScoreFirstHalf != expectedScoreFirstHalfTeamB { + t.Errorf("expected score first half team B to be %d got %d", expectedScoreFirstHalfTeamB, match.TeamB.ScoreFirstHalf) + } + if match.TeamA.ScoreSecondHalf != expectedScoreSecondHalfTeamA { + t.Errorf("expected score second half team A to be %d got %d", expectedScoreSecondHalfTeamA, match.TeamA.ScoreSecondHalf) + } + if match.TeamB.ScoreSecondHalf != expectedScoreSecondHalfTeamB { + t.Errorf("expected score second half team B to be %d got %d", expectedScoreSecondHalfTeamB, match.TeamB.ScoreSecondHalf) + } + if match.Winner.Name != expectedWinnerName { + t.Errorf("expected winner to be %s but got %s", expectedWinnerName, match.Winner.Name) + } + if match.MaxRounds != expectedMaxRounds { + t.Errorf("expected max rounds to be %d but got %d", expectedMaxRounds, match.MaxRounds) + } + + var rounds = []fake.FakeRound{ + { + Number: 1, + StartTick: 6834, + StartFrame: 8027, + EndTick: 11534, + FreezeTimeEndTick: 7980, + TeamAStartMoney: 4000, + TeamBStartMoney: 4000, + TeamAEconomyType: constants.EconomyTypePistol, + TeamBEconomyType: constants.EconomyTypePistol, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 1, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 2, + StartTick: 11854, + StartFrame: 13817, + EndTick: 14899, + FreezeTimeEndTick: 13006, + TeamAStartMoney: 19050, + TeamBStartMoney: 11700, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeEco, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 2, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 3, + StartTick: 15219, + StartFrame: 17780, + EndTick: 19617, + FreezeTimeEndTick: 16371, + TeamAStartMoney: 19000, + TeamBStartMoney: 23200, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 3, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 4, + StartTick: 19937, + StartFrame: 23293, + EndTick: 25044, + FreezeTimeEndTick: 21089, + TeamAStartMoney: 33150, + TeamBStartMoney: 19400, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 4, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 5, + StartTick: 25364, + StartFrame: 29544, + EndTick: 31389, + FreezeTimeEndTick: 26516, + TeamAStartMoney: 38400, + TeamBStartMoney: 26350, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 4, + TeamBScore: 1, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 6, + StartTick: 31709, + StartFrame: 36933, + EndTick: 38309, + FreezeTimeEndTick: 32862, + TeamAStartMoney: 37150, + TeamBStartMoney: 23150, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 5, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 7, + StartTick: 38629, + StartFrame: 44660, + EndTick: 44492, + FreezeTimeEndTick: 39781, + TeamAStartMoney: 36700, + TeamBStartMoney: 31450, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 6, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 8, + StartTick: 44812, + StartFrame: 51947, + EndTick: 50321, + FreezeTimeEndTick: 45964, + TeamAStartMoney: 45400, + TeamBStartMoney: 26050, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 6, + TeamBScore: 2, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 9, + StartTick: 50641, + StartFrame: 58997, + EndTick: 53989, + FreezeTimeEndTick: 51793, + TeamAStartMoney: 41850, + TeamBStartMoney: 26600, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 7, + TeamBScore: 2, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 10, + StartTick: 54309, + StartFrame: 63131, + EndTick: 60682, + FreezeTimeEndTick: 55461, + TeamAStartMoney: 37150, + TeamBStartMoney: 33500, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 7, + TeamBScore: 3, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 11, + StartTick: 61002, + StartFrame: 71031, + EndTick: 66705, + FreezeTimeEndTick: 62154, + TeamAStartMoney: 41300, + TeamBStartMoney: 28900, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 8, + TeamBScore: 3, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 12, + StartTick: 67025, + StartFrame: 77977, + EndTick: 73441, + FreezeTimeEndTick: 68177, + TeamAStartMoney: 36850, + TeamBStartMoney: 24000, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 9, + TeamBScore: 3, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 13, + StartTick: 74401, + StartFrame: 86662, + EndTick: 78934, + FreezeTimeEndTick: 75553, + TeamAStartMoney: 4000, + TeamBStartMoney: 4000, + TeamAEconomyType: constants.EconomyTypePistol, + TeamBEconomyType: constants.EconomyTypePistol, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 9, + TeamBScore: 4, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 14, + StartTick: 79254, + StartFrame: 92203, + EndTick: 88102, + FreezeTimeEndTick: 80406, + TeamAStartMoney: 11500, + TeamBStartMoney: 19200, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 9, + TeamBScore: 5, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 15, + StartTick: 88422, + StartFrame: 102770, + EndTick: 97222, + FreezeTimeEndTick: 89574, + TeamAStartMoney: 20450, + TeamBStartMoney: 24950, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTargetBombed, + WinnerSide: common.TeamTerrorists, + TeamAScore: 10, + TeamBScore: 5, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 16, + StartTick: 97542, + StartFrame: 113295, + EndTick: 103715, + FreezeTimeEndTick: 98694, + TeamAStartMoney: 21200, + TeamBStartMoney: 15400, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 6, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 17, + StartTick: 104035, + StartFrame: 120738, + EndTick: 111748, + FreezeTimeEndTick: 105187, + TeamAStartMoney: 22550, + TeamBStartMoney: 23450, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 7, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 18, + StartTick: 112068, + StartFrame: 130036, + EndTick: 117015, + FreezeTimeEndTick: 113220, + TeamAStartMoney: 21450, + TeamBStartMoney: 28550, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 8, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 19, + StartTick: 117335, + StartFrame: 136026, + EndTick: 124033, + FreezeTimeEndTick: 118487, + TeamAStartMoney: 21050, + TeamBStartMoney: 24450, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 11, + TeamBScore: 8, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 20, + StartTick: 124353, + StartFrame: 144102, + EndTick: 132865, + FreezeTimeEndTick: 125505, + TeamAStartMoney: 22300, + TeamBStartMoney: 23750, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonTargetSaved, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 11, + TeamBScore: 9, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 21, + StartTick: 133185, + StartFrame: 154167, + EndTick: 141844, + FreezeTimeEndTick: 134337, + TeamAStartMoney: 20700, + TeamBStartMoney: 19500, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 12, + TeamBScore: 9, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 22, + StartTick: 142164, + StartFrame: 164519, + EndTick: 148554, + FreezeTimeEndTick: 143316, + TeamAStartMoney: 23100, + TeamBStartMoney: 14350, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeForceBuy, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 13, + TeamBScore: 9, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + } + + assertion.AssertRounds(t, match, rounds) +} diff --git a/tests/cs2_matchzy_pressure_vs_cyphin_2024_nuke_test.go b/tests/cs2_matchzy_pressure_vs_cyphin_2024_nuke_test.go new file mode 100644 index 0000000..d8868ff --- /dev/null +++ b/tests/cs2_matchzy_pressure_vs_cyphin_2024_nuke_test.go @@ -0,0 +1,543 @@ +package tests + +import ( + "testing" + + "github.com/akiver/cs-demo-analyzer/pkg/api" + "github.com/akiver/cs-demo-analyzer/pkg/api/constants" + "github.com/akiver/cs-demo-analyzer/tests/assertion" + "github.com/akiver/cs-demo-analyzer/tests/fake" + "github.com/akiver/cs-demo-analyzer/tests/testsutils" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common" + "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events" +) + +// The first round is restored 2 times +func Test_MatchZy_PressurE_vs_cyphin_2024_nuke(t *testing.T) { + demoName := "matchzy_pressure_vs_cyphin_2024_nuke" + demoPath := testsutils.GetDemoPath("cs2", demoName) + match, err := api.AnalyzeDemo(demoPath, api.AnalyzeDemoOptions{ + Source: constants.DemoSourceMatchZy, + }) + if err != nil { + t.Error(err) + } + + expectedRoundCount := 17 + expectedPlayerCount := 10 + expectedScoreTeamA := 13 + expectedScoreTeamB := 4 + expectedScoreFirstHalfTeamA := 10 + expectedScoreFirstHalfTeamB := 2 + expectedScoreSecondHalfTeamA := 3 + expectedScoreSecondHalfTeamB := 2 + expectedTeamNameA := "team_cyphin" + expectedTeamNameB := "team_PressurE" + expectedWinnerName := expectedTeamNameA + expectedMaxRounds := 24 + + if len(match.Rounds) != expectedRoundCount { + t.Errorf("expected %d rounds but got %d", expectedRoundCount, len(match.Rounds)) + } + if len(match.Players()) != expectedPlayerCount { + t.Errorf("expected %d players but got %d", expectedPlayerCount, len(match.Players())) + } + if match.TeamA.Score != expectedScoreTeamA { + t.Errorf("expected score team A to be %d got %d", expectedScoreTeamA, match.TeamA.Score) + } + if match.TeamB.Score != expectedScoreTeamB { + t.Errorf("expected score team B to be %d got %d", expectedScoreTeamB, match.TeamB.Score) + } + if match.TeamA.Name != expectedTeamNameA { + t.Errorf("expected team name A to be %s got %s", expectedTeamNameA, match.TeamA.Name) + } + if match.TeamB.Name != expectedTeamNameB { + t.Errorf("expected team name B to be %s got %s", expectedTeamNameB, match.TeamB.Name) + } + if match.TeamA.ScoreFirstHalf != expectedScoreFirstHalfTeamA { + t.Errorf("expected score first half team A to be %d got %d", expectedScoreFirstHalfTeamA, match.TeamA.ScoreFirstHalf) + } + if match.TeamB.ScoreFirstHalf != expectedScoreFirstHalfTeamB { + t.Errorf("expected score first half team B to be %d got %d", expectedScoreFirstHalfTeamB, match.TeamB.ScoreFirstHalf) + } + if match.TeamA.ScoreSecondHalf != expectedScoreSecondHalfTeamA { + t.Errorf("expected score second half team A to be %d got %d", expectedScoreSecondHalfTeamA, match.TeamA.ScoreSecondHalf) + } + if match.TeamB.ScoreSecondHalf != expectedScoreSecondHalfTeamB { + t.Errorf("expected score second half team B to be %d got %d", expectedScoreSecondHalfTeamB, match.TeamB.ScoreSecondHalf) + } + if match.Winner.Name != expectedWinnerName { + t.Errorf("expected winner to be %s but got %s", expectedWinnerName, match.Winner.Name) + } + if match.MaxRounds != expectedMaxRounds { + t.Errorf("expected max rounds to be %d but got %d", expectedMaxRounds, match.MaxRounds) + } + + var rounds = []fake.FakeRound{ + { + Number: 1, + StartTick: 17681, + StartFrame: 18329, + EndTick: 21025, + FreezeTimeEndTick: 18832, + TeamAStartMoney: 4000, + TeamBStartMoney: 4000, + TeamAEconomyType: constants.EconomyTypePistol, + TeamBEconomyType: constants.EconomyTypePistol, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 1, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 2, + StartTick: 21345, + StartFrame: 22120, + EndTick: 25468, + FreezeTimeEndTick: 22497, + TeamAStartMoney: 18500, + TeamBStartMoney: 10500, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeEco, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 2, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 3, + StartTick: 25788, + StartFrame: 26848, + EndTick: 33118, + FreezeTimeEndTick: 26940, + TeamAStartMoney: 20650, + TeamBStartMoney: 21900, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 3, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 4, + StartTick: 33438, + StartFrame: 34878, + EndTick: 39707, + FreezeTimeEndTick: 34590, + TeamAStartMoney: 24300, + TeamBStartMoney: 15400, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeEco, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 4, + TeamBScore: 0, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 5, + StartTick: 40027, + StartFrame: 41748, + EndTick: 45725, + FreezeTimeEndTick: 41179, + TeamAStartMoney: 27300, + TeamBStartMoney: 28600, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTargetBombed, + WinnerSide: common.TeamTerrorists, + TeamAScore: 4, + TeamBScore: 1, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 6, + StartTick: 46045, + StartFrame: 48177, + EndTick: 53082, + FreezeTimeEndTick: 47197, + TeamAStartMoney: 20650, + TeamBStartMoney: 21950, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 5, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 7, + StartTick: 53402, + StartFrame: 55929, + EndTick: 60316, + FreezeTimeEndTick: 54554, + TeamAStartMoney: 18550, + TeamBStartMoney: 28950, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 6, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 8, + StartTick: 60636, + StartFrame: 63661, + EndTick: 68353, + FreezeTimeEndTick: 61788, + TeamAStartMoney: 24550, + TeamBStartMoney: 27450, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 7, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 9, + StartTick: 68673, + StartFrame: 72159, + EndTick: 74328, + FreezeTimeEndTick: 69825, + TeamAStartMoney: 29750, + TeamBStartMoney: 25350, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 8, + TeamBScore: 1, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 10, + StartTick: 74648, + StartFrame: 78446, + EndTick: 79949, + FreezeTimeEndTick: 75800, + TeamAStartMoney: 30250, + TeamBStartMoney: 21100, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 8, + TeamBScore: 2, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 11, + StartTick: 80269, + StartFrame: 84409, + EndTick: 85974, + FreezeTimeEndTick: 81421, + TeamAStartMoney: 29750, + TeamBStartMoney: 20750, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 9, + TeamBScore: 2, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 12, + StartTick: 86294, + StartFrame: 90772, + EndTick: 88910, + FreezeTimeEndTick: 87446, + TeamAStartMoney: 24500, + TeamBStartMoney: 21000, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 10, + TeamBScore: 2, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamCounterTerrorists, + TeamBSide: common.TeamTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 13, + StartTick: 89870, + StartFrame: 94644, + EndTick: 93038, + FreezeTimeEndTick: 91022, + TeamAStartMoney: 4000, + TeamBStartMoney: 4000, + TeamAEconomyType: constants.EconomyTypePistol, + TeamBEconomyType: constants.EconomyTypePistol, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 11, + TeamBScore: 2, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 14, + StartTick: 93358, + StartFrame: 98409, + EndTick: 97123, + FreezeTimeEndTick: 94510, + TeamAStartMoney: 18500, + TeamBStartMoney: 10700, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeSemi, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 12, + TeamBScore: 2, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 15, + StartTick: 97443, + StartFrame: 102780, + EndTick: 101859, + FreezeTimeEndTick: 98595, + TeamAStartMoney: 22250, + TeamBStartMoney: 18700, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeForceBuy, + EndReason: events.RoundEndReasonCTWin, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 12, + TeamBScore: 3, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 16, + StartTick: 102179, + StartFrame: 107958, + EndTick: 107587, + FreezeTimeEndTick: 103331, + TeamAStartMoney: 15650, + TeamBStartMoney: 18200, + TeamAEconomyType: constants.EconomyTypeSemi, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonBombDefused, + WinnerSide: common.TeamCounterTerrorists, + TeamAScore: 12, + TeamBScore: 4, + WinnerName: expectedTeamNameB, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + { + Number: 17, + StartTick: 107907, + StartFrame: 114080, + EndTick: 116221, + FreezeTimeEndTick: 109059, + TeamAStartMoney: 24850, + TeamBStartMoney: 22600, + TeamAEconomyType: constants.EconomyTypeFull, + TeamBEconomyType: constants.EconomyTypeFull, + EndReason: events.RoundEndReasonTerroristsWin, + WinnerSide: common.TeamTerrorists, + TeamAScore: 13, + TeamBScore: 4, + WinnerName: expectedTeamNameA, + TeamASide: common.TeamTerrorists, + TeamBSide: common.TeamCounterTerrorists, + TeamAName: expectedTeamNameA, + TeamBName: expectedTeamNameB, + }, + } + var players = []fake.FakePlayer{ + { + SteamID64: 76561198005227870, + Name: "kdz", + KillCount: 15, + AssistCount: 6, + DeathCount: 6, + Score: 40, + Team: match.TeamA, + HeadshotCount: 9, + MvpCount: 4, + UtilityDamage: 109, + }, + { + SteamID64: 76561198065793422, + Name: "oer", + KillCount: 21, + AssistCount: 4, + DeathCount: 12, + Score: 48, + Team: match.TeamA, + HeadshotCount: 12, + MvpCount: 5, + UtilityDamage: 106, + }, + { + SteamID64: 76561198042767969, + Name: "dusty", + KillCount: 11, + AssistCount: 4, + DeathCount: 5, + Score: 27, + Team: match.TeamA, + HeadshotCount: 2, + MvpCount: 2, + UtilityDamage: 43, + }, + { + SteamID64: 76561198010988125, + Name: "cyphin", + KillCount: 16, + AssistCount: 6, + DeathCount: 10, + Score: 41, + Team: match.TeamA, + HeadshotCount: 10, + MvpCount: 1, + UtilityDamage: 12, + }, + { + SteamID64: 76561198082434923, + Name: "Yakov", + KillCount: 10, + AssistCount: 5, + DeathCount: 8, + Score: 29, + Team: match.TeamA, + HeadshotCount: 5, + MvpCount: 1, + UtilityDamage: 108, + }, + { + SteamID64: 76561198861089344, + Name: "bMd", + KillCount: 14, + AssistCount: 3, + DeathCount: 16, + Score: 35, + Team: match.TeamB, + HeadshotCount: 9, + MvpCount: 1, + UtilityDamage: 0, + }, + { + SteamID64: 76561197982702431, + Name: "-maV.", + KillCount: 8, + AssistCount: 1, + DeathCount: 15, + Score: 18, + Team: match.TeamB, + HeadshotCount: 3, + MvpCount: 0, + UtilityDamage: 4, + }, + { + SteamID64: 76561198208988596, + Name: "tamarac", + KillCount: 7, + AssistCount: 1, + DeathCount: 14, + Score: 23, + Team: match.TeamB, + HeadshotCount: 4, + MvpCount: 1, + UtilityDamage: 0, + }, + { + SteamID64: 76561197974414204, + Name: "PressurE", + KillCount: 7, + AssistCount: 4, + DeathCount: 15, + Score: 22, + Team: match.TeamB, + HeadshotCount: 2, + MvpCount: 2, + UtilityDamage: 0, + }, + { + SteamID64: 76561197972550155, + Name: "davetime", + KillCount: 5, + AssistCount: 3, + DeathCount: 13, + Score: 17, + Team: match.TeamB, + HeadshotCount: 4, + MvpCount: 0, + UtilityDamage: 50, + }, + } + + assertion.AssertRounds(t, match, rounds) + assertion.AssertPlayers(t, match, players) +} diff --git a/tests/csgo_ebot_immortals_vs_north_iem_katowice_2017_overpass_test.go b/tests/csgo_ebot_immortals_vs_north_iem_katowice_2017_overpass_test.go index 5550b5c..774d561 100644 --- a/tests/csgo_ebot_immortals_vs_north_iem_katowice_2017_overpass_test.go +++ b/tests/csgo_ebot_immortals_vs_north_iem_katowice_2017_overpass_test.go @@ -698,7 +698,7 @@ func TestEbot_Immortals_VS_North_IEM_Katowice_2017_Overpass(t *testing.T) { TeamBStartMoney: 24500, TeamAEconomyType: constants.EconomyTypeFull, TeamBEconomyType: constants.EconomyTypeFull, - EndReason: events.RoundEndReasonTargetBombed, + EndReason: events.RoundEndReasonTerroristsWin, WinnerSide: common.TeamTerrorists, TeamAScore: 15, TeamBScore: 15, diff --git a/tests/csgo_ebot_optic_vs_faze_iem_oakland_2017_overpass_test.go b/tests/csgo_ebot_optic_vs_faze_iem_oakland_2017_overpass_test.go index 8c71c02..c2f34d2 100644 --- a/tests/csgo_ebot_optic_vs_faze_iem_oakland_2017_overpass_test.go +++ b/tests/csgo_ebot_optic_vs_faze_iem_oakland_2017_overpass_test.go @@ -208,7 +208,7 @@ func TestEbot_Optic_VS_Faze_IEM_Oakland_2017_Overpass(t *testing.T) { TeamBStartMoney: 27000, TeamAEconomyType: constants.EconomyTypeFull, TeamBEconomyType: constants.EconomyTypeFull, - EndReason: events.RoundEndReasonTargetBombed, + EndReason: events.RoundEndReasonTerroristsWin, WinnerSide: common.TeamTerrorists, TeamAScore: 1, TeamBScore: 6, diff --git a/tests/csgo_valve_match730_003402256765125919145_0103110035_190_nuke_test.go b/tests/csgo_valve_match730_003402256765125919145_0103110035_190_nuke_test.go index 66feabc..08f455c 100644 --- a/tests/csgo_valve_match730_003402256765125919145_0103110035_190_nuke_test.go +++ b/tests/csgo_valve_match730_003402256765125919145_0103110035_190_nuke_test.go @@ -379,7 +379,7 @@ func TestValve_Match730_003402256765125919145_0103110035_190_Nuke(t *testing.T) EndTick: 67740, TeamAStartMoney: 18650, TeamBStartMoney: 27750, - EndReason: events.RoundEndReasonTargetBombed, + EndReason: events.RoundEndReasonTerroristsWin, WinnerSide: common.TeamTerrorists, TeamAScore: 2, TeamBScore: 8, @@ -525,7 +525,7 @@ func TestValve_Match730_003402256765125919145_0103110035_190_Nuke(t *testing.T) EndTick: 116582, TeamAStartMoney: 21250, TeamBStartMoney: 10450, - EndReason: events.RoundEndReasonTargetBombed, + EndReason: events.RoundEndReasonTerroristsWin, WinnerSide: common.TeamTerrorists, TeamAScore: 5, TeamBScore: 13,