mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-28 18:42:39 +01:00
feat(channelserver): add daily noon resets for gacha stepup and guild RP
Gacha stepup progress now resets when queried after the most recent noon boundary, using a new created_at column on gacha_stepup. Guild member rp_today rolls into rp_yesterday lazily when members are enumerated after noon, using a new rp_reset_at column on guilds. Both follow the established lazy-reset pattern from the cafe handler.
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package channelserver
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"erupe-ce/common/byteframe"
|
||||
"erupe-ce/network/mhfpacket"
|
||||
"math/rand"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -306,8 +310,25 @@ func handleMsgMhfPlayStepupGacha(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
func handleMsgMhfGetStepupStatus(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetStepupStatus)
|
||||
// TODO: Reset daily (noon)
|
||||
step, _ := s.server.gachaRepo.GetStepupStep(pkt.GachaID, s.charID)
|
||||
|
||||
// Compute the most recent noon boundary
|
||||
midday := TimeMidnight().Add(12 * time.Hour)
|
||||
if TimeAdjusted().Before(midday) {
|
||||
midday = midday.Add(-24 * time.Hour)
|
||||
}
|
||||
|
||||
step, createdAt, err := s.server.gachaRepo.GetStepupWithTime(pkt.GachaID, s.charID)
|
||||
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||
s.logger.Error("Failed to get gacha stepup state", zap.Error(err))
|
||||
}
|
||||
// Reset stale stepup progress (created before the most recent noon)
|
||||
if err == nil && createdAt.Before(midday) {
|
||||
if err := s.server.gachaRepo.DeleteStepup(pkt.GachaID, s.charID); err != nil {
|
||||
s.logger.Error("Failed to reset stale gacha stepup", zap.Error(err))
|
||||
}
|
||||
step = 0
|
||||
}
|
||||
|
||||
hasEntry, _ := s.server.gachaRepo.HasEntryType(pkt.GachaID, step)
|
||||
if !hasEntry {
|
||||
if err := s.server.gachaRepo.DeleteStepup(pkt.GachaID, s.charID); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user