mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 01:23:13 +01:00
feat(channelserver): implement monthly guild item claim tracking
Players could never claim monthly guild items because the handler always returned 0x01 (claimed). Now tracks per-character per-type (standard/HLC/EXC) claim timestamps in the stamps table, comparing against the current month boundary to determine claim eligibility. Adds MonthStart() to gametime, extends StampRepo with GetMonthlyClaimed/SetMonthlyClaimed, and includes schema migration 31-monthly-items.sql.
This commit is contained in:
@@ -59,3 +59,20 @@ func (r *StampRepository) Exchange(charID uint32, stampType string) (total, rede
|
||||
err = r.db.QueryRow(fmt.Sprintf("UPDATE stamps SET %s_redeemed=%s_redeemed+8 WHERE character_id=$1 RETURNING %s_total, %s_redeemed", stampType, stampType, stampType, stampType), charID).Scan(&total, &redeemed)
|
||||
return
|
||||
}
|
||||
|
||||
// GetMonthlyClaimed returns the last monthly item claim time for the given type.
|
||||
func (r *StampRepository) GetMonthlyClaimed(charID uint32, monthlyType string) (time.Time, error) {
|
||||
var claimed time.Time
|
||||
err := r.db.QueryRow(
|
||||
fmt.Sprintf("SELECT %s_claimed FROM stamps WHERE character_id=$1", monthlyType), charID,
|
||||
).Scan(&claimed)
|
||||
return claimed, err
|
||||
}
|
||||
|
||||
// SetMonthlyClaimed updates the monthly item claim time for the given type.
|
||||
func (r *StampRepository) SetMonthlyClaimed(charID uint32, monthlyType string, now time.Time) error {
|
||||
_, err := r.db.Exec(
|
||||
fmt.Sprintf("UPDATE stamps SET %s_claimed=$1 WHERE character_id=$2", monthlyType), now, charID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user