Skip to content

Commit

Permalink
Merge pull request #17 from kurenkoff/feature/SB-856
Browse files Browse the repository at this point in the history
SB-856 split CsMatchSummary into structs
  • Loading branch information
patstrom authored Mar 2, 2021
2 parents ce08cc8 + 4f01333 commit 1cb86bf
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 73 deletions.
83 changes: 83 additions & 0 deletions structs/cs_match_summary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package structs

// CsMatchSummary is the summarization of a CS:GO match.
type CsMatchSummary struct {
Home int64 `json:"home"`
Away int64 `json:"away"`
MatchLength int64 `json:"match_length"`
ScoreBoard struct {
Home []CsScoreBoardEntry `json:"home"`
Away []CsScoreBoardEntry `json:"away"`
} `json:"scoreboard"`
Rounds []Round `json:"rounds"`
}

// Round is summaryization of a CS:GO round.
type Round struct {
RoundNr int64 `json:"round_nr"`
TSide int64 `json:"t_side"`
CtSide int64 `json:"ct_side"`
Winner int64 `json:"winner"`
WinReason string `json:"win_reason"`
BombEvents []BombEvent `json:"bomb_events"`
Kills []Kill `json:"kills"`
PlayerStats struct {
TSide []RoundPlayerStats `json:"t_side"`
CtSide []RoundPlayerStats `json:"ct_side"`
} `json:"player_stats"`
}

// RoundPlayerStats reflects how well a player performed in a round.
type RoundPlayerStats struct {
PlayerId int64 `json:"player_id"`
DmgGiven float64 `json:"dmg_given"`
DmgTaken float64 `json:"dmg_taken"`
Kills int64 `json:"kills"`
Assists int64 `json:"assists"`
Died bool `json:"died"`
Accuracy struct {
General float64 `json:"general"`
Headshot float64 `json:"head_shot"`
} `json:"accuracy"`
}

// BombEvent hold data about bomb event in CS:GO round
type BombEvent struct {
Type string `json:"type"`
PlayerId int64 `json:"player_id"`
RoundClock int64 `json:"round_clock"`
Pos Pos `json:"pos"`
}

// Pos hold x, y and z coordinates.
type Pos struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z"`
}

// Kill holds CS:GO kill data
type Kill struct {
RoundClock int64 `json:"round_clock"`
Damage int64 `json:"damage"`
Attacker struct {
PlayerId int64 `json:"player_id"`
Pos Pos `json:"pos"`
} `json:"attacker"`
Victim struct {
PlayerId int64 `json:"player_id"`
Pos Pos `json:"pos"`
} `json:"victim"`
Assists *int64 `json:"assist"`
Weapon Weapon `json:"weapon"`
HitGroup string `json:"hit_group"`
}

// CsScoreBoardEntry reflects a CS:GO scoreboard entry.
type CsScoreBoardEntry struct {
PlayerId int64 `json:"player_id"`
Kills int64 `json:"kills"`
Assists int64 `json:"assists"`
Deaths int64 `json:"deaths"`
Adr float64 `json:"adr"`
}
73 changes: 0 additions & 73 deletions structs/match_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,6 @@ package structs
// MatchSummary holds information about play by play statistics for a certain match.
type MatchSummary interface{}

// CsMatchSummary is the summarization of a CS:GO match.
type CsMatchSummary struct {
Home int64 `json:"home"`
Away int64 `json:"away"`
MatchLength int64 `json:"match_length"`
ScoreBoard struct {
Home []CsScoreBoardEntry `json:"home"`
Away []CsScoreBoardEntry `json:"away"`
} `json:"scoreboard"`
Rounds []struct {
RoundNr int64 `json:"round_nr"`
TSide int64 `json:"t_side"`
CtSide int64 `json:"ct_side"`
Winner int64 `json:"winner"`
WinReason string `json:"win_reason"`
BombEvents []struct {
Type string `json:"type"`
PlayerId int64 `json:"player_id"`
RoundClock int64 `json:"round_clock"`
Pos Pos `json:"pos"`
} `json:"bomb_events"`
Kills []struct {
RoundClock int64 `json:"round_clock"`
Damage int64 `json:"damage"`
Attacker struct {
PlayerId int64 `json:"player_id"`
Pos Pos `json:"pos"`
} `json:"attacker"`
Victim struct {
PlayerId int64 `json:"player_id"`
Pos Pos `json:"pos"`
} `json:"victim"`
Assists *int64 `json:"assist"`
Weapon Weapon `json:"weapon"`
HitGroup string `json:"hit_group"`
} `json:"kills"`
PlayerStats struct {
TSide []RoundPlayerStats `json:"t_side"`
CtSide []RoundPlayerStats `json:"ct_side"`
} `json:"player_stats"`
} `json:"rounds"`
}

// RoundPlayerStats reflects how well a player performed in a round.
type RoundPlayerStats struct {
PlayerId int64 `json:"player_id"`
DmgGiven float64 `json:"dmg_given"`
DmgTaken float64 `json:"dmg_taken"`
Kills int64 `json:"kills"`
Assists int64 `json:"assists"`
Died bool `json:"died"`
Accuracy struct {
General float64 `json:"general"`
Headshot float64 `json:"head_shot"`
} `json:"accuracy"`
}

// Pos hold x, y and z coordinates.
type Pos struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z"`
}

// CsScoreBoardEntry reflects a CS:GO scoreboard entry.
type CsScoreBoardEntry struct {
PlayerId int64 `json:"player_id"`
Kills int64 `json:"kills"`
Assists int64 `json:"assists"`
Deaths int64 `json:"deaths"`
Adr float64 `json:"adr"`
}

type LolMatchSummary struct {
MatchLength int64 `json:"match_length"`
BlueRoster struct {
Expand Down

0 comments on commit 1cb86bf

Please sign in to comment.