package achievements import "time" // Requirement represents a single achievement requirement type Requirement struct { AchievementID uint32 `json:"achievement_id"` Name string `json:"name"` QtyRequired uint32 `json:"qty_required"` } // Reward represents a single achievement reward type Reward struct { AchievementID uint32 `json:"achievement_id"` Reward string `json:"reward"` } // UpdateItem represents a single achievement progress update type UpdateItem struct { AchievementID uint32 `json:"achievement_id"` ItemUpdate uint32 `json:"item_update"` } // Update represents achievement completion/progress data type Update struct { ID uint32 `json:"id"` CompletedDate time.Time `json:"completed_date"` UpdateItems []UpdateItem `json:"update_items"` } // NewUpdate creates a new achievement update with empty slices func NewUpdate() *Update { return &Update{ UpdateItems: make([]UpdateItem, 0), } } // AddUpdateItem adds an update item to the achievement update func (u *Update) AddUpdateItem(item UpdateItem) { u.UpdateItems = append(u.UpdateItems, item) } // Clone creates a deep copy of the achievement update func (u *Update) Clone() *Update { clone := &Update{ ID: u.ID, CompletedDate: u.CompletedDate, UpdateItems: make([]UpdateItem, len(u.UpdateItems)), } copy(clone.UpdateItems, u.UpdateItems) return clone }