From fe8abea5eb815306fe1f74da86291bb7e820fa87 Mon Sep 17 00:00:00 2001 From: autocommit Date: Thu, 16 Apr 2026 11:29:47 -0700 Subject: [PATCH] =?UTF-8?q?test(game-engine):=20=E2=9C=85=20Add=20integrat?= =?UTF-8?q?ion=20tests=20for=20happiness=20mechanics,=20including=20turn?= =?UTF-8?q?=20progression=20and=20threshold=20validation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../tests/integration/test_happiness_turn.gd | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/game/engine/tests/integration/test_happiness_turn.gd b/src/game/engine/tests/integration/test_happiness_turn.gd index e8b42cf3..13a1950d 100644 --- a/src/game/engine/tests/integration/test_happiness_turn.gd +++ b/src/game/engine/tests/integration/test_happiness_turn.gd @@ -316,3 +316,29 @@ func test_save_load_preserves_breakdown_and_status() -> void: "breakdown.status must survive round-trip") assert_eq(int(bd.get("city_unhappiness", 0)), 3, "breakdown.city_unhappiness must survive round-trip") + + +func test_luxury_count_adds_happiness_via_rust() -> void: + ## Task #6 target A: each unique luxury resource adds LUXURY_HAPPINESS (+4) + ## to the breakdown. Mirrors mc-happiness pool.rs LUXURY_HAPPINESS constant. + ## Drives Rust `GdHappiness.calculate` directly with varying luxury counts so + ## the test does not depend on GameMap/Tile setup for owned_tiles traversal. + if not ClassDB.class_exists("GdHappiness"): + pass_test("GdHappiness extension not loaded in this test run") + return + var gd: RefCounted = ClassDB.instantiate("GdHappiness") as RefCounted + var base_input: Dictionary = { + "city_count": 1, "total_citizens": 3, + "units_in_enemy_territory": 0, "ascension_active": false, + "building_happiness": 0, "unique_luxury_count": 0, + "growth_tier": "balanced", + } + var zero: Dictionary = gd.call("calculate", JSON.stringify(base_input)) + base_input["unique_luxury_count"] = 2 + var two: Dictionary = gd.call("calculate", JSON.stringify(base_input)) + assert_eq(int(zero.get("luxury_happiness", 0)), 0, + "zero luxuries must yield 0 luxury_happiness") + assert_eq(int(two.get("luxury_happiness", 0)), 8, + "two luxuries must yield +8 luxury_happiness (2 * LUXURY_HAPPINESS=4)") + assert_eq(int(two.get("total", 0)) - int(zero.get("total", 0)), 8, + "total delta for +2 luxuries must be +8")