205 lines
5.1 KiB
Go
205 lines
5.1 KiB
Go
package achievement
|
|
|
|
const (
|
|
TypeOrdinary = "ordinary"
|
|
TypeActivityLimited = "activity_limited"
|
|
|
|
CollectionOrdinary = "ordinary"
|
|
CycleLifetime = "lifetime"
|
|
|
|
StatusDraft = "draft"
|
|
StatusActive = "active"
|
|
StatusPaused = "paused"
|
|
StatusArchived = "archived"
|
|
|
|
ProgressStatusInProgress = "in_progress"
|
|
ProgressStatusCompleted = "completed"
|
|
|
|
UnlockStatusUnlocked = "unlocked"
|
|
|
|
EventStatusConsumed = "consumed"
|
|
EventStatusSkipped = "skipped"
|
|
EventStatusDuplicate = "duplicate"
|
|
|
|
RewardStatusPending = "pending"
|
|
RewardStatusRunning = "running"
|
|
RewardStatusGranted = "granted"
|
|
RewardStatusFailed = "failed"
|
|
|
|
BadgeFormStrip = "strip"
|
|
BadgeFormTile = "tile"
|
|
|
|
BadgeSlotProfileStrip = "profile_strip"
|
|
BadgeSlotProfileTile = "profile_tile"
|
|
BadgeSlotHonorWall = "honor_wall"
|
|
|
|
SourceAchievement = "achievement"
|
|
SourceSystemGrant = "system_grant"
|
|
SourceLevel = "level"
|
|
SourceVIP = "vip"
|
|
SourceIdentity = "identity"
|
|
|
|
AutoPinNone = "none"
|
|
AutoPinIfEmpty = "if_empty"
|
|
AutoPinAlways = "always"
|
|
|
|
GrantSourceAchievement = "achievement"
|
|
)
|
|
|
|
// Definition is an achievement rule configured by operations.
|
|
type Definition struct {
|
|
AppCode string
|
|
AchievementID string
|
|
CollectionID string
|
|
CollectionType string
|
|
AchievementType string
|
|
Title string
|
|
Description string
|
|
Status string
|
|
Version int64
|
|
PrimaryBadgeResourceID int64
|
|
RewardResourceGroupID int64
|
|
AutoPinPolicy string
|
|
HonorVisibility bool
|
|
EffectiveFromMS int64
|
|
EffectiveToMS int64
|
|
SortOrder int32
|
|
DisplayConfigJSON string
|
|
CreatedByAdminID int64
|
|
UpdatedByAdminID int64
|
|
CreatedAtMS int64
|
|
UpdatedAtMS int64
|
|
Conditions []Condition
|
|
}
|
|
|
|
// Condition is one AND condition of an achievement definition.
|
|
type Condition struct {
|
|
AppCode string
|
|
ConditionID string
|
|
AchievementID string
|
|
Version int64
|
|
MetricType string
|
|
TargetValue int64
|
|
TargetUnit string
|
|
DimensionFilterJSON string
|
|
CreatedAtMS int64
|
|
}
|
|
|
|
// UserAchievement is the App read model for one achievement and user.
|
|
type UserAchievement struct {
|
|
Definition
|
|
CycleKey string
|
|
ProgressValue int64
|
|
TargetValue int64
|
|
UserStatus string
|
|
UnlockedAtMS int64
|
|
RewardStatus string
|
|
}
|
|
|
|
// Event is a server-side fact consumed by achievements.
|
|
type Event struct {
|
|
EventID string
|
|
EventType string
|
|
SourceService string
|
|
UserID int64
|
|
MetricType string
|
|
Value int64
|
|
OccurredAtMS int64
|
|
DimensionsJSON string
|
|
}
|
|
|
|
// EventResult describes idempotent consumption outcome.
|
|
type EventResult struct {
|
|
EventID string
|
|
Status string
|
|
MatchedAchievementCount int32
|
|
UnlockedAchievementCount int32
|
|
RewardJobCount int64
|
|
}
|
|
|
|
// RewardJob is an async wallet resource group grant for achievement rewards.
|
|
type RewardJob struct {
|
|
AppCode string
|
|
RewardJobID string
|
|
UserID int64
|
|
AchievementID string
|
|
CycleKey string
|
|
ResourceGroupID int64
|
|
WalletCommandID string
|
|
WalletGrantID string
|
|
Status string
|
|
AttemptCount int32
|
|
FailureReason string
|
|
CreatedAtMS int64
|
|
UpdatedAtMS int64
|
|
}
|
|
|
|
// BadgeDisplayItem is a badge slot item rendered on profile or honor surfaces.
|
|
type BadgeDisplayItem struct {
|
|
UserID int64
|
|
Slot string
|
|
Position int32
|
|
BadgeForm string
|
|
ResourceID int64
|
|
EntitlementID string
|
|
SourceType string
|
|
SourceID string
|
|
PinMode string
|
|
UpdatedAtMS int64
|
|
}
|
|
|
|
// BadgeProfile groups badge display slots for App reads.
|
|
type BadgeProfile struct {
|
|
StripBadges []BadgeDisplayItem
|
|
ProfileTileBadges []BadgeDisplayItem
|
|
HonorBadges []BadgeDisplayItem
|
|
ServerTimeMS int64
|
|
}
|
|
|
|
// DisplayCommand updates one user-controlled badge display slot.
|
|
type DisplayCommand struct {
|
|
UserID int64
|
|
Slot string
|
|
Items []BadgeDisplayItem
|
|
CommandID string
|
|
}
|
|
|
|
// DefinitionCommand creates or updates one achievement definition.
|
|
type DefinitionCommand struct {
|
|
AchievementID string
|
|
CollectionID string
|
|
CollectionType string
|
|
AchievementType string
|
|
Title string
|
|
Description string
|
|
Status string
|
|
PrimaryBadgeResourceID int64
|
|
RewardResourceGroupID int64
|
|
AutoPinPolicy string
|
|
HonorVisibility bool
|
|
EffectiveFromMS int64
|
|
EffectiveToMS int64
|
|
SortOrder int32
|
|
DisplayConfigJSON string
|
|
OperatorAdminID int64
|
|
Conditions []ConditionCommand
|
|
}
|
|
|
|
// ConditionCommand is the writable shape for achievement conditions.
|
|
type ConditionCommand struct {
|
|
MetricType string
|
|
TargetValue int64
|
|
TargetUnit string
|
|
DimensionFilterJSON string
|
|
}
|
|
|
|
// ListQuery filters achievements for App/Admin reads.
|
|
type ListQuery struct {
|
|
UserID int64
|
|
CollectionType string
|
|
CollectionID string
|
|
Status string
|
|
Page int32
|
|
PageSize int32
|
|
}
|