From 2f34e75f27e5f99cfc1c5f8eaf6ab4ff2fddb1d9 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 16 Sep 2026 14:09:22 -0400 Subject: fix: reserved-loot pickup, credit pickup, payout recovery, and slot stake/bonus shutdown handling --- internal/game/credits_pickup_test.go | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 internal/game/credits_pickup_test.go (limited to 'internal/game/credits_pickup_test.go') diff --git a/internal/game/credits_pickup_test.go b/internal/game/credits_pickup_test.go new file mode 100644 index 0000000..61509e4 --- /dev/null +++ b/internal/game/credits_pickup_test.go @@ -0,0 +1,44 @@ +package game + +import ( + "testing" + + "thehouseoficarus/internal/net" +) + +// TestPickupCreditsSentinelQuantity: credit pickups request a sentinel +// quantity far above any possible ground stock. RemoveReservedItem is +// all-or-nothing and rejects such a request; the pickup must use capped +// removal so picking up 10 credits succeeds instead of answering +// "That's not yours!". +func TestPickupCreditsSentinelQuantity(t *testing.T) { + h := newHarness(t) + h.seedAccount("alice", "pw", false) + p := h.seedCharacter("alice", "alice") + h.g.RunOnOwner(func() { + p.Credits = 100 + h.g.World.AddGroundItem(p.RoomID, "credits", 10) + sess := &net.Session{Player: p, Conn: newChanConn()} + h.g.pickupCredits(sess, p, "credits") + if p.Credits != 110 { + t.Errorf("credits after pickup = %d, want 110 (output: %s)", p.Credits, sess.Conn.(*chanConn).Bytes()) + } + }) +} + +// TestGetAllPicksUpCreditsWithSentinelQuantity: the same sentinel rule for +// the "get all" path. +func TestGetAllPicksUpCreditsWithSentinelQuantity(t *testing.T) { + h := newHarness(t) + h.seedAccount("alice", "pw", false) + p := h.seedCharacter("alice", "alice") + h.g.RunOnOwner(func() { + p.Credits = 0 + h.g.World.AddGroundItem(p.RoomID, "credits", 10) + sess := &net.Session{Player: p, Conn: newChanConn()} + h.g.doGetAll(sess) + if p.Credits != 10 { + t.Errorf("credits after get-all = %d, want 10 (output: %s)", p.Credits, sess.Conn.(*chanConn).Bytes()) + } + }) +} -- cgit v1.2.3