mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
Adv 2.0 D&D Phase 12 E4b: region progression hooks + status display
Multi-region zones now default CurrentRegion to the entry region at
startExpedition; that region is also written to regions_visited so
the visited/cleared distinction is meaningful from Day 1.
MarkRegionVisited / MarkRegionBossDefeated expose the combat-link
hook surface. MarkRegionBossDefeated also flips Expedition.BossDefeated
when the cleared region's IsZoneBoss is set, since the zone-boss kill
is the same event from §7's POV (suppresses temporal accumulation,
kills further awareness pulses, etc.). setCurrentRegion is the
companion writer used by E4c's travel command.
!expedition status now shows the region line ("🗺 Region: Drow
Outpost (2/4)") with a ✓ marker when the region boss is down.
This commit is contained in:
@@ -84,6 +84,69 @@ func TestCurrentRegion_DefaultsToFirst(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarkRegionBossDefeated_FlipsZoneBoss(t *testing.T) {
|
||||
setupZoneRunTestDB(t)
|
||||
uid := id.UserID("@region-boss:example.org")
|
||||
defer cleanupExpeditions(uid)
|
||||
|
||||
exp, err := startExpedition(uid, ZoneUnderdark, "", ExpeditionSupplies{Max: 10, Current: 10, DailyBurn: 1})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Non-zone-boss region: clears region, leaves zone BossDefeated.
|
||||
if changed, err := MarkRegionBossDefeated(exp, "underdark_drow_outpost"); err != nil || !changed {
|
||||
t.Fatalf("first mark: changed=%v err=%v", changed, err)
|
||||
}
|
||||
if !IsRegionCleared(exp, "underdark_drow_outpost") {
|
||||
t.Error("region not cleared after Mark")
|
||||
}
|
||||
if exp.BossDefeated {
|
||||
t.Error("BossDefeated flipped on non-zone-boss region")
|
||||
}
|
||||
|
||||
// Idempotent.
|
||||
if changed, _ := MarkRegionBossDefeated(exp, "underdark_drow_outpost"); changed {
|
||||
t.Error("idempotent mark reported change")
|
||||
}
|
||||
|
||||
// Zone-boss region: flips BossDefeated and persists.
|
||||
if changed, err := MarkRegionBossDefeated(exp, "underdark_deep_throne"); err != nil || !changed {
|
||||
t.Fatalf("zone-boss mark: changed=%v err=%v", changed, err)
|
||||
}
|
||||
if !exp.BossDefeated {
|
||||
t.Error("BossDefeated not set after zone-boss kill")
|
||||
}
|
||||
loaded, _ := getActiveExpedition(uid)
|
||||
if !loaded.BossDefeated {
|
||||
t.Error("BossDefeated did not persist")
|
||||
}
|
||||
if !IsRegionCleared(loaded, "underdark_deep_throne") {
|
||||
t.Error("zone-boss region not in cleared list after reload")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartExpedition_DefaultsCurrentRegionForMultiRegionZone(t *testing.T) {
|
||||
setupZoneRunTestDB(t)
|
||||
uid := id.UserID("@region-default:example.org")
|
||||
defer cleanupExpeditions(uid)
|
||||
|
||||
exp, err := startExpedition(uid, ZoneAbyssPortal, "", ExpeditionSupplies{Max: 10, Current: 10, DailyBurn: 1})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if exp.CurrentRegion != "abyss_outer_rift" {
|
||||
t.Errorf("CurrentRegion = %q, want abyss_outer_rift", exp.CurrentRegion)
|
||||
}
|
||||
if !IsRegionVisited(exp, "abyss_outer_rift") {
|
||||
t.Error("entry region not in visited list")
|
||||
}
|
||||
loaded, _ := getActiveExpedition(uid)
|
||||
if loaded.CurrentRegion != "abyss_outer_rift" {
|
||||
t.Errorf("reload CurrentRegion = %q", loaded.CurrentRegion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegionStateLists_PersistAndRoundTrip(t *testing.T) {
|
||||
setupZoneRunTestDB(t)
|
||||
uid := id.UserID("@region-state:example.org")
|
||||
|
||||
Reference in New Issue
Block a user