Auto-walk: gate on fork/rest, slow cadence, credit DnD streak

Four fixes for the auto-walk loop that was re-clearing the same room
every 15 min while a fork was pending, ignoring the rest lockout, and
not counting expedition activity toward the daily streak:

- advanceOnceWithOpts / runAutopilotWalk now short-circuit to stopFork
  when NodeChoices has a pending fork. Stops phantom kills + duplicate
  loot drops + fork re-prompts on the same cleared room.
- fireExpeditionAutoRuns honors restingLockoutRemaining so the
  background ticker no longer walks through a long rest.
- autoRunCooldown 15m -> 2h, autoRunTickInterval 5m -> 15m. Auto-walk
  DMs are now a once-in-a-while ping, not a steady drip.
- markActedToday + HasActedToday recognise LastActionDate. Wired into
  !rest short/long, !expedition start/abandon, !extract, foreground
  !zone advance, and !zone go so DnD-side activity credits the streak
  even when the expedition ends before midnight.

(cherry picked from commit 9e27fd8257a4c92150ad584b393bf5a72270b82c)
This commit is contained in:
prosolis
2026-05-18 17:16:04 -07:00
parent e4518c9c39
commit 01d2329993
7 changed files with 76 additions and 5 deletions

View File

@@ -34,12 +34,13 @@ const (
// autoRunTickInterval — how often the ticker wakes. The per-expedition
// cooldown is what actually paces; the tick just has to be frequent
// enough that the cooldown is enforced cleanly.
autoRunTickInterval = 5 * time.Minute
autoRunTickInterval = 15 * time.Minute
// autoRunCooldown — minimum gap between background walks for one
// expedition. 15 min keeps the dungeon moving while leaving room for
// the player to step in and steer if they want.
autoRunCooldown = 15 * time.Minute
// expedition. 2h is the slow cadence: the dungeon still moves on its
// own while the player is away, but the auto-walk DM stays a
// once-in-a-while ping instead of a steady drip.
autoRunCooldown = 2 * time.Hour
// autoRunMinExpeditionAge — don't auto-walk a brand-new expedition;
// let the player walk the first beat manually so the opening reads
@@ -93,6 +94,14 @@ func (p *AdventurePlugin) fireExpeditionAutoRuns(now time.Time) {
if hasActiveCombatSession(uid) {
continue
}
// Honor the rest lockout — short/long rest set RestingUntil and
// foreground !expedition run checks it; background must too, or
// the auto-walk ticker fires through a long rest.
if c, cerr := LoadDnDCharacter(uid); cerr == nil && c != nil {
if restingLockoutRemaining(c) > 0 {
continue
}
}
if err := p.tryAutoRun(e, now); err != nil {
slog.Warn("expedition: autorun step", "expedition", e.ID, "err", err)
}