extends GutTest ## Tests for optional effect prompting in AbilitySystem # ============================================================================= # BUILD EFFECT DESCRIPTION TESTS # ============================================================================= func test_build_description_draw_single() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "DRAW", "amount": 1} var description = ability_system._build_effect_description(effect) assert_eq(description, "Draw 1 card", "Should describe single card draw") ability_system.free() func test_build_description_draw_multiple() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "DRAW", "amount": 3} var description = ability_system._build_effect_description(effect) assert_eq(description, "Draw 3 cards", "Should describe multiple card draw with plural") ability_system.free() func test_build_description_damage() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "DAMAGE", "amount": 5000} var description = ability_system._build_effect_description(effect) assert_eq(description, "Deal 5000 damage", "Should describe damage amount") ability_system.free() func test_build_description_power_mod_positive() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "POWER_MOD", "amount": 2000} var description = ability_system._build_effect_description(effect) assert_eq(description, "Give +2000 power", "Should describe positive power mod with +") ability_system.free() func test_build_description_power_mod_negative() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "POWER_MOD", "amount": -3000} var description = ability_system._build_effect_description(effect) assert_eq(description, "Give -3000 power", "Should describe negative power mod") ability_system.free() func test_build_description_dull() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "DULL"} var description = ability_system._build_effect_description(effect) assert_eq(description, "Dull a Forward", "Should describe dull effect") ability_system.free() func test_build_description_activate() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "ACTIVATE"} var description = ability_system._build_effect_description(effect) assert_eq(description, "Activate a card", "Should describe activate effect") ability_system.free() func test_build_description_break() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "BREAK"} var description = ability_system._build_effect_description(effect) assert_eq(description, "Break a card", "Should describe break effect") ability_system.free() func test_build_description_return() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "RETURN"} var description = ability_system._build_effect_description(effect) assert_eq(description, "Return a card to hand", "Should describe return effect") ability_system.free() func test_build_description_search() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "SEARCH"} var description = ability_system._build_effect_description(effect) assert_eq(description, "Search your deck", "Should describe search effect") ability_system.free() func test_build_description_discard_single() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "DISCARD", "amount": 1} var description = ability_system._build_effect_description(effect) assert_eq(description, "Discard 1 card", "Should describe single discard") ability_system.free() func test_build_description_discard_multiple() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "DISCARD", "amount": 2} var description = ability_system._build_effect_description(effect) assert_eq(description, "Discard 2 cards", "Should describe multiple discard with plural") ability_system.free() func test_build_description_uses_original_text() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "UNKNOWN_EFFECT", "original_text": "Do something special"} var description = ability_system._build_effect_description(effect) assert_eq(description, "Do something special", "Should use original_text for unknown effects") ability_system.free() func test_build_description_fallback() -> void: var ability_system = AbilitySystem.new() var effect = {"type": "UNKNOWN_EFFECT"} var description = ability_system._build_effect_description(effect) assert_eq(description, "Use this effect", "Should use fallback for unknown effects without original_text") ability_system.free() # ============================================================================= # OPTIONAL EFFECT FLAG TESTS # ============================================================================= func test_optional_flag_is_detected() -> void: var effect_with_optional = {"type": "DRAW", "amount": 1, "optional": true} var effect_without_optional = {"type": "DRAW", "amount": 1} assert_true(effect_with_optional.get("optional", false), "Should detect optional flag") assert_false(effect_without_optional.get("optional", false), "Should default to false") # ============================================================================= # INTEGRATION TESTS (Signal Emission) # ============================================================================= func test_optional_effect_signal_contains_correct_data() -> void: # This test verifies the signal parameters are correct var ability_system = AbilitySystem.new() var received_player_index = -1 var received_effect = {} var received_description = "" var received_callback = null ability_system.optional_effect_prompt.connect(func(player_index, effect, description, callback): received_player_index = player_index received_effect = effect received_description = description received_callback = callback ) # Manually emit to test signal structure var test_effect = {"type": "DRAW", "amount": 2, "optional": true} var test_callback = func(_accepted): pass ability_system.optional_effect_prompt.emit(0, test_effect, "Draw 2 cards", test_callback) assert_eq(received_player_index, 0, "Player index should be passed") assert_eq(received_effect.type, "DRAW", "Effect should be passed") assert_eq(received_description, "Draw 2 cards", "Description should be passed") assert_not_null(received_callback, "Callback should be passed") ability_system.free()