Decouples core systems from centralized globals in favor of catalogue-based architecture and data-driven content. Key changes: - Prestige: node-based buff tech tree, graph panel, progress bar - Research: multi-worker system, per-generator research, xp generation - Ascension: meta-currency layer via multi-currency prestige resets - Buffs: refactored as generator-independent via catalogues - UI: currency panel, edge-scrolling camera + zoom, current-goal panel - Alchemy Tower: crafting building with recipe/cost system - Testing: 7 test suites (ascension, prestige, research, goals) - Content: migrated from hardcoded idles/ to gym format (tiny_sword)
147 lines
4.5 KiB
GDScript
147 lines
4.5 KiB
GDScript
@tool
|
|
extends Node
|
|
|
|
var _game_root: Node = null
|
|
|
|
func _ready() -> void:
|
|
if not Engine.is_editor_hint():
|
|
test_goals_prestige_reset()
|
|
get_tree().quit()
|
|
|
|
func test_goals_prestige_reset() -> void:
|
|
print("\n=== TEST: Goals Prestige Reset ===\n")
|
|
TestUtils.set_test_name("goals_prestige_reset")
|
|
|
|
# Load the tiny_sword scene directly
|
|
var scene = load("res://docs/gyms/tiny_sword/tiny_sword.tscn")
|
|
_game_root = scene.instantiate()
|
|
add_child(_game_root)
|
|
|
|
print("[TARGET] children_after_load: %d" % get_child_count())
|
|
|
|
var game_state: LevelGameState = _game_root.find_child("LevelGameState")
|
|
if game_state == null:
|
|
print("[ERROR] LevelGameState not found")
|
|
_print_summary(0, 1)
|
|
return
|
|
|
|
print("[TARGET] game_state_found: true")
|
|
|
|
var goals: Array[GoalData] = game_state.get_all_goals()
|
|
if goals.is_empty():
|
|
print("[ERROR] No goals found in game state")
|
|
_print_summary(0, 1)
|
|
return
|
|
|
|
var test_goal: GoalData = goals[0]
|
|
print("[TARGET] test_goal_id: %s" % String(test_goal.id))
|
|
|
|
var gold: BigNumber = BigNumber.from_float(1000000.0)
|
|
game_state.add_currency_by_id(&"gold", gold)
|
|
|
|
var is_met_before: bool = game_state.is_goal_met(test_goal)
|
|
print("[TARGET] goal_met_before_prestige: %s" % str(is_met_before))
|
|
|
|
TestUtils.assert_true(
|
|
is_met_before,
|
|
"Goal should be met before prestige (with high currency)"
|
|
)
|
|
|
|
var is_completed_before: bool = game_state.is_goal_completed(test_goal.id)
|
|
print("[TARGET] goal_completed_before_prestige: %s" % str(is_completed_before))
|
|
|
|
game_state.reset_for_prestige(true, true, [])
|
|
|
|
var is_completed_after_reset: bool = game_state.is_goal_completed(test_goal.id)
|
|
print("[TARGET] goal_completed_after_prestige: %s" % str(is_completed_after_reset))
|
|
|
|
TestUtils.assert_true(
|
|
not is_completed_after_reset,
|
|
"Goal should NOT be completed after prestige reset (BUG FIX VERIFICATION)"
|
|
)
|
|
|
|
var gold_after: BigNumber = game_state.get_currency_amount_by_id(&"gold")
|
|
print("[TARGET] gold_after_prestige: %s" % gold_after.to_string_suffix(2))
|
|
|
|
TestUtils.assert_equals(
|
|
0.0,
|
|
gold_after.mantissa,
|
|
"Gold should be reset to 0 after prestige"
|
|
)
|
|
|
|
var total_gold_after: BigNumber = game_state.get_total_currency_acquired_by_id(&"gold")
|
|
print("[TARGET] total_gold_after_prestige: %s" % total_gold_after.to_string_suffix(2))
|
|
|
|
TestUtils.assert_equals(
|
|
0.0,
|
|
total_gold_after.mantissa,
|
|
"Total gold should be reset to 0 after prestige"
|
|
)
|
|
|
|
var is_met_after: bool = game_state.is_goal_met(test_goal)
|
|
print("[TARGET] goal_met_after_prestige: %s" % str(is_met_after))
|
|
|
|
TestUtils.assert_true(
|
|
not is_met_after,
|
|
"Goal should NOT be met after prestige (currency reset to 0)"
|
|
)
|
|
|
|
var gold_for_unlock: BigNumber = BigNumber.from_float(1000000.0)
|
|
game_state.add_currency_by_id(&"gold", gold_for_unlock)
|
|
|
|
var is_met_again: bool = game_state.is_goal_met(test_goal)
|
|
print("[TARGET] goal_met_after_reaching_currency: %s" % str(is_met_again))
|
|
|
|
TestUtils.assert_true(
|
|
is_met_again,
|
|
"Goal should be met again after adding sufficient currency"
|
|
)
|
|
|
|
var is_completed_auto: bool = game_state.is_goal_completed(test_goal.id)
|
|
print("[TARGET] goal_completed_auto_check: %s" % str(is_completed_auto))
|
|
|
|
# This goal has AUTOMATIC unlock behavior, so it should be auto-completed when met
|
|
if test_goal.unlock_behavior == GoalData.UnlockBehavior.AUTOMATIC:
|
|
TestUtils.assert_true(
|
|
is_completed_auto,
|
|
"Goal with AUTOMATIC unlock should be auto-completed when met"
|
|
)
|
|
|
|
# Try manual completion (should be a no-op if already auto-completed)
|
|
game_state._complete_goal_manually(test_goal.id)
|
|
|
|
var is_completed: bool = game_state.is_goal_completed(test_goal.id)
|
|
print("[TARGET] goal_completed_after_attempt: %s" % str(is_completed))
|
|
|
|
TestUtils.assert_true(
|
|
is_completed,
|
|
"Goal should be completed (either auto or manual)"
|
|
)
|
|
|
|
game_state.reset_for_prestige(true, true, [])
|
|
|
|
var is_completed_after_second_prestige: bool = game_state.is_goal_completed(test_goal.id)
|
|
print("[TARGET] goal_completed_after_second_prestige: %s" % str(is_completed_after_second_prestige))
|
|
|
|
TestUtils.assert_true(
|
|
not is_completed_after_second_prestige,
|
|
"Goal should NOT be completed after second prestige reset"
|
|
)
|
|
|
|
var is_met_final: bool = game_state.is_goal_met(test_goal)
|
|
print("[TARGET] goal_met_final: %s" % str(is_met_final))
|
|
|
|
TestUtils.assert_true(
|
|
not is_met_final,
|
|
"Goal should NOT be met after second prestige reset"
|
|
)
|
|
|
|
_print_summary(TestUtils.get_passed(), TestUtils.get_failed())
|
|
|
|
func _print_summary(passed_count: int, failed_count: int) -> void:
|
|
TestUtils.print_result()
|
|
if failed_count == 0:
|
|
print("[RESULT] PASS")
|
|
else:
|
|
print("[RESULT] FAIL")
|