Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds MVP info #253

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions awpy/parser/parse_demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ type GameRound struct {
WinningTeam *string `json:"winningTeam"`
LosingTeam *string `json:"losingTeam"`
Reason string `json:"roundEndReason"`
MVPName string `json:"mvpName"`
MVPSteamID int64 `json:"mvpSteamID"`
MVPReason string `json:"mvpReason"`
MVPName *string `json:"mvpName"`
MVPSteamID *int64 `json:"mvpSteamID"`
MVPReason *string `json:"mvpReason"`
CTFreezeTimeEndEqVal int64 `json:"ctFreezeTimeEndEqVal"`
CTRoundStartEqVal int64 `json:"ctRoundStartEqVal"`
CTRoundMoneySpend int64 `json:"ctRoundSpendMoney"`
Expand Down Expand Up @@ -568,7 +568,7 @@ func convertRoundMVPReason(r events.RoundMVPReason) string {
case events.MVPReasonBombPlanted:
return "MVPReasonBombPlanted"
default:
return unknown
return "Unknown"
JanEricNitschke marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -1486,9 +1486,9 @@ func registerRoundEndHandler(demoParser *dem.Parser, currentGame *Game, currentR
func registerRoundMVPHandler(demoParser *dem.Parser, currentRound *GameRound) {
(*demoParser).RegisterEventHandler(func(e events.RoundMVPAnnouncement) {
if e.Player != nil {
currentRound.MVPName = e.Player.Name
currentRound.MVPSteamID = int64(e.Player.SteamID64)
currentRound.MVPReason = convertRoundMVPReason(e.Reason)
currentRound.MVPName = *e.Player.Name
currentRound.MVPSteamID = *int64(e.Player.SteamID64)
currentRound.MVPReason = *convertRoundMVPReason(e.Reason)
}
})
}
Expand Down
14 changes: 14 additions & 0 deletions awpy/parser/parse_demo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ import (
"testing"

common "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common"
events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
)

func TestConvertRoundMVPReason(t *testing.T) {
t.Parallel()
enumReasons := [events.MVPReasonMostEliminations, events.MVPReasonBombDefused, events.MVPReasonBombPlanted]
textReasons := []string{"MVPReasonMostEliminations", "MVPReasonBombDefused", "MVPReasonBombPlanted"}
for index, reason := enumReasons {
is := convertRoundMVPReason(reason)
want := textReasons[index]
if is != want {
t.Errorf("Round MVP reason value of %v should convert to %v, got %v", reason, want, is)
}
}
}

func TestConvertRank(t *testing.T) {
t.Parallel()
var rankInt int
Expand Down