Documentation ¶
Index ¶
- Constants
- Variables
- type CreateFunc
- type GetByIDAndGameIDFunc
- type GetPlayerProgressionFunc
- type NewStatisticData
- type NotifierPlayerProgressionUpdates
- type PlayerProgression
- type PlayerProgressionLandmark
- type PlayerProgressionUpdates
- type PlayerProgressionUpdatesLandmark
- type SoftDeleteByIDAndGameIDFunc
- type Statistic
- type StorageCreateStatisticFunc
- type StorageGetPlayerProgressionFunc
- type StorageGetStatisticByIDAndGameID
- type StorageSoftDeleteStatistic
- type StorageUpdatePlayerProgressionFunc
- type UpsertPlayerProgressionFunc
Constants ¶
View Source
const ( AggregationModeSum = "SUM" AggregationModeSub = "SUB" AggregationModeMax = "MAX" AggregationModeMin = "MIN" )
Variables ¶
View Source
var ( ErrStatisticValidation = errors.New("invalid statistic") ErrInvalidStatisticID = errors.New("invalid id") ErrInvalidName = errors.New("invalid name") ErrMissingGameID = errors.New("missing game id") ErrInvalidAggregationMode = errors.New("invalid aggregation mode") ErrStatisticNotFound = errors.New("statistic not found") )
View Source
var AggregationModes = []string{ AggregationModeSum, AggregationModeSub, AggregationModeMax, AggregationModeMin, }
View Source
var (
ErrPlayerStatisticNotFound = errors.New("player statistic not found")
)
Functions ¶
This section is empty.
Types ¶
type CreateFunc ¶
type CreateFunc func(ctx context.Context, data NewStatisticData) (Statistic, error)
Create a statistic
func BuildCreateStatisticFunc ¶
func BuildCreateStatisticFunc(storageCreateStatisticFunc StorageCreateStatisticFunc) CreateFunc
type GetByIDAndGameIDFunc ¶
Get statistic by is and game id
func BuildGetStatisticByIDAndGameID ¶
func BuildGetStatisticByIDAndGameID(storageGetStatisticByIDAndGameID StorageGetStatisticByIDAndGameID) GetByIDAndGameIDFunc
type GetPlayerProgressionFunc ¶
type GetPlayerProgressionFunc func(ctx context.Context, statisticID, playerID string) (PlayerProgression, error)
Get player progression by statistic id and player id
func BuildGetPlayerProgression ¶
func BuildGetPlayerProgression(storageGetPlayerProgressionFunc StorageGetPlayerProgressionFunc) GetPlayerProgressionFunc
type NewStatisticData ¶
type NewStatisticData struct { GameID string // ID of the game responsible for the statistic Name string // Statistic name Description string // Statistic details AggregationMode string // Data aggregation mode InitialValue *float64 // Initial statistic value for players Goal *float64 // Goal value. nil means no goal Landmarks []float64 // Statistic landmarks }
type NotifierPlayerProgressionUpdates ¶
type NotifierPlayerProgressionUpdates func(ctx context.Context, statistic Statistic, progression PlayerProgression, updates PlayerProgressionUpdates) error
Notify player progression updates
type PlayerProgression ¶
type PlayerProgression struct { StartedAt time.Time // Time the player started the progression for the given statistic UpdatedAt time.Time // Last time the player updated it's statistic progress PlayerID string // Player's ID StatisticID string // Statistic ID CurrentValue *float64 // Current progression value GoalValue *float64 // Statistic's goal GoalCompleted *bool // Has the player reached the goal? GoalCompletedAt time.Time // Time the player reached the goal Landmarks []PlayerProgressionLandmark // Landmarks player progression }
type PlayerProgressionUpdates ¶
type PlayerProgressionUpdates struct { GoalJustCompleted bool // Player just reached the goal? GoalCompletedAt time.Time // Time the player reached the goal LandmarksJustCompleted []PlayerProgressionUpdatesLandmark // Landmarks that the player has just reached }
type SoftDeleteByIDAndGameIDFunc ¶
Soft delete a statistic by id and game id
func BuildSoftDeleteStatistic ¶
func BuildSoftDeleteStatistic(storageSoftDeleteStatistic StorageSoftDeleteStatistic) SoftDeleteByIDAndGameIDFunc
type Statistic ¶
type Statistic struct { CreatedAt time.Time // Time that the statistic was created UpdatedAt time.Time // Last time that the statistic was updated DeletedAt time.Time // Time that the statistic was deleted ID string // Statistic ID GameID string // ID of the game responsible for the statistic Name string // Statistic name Description string // Statistic details AggregationMode string // Data aggregation mode InitialValue *float64 // Initial statistic value for players Goal *float64 // Goal value. nil means no goal Landmarks []float64 // Statistic landmarks }
type StorageCreateStatisticFunc ¶
type StorageCreateStatisticFunc func(ctx context.Context, data NewStatisticData) (Statistic, error)
Create a statistic
type StorageGetPlayerProgressionFunc ¶
type StorageGetPlayerProgressionFunc func(ctx context.Context, statisticID, playerID string) (PlayerProgression, error)
Get player progression by statistic id and player id
type StorageGetStatisticByIDAndGameID ¶
type StorageGetStatisticByIDAndGameID func(ctx context.Context, id, gameID string) (Statistic, error)
Get statistic by is and game id
type StorageSoftDeleteStatistic ¶
Soft delete a statistic by id and game id
type StorageUpdatePlayerProgressionFunc ¶
type StorageUpdatePlayerProgressionFunc func(ctx context.Context, statistic Statistic, playerID string, value float64) (PlayerProgression, PlayerProgressionUpdates, error)
Updates the player statistic progression using the provided value
type UpsertPlayerProgressionFunc ¶
type UpsertPlayerProgressionFunc func(ctx context.Context, statistic Statistic, playerID string, value float64) error
Update player statistic progression using the provided value
func BuildUpsertPlayerProgressionFunc ¶
func BuildUpsertPlayerProgressionFunc( notifierPlayerProgressionUpdates NotifierPlayerProgressionUpdates, storageUpdatePlayerProgressionFunc StorageUpdatePlayerProgressionFunc, ) UpsertPlayerProgressionFunc
Click to show internal directories.
Click to hide internal directories.