mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
Coop: per-gift voting timers (6h) — gifts resolve throughout the day
Replace the single daily-tick gift resolution with independent per-gift expiries. Each gift now has its own 6h voting window; once that elapses, the votes are tallied, the sender gets DM feedback, and the live game-room post is edited to reveal the type and resolved modifier. The modifier sits on the run waiting for the next floor resolution to merge it in. Effect: - Gifts fire continuously throughout the day rather than all at once at 08:00 UTC, surfacing sender activity in real time. - Senders get fast feedback (~6h instead of waiting for the next daily tick). - Floor resolution becomes purely "sum pending modifiers from already- resolved gifts" — cleaner separation of concerns. - Atomic per-gift apply via markCoopGiftApplied (UPDATE...WHERE applied_at IS NULL) prevents double-application on retry. Schema additions: - coop_dungeon_gifts.expires_at (when voting closes) - coop_dungeon_gifts.applied_at (when modifier merged into a floor) - Migration entries provided. Defensive backstop: floor resolution still force-resolves any gifts whose expiry was missed (e.g., bot down during the timer window). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -138,6 +138,8 @@ func runMigrations(d *sql.DB) error {
|
||||
`ALTER TABLE coop_dungeon_runs ADD COLUMN last_resolved_day INTEGER NOT NULL DEFAULT 0`,
|
||||
`ALTER TABLE coop_dungeon_members ADD COLUMN member_payout INTEGER`,
|
||||
`ALTER TABLE coop_dungeon_runs ADD COLUMN invite_post_id TEXT NOT NULL DEFAULT ''`,
|
||||
`ALTER TABLE coop_dungeon_gifts ADD COLUMN expires_at DATETIME`,
|
||||
`ALTER TABLE coop_dungeon_gifts ADD COLUMN applied_at DATETIME`,
|
||||
}
|
||||
for _, stmt := range columnMigrations {
|
||||
if _, err := d.Exec(stmt); err != nil {
|
||||
@@ -1445,7 +1447,9 @@ CREATE TABLE IF NOT EXISTS coop_dungeon_gifts (
|
||||
modifier INTEGER NOT NULL DEFAULT 0,
|
||||
post_event_id TEXT,
|
||||
sent_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
resolved_at DATETIME
|
||||
expires_at DATETIME, -- voting closes; tally fires when reached
|
||||
resolved_at DATETIME, -- vote tallied (vote_result/modifier set)
|
||||
applied_at DATETIME -- modifier merged into a floor success roll
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_coop_gifts_run_day ON coop_dungeon_gifts(run_id, day, vote_result);
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user