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") 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") 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()) } }) }