Skip to content

handleRoundMVP not firing? #632

@olehau

Description

@olehau

Just started using your library, and I have successfull parsed matches with calculations based on every event, except for this currently:

p.parser.RegisterEventHandler(p.handleRoundMVP)

Link to demo: http://replay186.valve.net/730/003798615004538732673_0358335611.dem.bz2

`func (p *Parser) handleRoundMVP(e events.RoundMVPAnnouncement) {
// DEBUG: Log that the handler was called
fmt.Printf("DEBUG MVP: handleRoundMVP called - Player: %v, Reason: %v\n",
e.Player != nil, e.Reason)

if e.Player == nil {
	fmt.Printf("DEBUG MVP: Player is nil, returning early\n")
	return
}

gameState := p.parser.GameState()
currentTick := gameState.IngameTick()
totalRoundsPlayed := gameState.TotalRoundsPlayed()

fmt.Printf("DEBUG MVP: Player=%s (SteamID: %d), Reason=%v, Tick=%d, TotalRoundsPlayed=%d\n",
	e.Player.Name, e.Player.SteamID64, e.Reason, currentTick, totalRoundsPlayed)

// MVP is announced for the round that just ended
// Since rounds aren't calculated yet during event parsing, use TotalRoundsPlayed()
// This gives us the number of completed rounds, which is the round the MVP is for
roundNumber := totalRoundsPlayed

// Safety check: ensure round number is valid
if roundNumber <= 0 {
	// If TotalRoundsPlayed is 0, try to find round from existing rounds
	// This handles edge cases where event fires before first round completes
	for _, round := range p.data.Rounds {
		if round.EndTick > 0 && currentTick >= round.EndTick {
			if round.RoundNumber > roundNumber {
				roundNumber = round.RoundNumber
			}
		}
	}
	fmt.Printf("DEBUG MVP: Round number was 0, found from rounds: %d\n", roundNumber)
}

// Map RoundMVPReason to string
mvpReason := mapMVPReason(e.Reason)

mvp := models.MVP{
	RoundNumber: roundNumber,
	SteamID:     steamIDToString(e.Player.SteamID64),
	Name:        e.Player.Name,
	Reason:      mvpReason,
}

p.data.MVPData = append(p.data.MVPData, mvp)

fmt.Printf("DEBUG MVP: Captured MVP - Round: %d, Player: %s (%s), Reason: %s, Total MVPs captured: %d\n",
	roundNumber, e.Player.Name, steamIDToString(e.Player.SteamID64), mvpReason, len(p.data.MVPData))

}
`

I have 0 events firing for the MVP announcements. Is there an issue with the implementation of this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions