[FEATURE] Detailed stats about player weapon usage and hitgroups (#1)

Reviewed-on: https://git.harting.dev/CSGOWTF/csgowtfd/pulls/1
Co-authored-by: Giovanni Harting <539@idlegandalf.com>
Co-committed-by: Giovanni Harting <539@idlegandalf.com>
This commit is contained in:
2021-10-16 01:49:52 +02:00
parent 3ff65bc5d7
commit 99ec0ad1bc
37 changed files with 15185 additions and 1080 deletions

View File

@@ -28,6 +28,7 @@ func (Player) Fields() []ent.Field {
}).StructTag(`json:"-"`),
field.Time("sharecode_updated").Optional().StructTag(`json:"-"`),
field.String("auth_code").Optional().Sensitive(),
field.Time("profile_created").Optional(),
}
}

View File

@@ -19,63 +19,48 @@ func (Stats) Fields() []ent.Field {
field.Int("deaths"),
field.Int("assists"),
field.Int("headshot"),
field.Int("mvp"),
field.Uint("mvp"),
field.Int("score"),
field.JSON("extended", struct {
MultiKills struct {
Duo int `json:"duo,omitempty"`
Triple int `json:"triple,omitempty"`
Quad int `json:"quad,omitempty"`
Pent int `json:"pent,omitempty"`
} `json:"multi_kills,omitempty"`
Dmg struct {
Enemy int `json:"enemy,omitempty"`
Team int `json:"team,omitempty"`
UD struct {
HE int `json:"he,omitempty"`
Flames int `json:"flames,omitempty"`
Flash int `json:"flash,omitempty"`
Decoy int `json:"decoy,omitempty"`
Smoke int `json:"smoke,omitempty"`
} `json:"ud,omitempty"`
HitGroup struct {
Head int `json:"head,omitempty"`
Chest int `json:"chest,omitempty"`
Stomach int `json:"stomach,omitempty"`
LeftArm int `json:"left_arm,omitempty"`
RightArm int `json:"right_arm,omitempty"`
LeftLeg int `json:"left_leg,omitempty"`
RightLeg int `json:"right_leg,omitempty"`
Gear int `json:"gear,omitempty"`
} `json:"hit_group,omitempty"`
} `json:"dmg,omitempty"`
Crosshair string `json:"crosshair,omitempty"`
Color string `json:"color,omitempty"`
KAST int `json:"kast,omitempty"`
Rank struct {
Old int `json:"old,omitempty"`
New int `json:"new,omitempty"`
} `json:"rank,omitempty"`
Flash struct {
Duration struct {
Self float32 `json:"self,omitempty"`
Team float32 `json:"team,omitempty"`
Enemy float32 `json:"enemy,omitempty"`
} `json:"duration,omitempty"`
Total struct {
Team int `json:"team,omitempty"`
Enemy int `json:"enemy,omitempty"`
Self int `json:"self,omitempty"`
} `json:"total,omitempty"`
} `json:"flash,omitempty"`
}{}).Optional(),
field.Int("rank_new").Optional(),
field.Int("rank_old").Optional(),
field.Uint("mk_2").Optional(),
field.Uint("mk_3").Optional(),
field.Uint("mk_4").Optional(),
field.Uint("mk_5").Optional(),
field.Uint("dmg_enemy").Optional(),
field.Uint("dmg_team").Optional(),
field.Uint("ud_he").Optional(),
field.Uint("ud_flames").Optional(),
field.Uint("ud_flash").Optional(),
field.Uint("ud_decoy").Optional(),
field.Uint("ud_smoke").Optional(),
field.Uint("hit_group_head").Optional(),
field.Uint("hit_group_chest").Optional(),
field.Uint("hit_group_stomach").Optional(),
field.Uint("hit_group_left_arm").Optional(),
field.Uint("hit_group_right_arm").Optional(),
field.Uint("hit_group_left_leg").Optional(),
field.Uint("hit_group_right_leg").Optional(),
field.Uint("hit_group_gear").Optional(),
field.String("crosshair").Optional(),
field.Enum("color").Optional().Values("green", "yellow", "purple", "blue", "orange", "grey"),
field.Int("kast").Optional(),
field.Float32("flash_duration_self").Optional(),
field.Float32("flash_duration_team").Optional(),
field.Float32("flash_duration_enemy").Optional(),
field.Uint("flash_total_self").Optional(),
field.Uint("flash_total_team").Optional(),
field.Uint("flash_total_enemy").Optional(),
field.Uint64("match_stats").Optional(),
field.Uint64("player_stats").Optional(),
}
}
// Edges of the Stats.
func (Stats) Edges() []ent.Edge {
return []ent.Edge{
edge.From("matches", Match.Type).Ref("stats").Unique(),
edge.From("players", Player.Type).Ref("stats").Unique(),
edge.From("matches", Match.Type).Ref("stats").Unique().Field("match_stats"),
edge.From("players", Player.Type).Ref("stats").Unique().Field("player_stats"),
edge.To("weapon_stats", WeaponStats.Type),
}
}

29
ent/schema/weaponstats.go Normal file
View File

@@ -0,0 +1,29 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// WeaponStats holds the schema definition for the WeaponStats entity.
type WeaponStats struct {
ent.Schema
}
// Fields of the WeaponStats.
func (WeaponStats) Fields() []ent.Field {
return []ent.Field{
field.Uint64("victim"),
field.Uint("dmg"),
field.Int("eq_type"),
field.Int("hit_group"),
}
}
// Edges of the WeaponStats.
func (WeaponStats) Edges() []ent.Edge {
return []ent.Edge{
edge.From("stat", Stats.Type).Ref("weapon_stats").Unique(),
}
}