mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
Adv 2.0 L5d: streak/action/lifecycle migration off AdvCharacter
Ten player_meta columns: current_streak, best_streak, last_action_date, streak_decayed, action_taken_today, holiday_action_taken, combat_actions_used, harvest_actions_used, created_at, last_active_at. LifecycleState struct with HasLifecycle() marker + load/upsert/backfill/ projection helpers. New resetAllPlayerMetaDailyActions parallels the existing resetAllAdvDailyActions for the bulk midnight reset. createAdvCharacter now seeds created_at/last_active_at (CURRENT_TIMESTAMP) so player_meta rows are fully formed at creation. Mutation surface turned out to be small: only `rest` writes ActionTakenToday (combat/harvest counters are dormant in current code); plus streak halve + streak update in scheduler. Dual-writes wired at all four sites + the bulk reset. Tests: TestPlayerMetaLifecycleStateBackfill_Idempotent, TestLoadLifecycleState_FallsBackToAdvCharacter, TestUpsertPlayerMetaLifecycleState_RoundTrip, TestResetAllPlayerMetaDailyActions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -240,6 +240,11 @@ func (p *AdventurePlugin) Init() error {
|
||||
if err := backfillPlayerMetaNPCState(); err != nil {
|
||||
slog.Error("player_meta: NPC state backfill failed", "err", err)
|
||||
}
|
||||
// Adv 2.0 Phase L5d — one-shot lifecycle state backfill into player_meta.
|
||||
// Idempotent (only fills rows whose created_at is still NULL).
|
||||
if err := backfillPlayerMetaLifecycleState(); err != nil {
|
||||
slog.Error("player_meta: lifecycle state backfill failed", "err", err)
|
||||
}
|
||||
// Phase L3 — cancel any open/active legacy coop dungeon runs and
|
||||
// refund member contributions + unsettled bets. Idempotent.
|
||||
closeAndRefundLegacyCoopRuns(p.euro)
|
||||
@@ -1032,6 +1037,7 @@ func (p *AdventurePlugin) resolveRest(ctx MessageContext, char *AdventureCharact
|
||||
if err := saveAdvCharacter(char); err != nil {
|
||||
return p.SendDM(ctx.Sender, "Failed to save. Even resting is broken.")
|
||||
}
|
||||
_ = upsertPlayerMetaLifecycleState(char.UserID, lifecycleStateFromAdvChar(char))
|
||||
|
||||
logAdvActivity(char.UserID, string(AdvActivityRest), "", "rest", 0, 0, "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user