Add final progression to tiny sword, fixes and tweeks required

This commit is contained in:
2026-05-15 00:47:38 +02:00
parent 66666defcb
commit 738381a16b
43 changed files with 1127 additions and 339 deletions

View File

@@ -6,7 +6,7 @@ var _game_root: Node = null
func _ready() -> void:
await run()
pass # run() is called by the test runner; avoid double-execution.
func run() -> void:
@@ -118,10 +118,17 @@ func _test_purchase_flow() -> void:
var scene: PackedScene = load("res://docs/gyms/tiny_sword/tiny_sword.tscn")
_game_root = scene.instantiate()
# Use a unique save path to avoid contamination from previous test runs.
var save_path: String = "user://test_ascension_%d.json" % randi()
DirAccess.remove_absolute(ProjectSettings.globalize_path(save_path))
var gs: LevelGameState = _game_root.get_node("LevelGameState")
gs.save_file_path = save_path
add_child(_game_root)
await _wait()
var gs: LevelGameState = _game_root.find_child("LevelGameState")
gs = _game_root.find_child("LevelGameState")
if gs == null:
print("[ERROR] LevelGameState not found")
return
@@ -142,9 +149,9 @@ func _test_purchase_flow() -> void:
TestUtils.assert_false(gs.is_prestige_buff_unlocked(&"gold_boost"), "gold_boost starts locked")
TestUtils.assert_false(gs.is_prestige_buff_unlocked(&"farm_boost"), "farm_boost starts locked")
# Check can_purchase (both are root nodes with no parents, should be purchaseable)
# gold_boost is a root node (no parents), farm_boost requires gold_boost as parent.
TestUtils.assert_true(gs.can_purchase_prestige_buff(&"gold_boost"), "gold_boost is purchasable")
TestUtils.assert_true(gs.can_purchase_prestige_buff(&"farm_boost"), "farm_boost is purchasable")
TestUtils.assert_false(gs.can_purchase_prestige_buff(&"farm_boost"), "farm_boost is NOT purchasable (parent gold_boost not yet unlocked)")
# Check cost
var cost: BigNumber = gs.get_prestige_buff_cost(&"gold_boost")

View File

@@ -6,7 +6,6 @@ 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")
@@ -15,6 +14,13 @@ func test_goals_prestige_reset() -> void:
# Load the tiny_sword scene directly
var scene = load("res://docs/gyms/tiny_sword/tiny_sword.tscn")
_game_root = scene.instantiate()
# Use a unique save path to avoid contaminating the real game's save.
var save_path: String = "user://test_goals_prestige_%d.json" % randi()
DirAccess.remove_absolute(ProjectSettings.globalize_path(save_path))
var gs: LevelGameState = _game_root.get_node("LevelGameState")
gs.save_file_path = save_path
add_child(_game_root)
print("[TARGET] children_after_load: %d" % get_child_count())

View File

@@ -5,8 +5,7 @@ var failed: int = 0
var _game_root: Node = null
func _ready():
await run()
# Don't quit here - let test_runner handle it
pass # run() is called by the test runner; avoid double-execution.
func run():
print("\n=== TEST: Gold Mine Click ===\n")
@@ -15,34 +14,62 @@ func run():
# Load tiny_sword scene
var scene = load("res://docs/gyms/tiny_sword/tiny_sword.tscn")
_game_root = scene.instantiate()
# Use a unique save path to avoid contamination from previous test runs.
var save_path: String = "user://test_gold_mine_%d.json" % randi()
DirAccess.remove_absolute(ProjectSettings.globalize_path(save_path))
var gs: LevelGameState = _game_root.get_node("LevelGameState")
gs.save_file_path = save_path
add_child(_game_root)
await _wait()
var game_state: LevelGameState = _game_root.find_child("LevelGameState")
var gold_mine = _game_root.find_child("GoldMine") as CurrencyGenerator
var gold_mine_node: Node = _game_root.find_child("GoldMine")
if game_state == null:
print("[ERROR] LevelGameState not found")
_print_summary()
return
if gold_mine == null:
if gold_mine_node == null:
print("[ERROR] GoldMine node not found")
_print_summary()
return
# Record initial gold
var initial_gold: BigNumber = game_state.get_currency_amount_by_id(&"gold")
var gold_mine: CurrencyGenerator = gold_mine_node.find_child("CurrencyGenerator") as CurrencyGenerator
if gold_mine == null:
print("[ERROR] CurrencyGenerator not found under GoldMine")
_print_summary()
return
# Verify game_state is reachable and generator is available
TestUtils.assert_not_null(gold_mine.game_state, "game_state is not null")
TestUtils.assert_true(gold_mine.is_available_to_player(), "Gold Mine is available to player")
# Record initial gold (copy to avoid BigNumber reference sharing)
var initial_gold: BigNumber = BigNumber.new(
game_state.get_currency_amount_by_id(&"gold").mantissa,
game_state.get_currency_amount_by_id(&"gold").exponent
)
print("[TARGET] initial_gold: %s" % initial_gold.to_string_suffix(2))
# Temporarily set press_buys_generator to false so _on_pressed grants click currency
# (Gold Mine defaults to true which would try to buy with workers instead)
var original_press_buys: bool = gold_mine.press_buys_generator
gold_mine.press_buys_generator = false
# Simulate clicking the generator
gold_mine._on_pressed()
await _wait()
# Validate gold increased
var final_gold: BigNumber = game_state.get_currency_amount_by_id(&"gold")
# Validate gold increased (copy to avoid BigNumber reference sharing)
var final_gold: BigNumber = BigNumber.new(
game_state.get_currency_amount_by_id(&"gold").mantissa,
game_state.get_currency_amount_by_id(&"gold").exponent
)
print("[TARGET] final_gold: %s" % final_gold.to_string_suffix(2))
TestUtils.assert_greater_than(

View File

@@ -5,9 +5,7 @@ var failed: int = 0
var _game_root: Node = null
func _ready():
await run()
# Let test_runner handle exit
pass
pass # run() is called by the test runner; avoid double-execution.
func run():
print("\n=== TEST: Prestige Mechanics ===\n")
@@ -15,6 +13,13 @@ func run():
var scene = load("res://docs/gyms/tiny_sword/tiny_sword.tscn")
_game_root = scene.instantiate()
# Use a unique save path to avoid contaminating the real game's save.
var save_path: String = "user://test_prestige_%d.json" % randi()
DirAccess.remove_absolute(ProjectSettings.globalize_path(save_path))
var gs: LevelGameState = _game_root.get_node("LevelGameState")
gs.save_file_path = save_path
add_child(_game_root)
await _wait()