[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

@@ -47,6 +47,19 @@ func (f StatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
return f(ctx, mv)
}
// The WeaponStatsFunc type is an adapter to allow the use of ordinary
// function as WeaponStats mutator.
type WeaponStatsFunc func(context.Context, *ent.WeaponStatsMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f WeaponStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
mv, ok := m.(*ent.WeaponStatsMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponStatsMutation", m)
}
return f(ctx, mv)
}
// Condition is a hook condition function.
type Condition func(context.Context, ent.Mutation) bool