Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.ralphex/
.mcp.json
docs/plans/
docs/implementation-plan.md
*
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
.mcp.json
/.ralphex/
/.bin/
/dist/
Expand Down
5 changes: 5 additions & 0 deletions docs/tool-contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@
"type": ["integer", "null"],
"minimum": 0
},
"imp": {
"type": ["number", "null"],
"description": "STRATZ Individual Match Performance (IMP) for this player when upstream provides it. Null means unavailable for the match/player."
},
"won": {
"type": "boolean"
}
Expand All @@ -447,6 +451,7 @@
"assists",
"networth",
"level",
"imp",
"won"
],
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@
"minimum": 1,
"type": "integer"
},
"imp": {
"description": "STRATZ Individual Match Performance (IMP) for this player when upstream provides it. Null means unavailable for the match/player.",
"type": [
"number",
"null"
]
},
"kills": {
"minimum": 0,
"type": "integer"
Expand Down Expand Up @@ -538,6 +545,7 @@
"assists",
"networth",
"level",
"imp",
"won"
],
"type": "object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@
"minimum": 1,
"type": "integer"
},
"imp": {
"description": "STRATZ Individual Match Performance (IMP) for this player when upstream provides it. Null means unavailable for the match/player.",
"type": [
"number",
"null"
]
},
"kills": {
"minimum": 0,
"type": "integer"
Expand Down Expand Up @@ -534,6 +541,7 @@
"assists",
"networth",
"level",
"imp",
"won"
],
"type": "object"
Expand Down
21 changes: 11 additions & 10 deletions internal/contracts/zz_generated.contracts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/domain/playermatch/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func mapMatch(source *upstreamMatch, detail contracts.DetailLevel) contracts.Mat
Assists: maxZero(player.Assists),
Networth: nonNegative(player.Networth),
Level: nonNegative(player.Level),
Imp: player.IMP,
Won: won,
})
}
Expand Down
8 changes: 7 additions & 1 deletion internal/domain/playermatch/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func TestMatchDetailLevelsAndDataNotReady(t *testing.T) {
"leagueId":null,
"gameVersionId":"7.XX",
"parsedDateTime":1781728000,
"players":[{"steamAccountId":39734272,"heroId":5,"isRadiant":true,"playerSlot":0,"kills":10,"deaths":2,"assists":15,"networth":20000,"level":25}],
"players":[{"steamAccountId":39734272,"heroId":5,"isRadiant":true,"playerSlot":0,"kills":10,"deaths":2,"assists":15,"networth":20000,"level":25,"imp":8.75}],
"playbackData":{
"buildingEvents":[{"time":100,"type":"TOWER","isRadiant":true,"npcId":42}],
"roshanEvents":[{"time":200}],
Expand All @@ -223,6 +223,9 @@ func TestMatchDetailLevelsAndDataNotReady(t *testing.T) {
if request.OperationName != test.wantOperationName {
t.Fatalf("operation = %q", request.OperationName)
}
if !strings.Contains(request.Query, "imp") {
t.Fatalf("match query is missing player IMP: %s", request.Query)
}
if test.wantObjectives && !strings.Contains(request.Query, "buildingEvents") {
t.Fatalf("standard query is missing playback objectives: %s", request.Query)
}
Expand All @@ -240,6 +243,9 @@ func TestMatchDetailLevelsAndDataNotReady(t *testing.T) {
(result.Data.Timeline != nil) != test.wantFull {
t.Fatalf("match detail mapping = %#v", result.Data)
}
if len(result.Data.Players) != 1 || result.Data.Players[0].Imp == nil || *result.Data.Players[0].Imp != 8.75 {
t.Fatalf("player IMP = %#v", result.Data.Players)
}
if test.wantObjectives && len(result.Data.Objectives) != 3 {
t.Fatalf("objectives = %#v", result.Data.Objectives)
}
Expand Down
19 changes: 10 additions & 9 deletions internal/domain/playermatch/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ func (value *upstreamEnumID) UnmarshalJSON(data []byte) error {
}

type upstreamMatchPlayer struct {
SteamAccountID *int64 `json:"steamAccountId"`
HeroID int64 `json:"heroId"`
IsRadiant bool `json:"isRadiant"`
PlayerSlot int64 `json:"playerSlot"`
Kills int64 `json:"kills"`
Deaths int64 `json:"deaths"`
Assists int64 `json:"assists"`
Networth *int64 `json:"networth"`
Level *int64 `json:"level"`
SteamAccountID *int64 `json:"steamAccountId"`
HeroID int64 `json:"heroId"`
IsRadiant bool `json:"isRadiant"`
PlayerSlot int64 `json:"playerSlot"`
Kills int64 `json:"kills"`
Deaths int64 `json:"deaths"`
Assists int64 `json:"assists"`
Networth *int64 `json:"networth"`
Level *int64 `json:"level"`
IMP *float64 `json:"imp"`
}

type upstreamEvent struct {
Expand Down
Loading
Loading