systems rework: buffs, prestige graph, research, modular architecture
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)
This commit was merged in pull request #1.
This commit is contained in:
146
tests/test_research_xp_acquisition.gd
Normal file
146
tests/test_research_xp_acquisition.gd
Normal file
@@ -0,0 +1,146 @@
|
||||
extends SceneTree
|
||||
|
||||
var passed: int = 0
|
||||
var failed: int = 0
|
||||
var _game_root: Node = null
|
||||
var _test_complete: bool = false
|
||||
|
||||
func _init():
|
||||
print("\n=== TEST: Research XP Acquisition ===\n")
|
||||
TestUtils.set_test_name("research_xp_acquisition")
|
||||
|
||||
# Load tiny_sword scene
|
||||
var scene = load("res://docs/gyms/tiny_sword/tiny_sword.tscn")
|
||||
change_scene_to_packed(scene)
|
||||
|
||||
await _wait()
|
||||
|
||||
_game_root = root.get_child(0)
|
||||
|
||||
var game_state: LevelGameState = _game_root.find_child("LevelGameState")
|
||||
|
||||
if game_state == null:
|
||||
print("[ERROR] LevelGameState not found")
|
||||
_print_summary()
|
||||
_test_complete = true
|
||||
quit(1)
|
||||
return
|
||||
|
||||
# Find GoldMine CurrencyGenerator
|
||||
var gold_mine: CurrencyGenerator = null
|
||||
var world = game_state.get_node_or_null("World")
|
||||
if world:
|
||||
for child in world.get_children():
|
||||
if child.get_name() == "GoldMine":
|
||||
for gc_child in child.get_children():
|
||||
if gc_child is CurrencyGenerator:
|
||||
gold_mine = gc_child
|
||||
break
|
||||
|
||||
if gold_mine == null:
|
||||
print("[ERROR] GoldMine CurrencyGenerator node not found")
|
||||
_print_summary()
|
||||
_test_complete = true
|
||||
quit(1)
|
||||
return
|
||||
|
||||
# Give the generator initial ownership so clicks work properly
|
||||
if gold_mine.owned <= 0:
|
||||
game_state.add_currency_by_id(&"worker", BigNumber.from_float(100.0))
|
||||
await _wait(0.05)
|
||||
gold_mine.buy(1)
|
||||
await _wait(0.05)
|
||||
|
||||
# Get initial gold currency
|
||||
var initial_gold: BigNumber = game_state.get_currency_amount_by_id(&"gold")
|
||||
print("[TARGET] initial_gold: mantissa=%s, exponent=%s" % [initial_gold.mantissa, initial_gold.exponent])
|
||||
|
||||
# Get initial research XP
|
||||
var initial_xp: BigNumber = game_state.get_research_xp(&"gold_research")
|
||||
print("[TARGET] initial_research_xp: mantissa=%s, exponent=%s" % [initial_xp.mantissa, initial_xp.exponent])
|
||||
|
||||
# Set press_buys_generator to false so clicks grant currency instead of buying
|
||||
gold_mine.press_buys_generator = false
|
||||
|
||||
# Simulate clicking the generator multiple times to produce currency
|
||||
var click_count: int = 5
|
||||
for i in range(click_count):
|
||||
gold_mine._on_pressed()
|
||||
await _wait(0.1)
|
||||
|
||||
# Check gold increased
|
||||
var final_gold: BigNumber = game_state.get_currency_amount_by_id(&"gold")
|
||||
print("[TARGET] final_gold: mantissa=%s, exponent=%s" % [final_gold.mantissa, final_gold.exponent])
|
||||
|
||||
# Check owned count
|
||||
var owned: int = gold_mine.owned
|
||||
print("[TARGET] gold_mine_owned: %d" % owned)
|
||||
|
||||
# Validate research XP increased
|
||||
var final_xp: BigNumber = game_state.get_research_xp(&"gold_research")
|
||||
print("[TARGET] final_research_xp: mantissa=%s, exponent=%s" % [final_xp.mantissa, final_xp.exponent])
|
||||
|
||||
TestUtils.assert_true(
|
||||
final_xp.is_greater_than(initial_xp),
|
||||
"Research XP increased after generator clicks"
|
||||
)
|
||||
|
||||
# Test level calculation
|
||||
var level: int = game_state.get_research_level(&"gold_research")
|
||||
print("[TARGET] research_level: %d" % level)
|
||||
|
||||
TestUtils.assert_true(
|
||||
level >= 0,
|
||||
"Research level is non-negative"
|
||||
)
|
||||
|
||||
# Test research multiplier
|
||||
var multiplier: float = game_state.get_research_multiplier(&"gold_research")
|
||||
print("[TARGET] research_multiplier: %f" % multiplier)
|
||||
|
||||
TestUtils.assert_greater_than(
|
||||
multiplier,
|
||||
0.0,
|
||||
"Research multiplier is positive"
|
||||
)
|
||||
|
||||
# Test BigNumber XP progress calculation
|
||||
var research_data: ResearchData = game_state.research_catalogue.get_research_by_id(&"gold_research")
|
||||
if research_data != null:
|
||||
var progress: float = research_data.get_xp_progress(final_xp)
|
||||
print("[TARGET] xp_progress: %f" % progress)
|
||||
|
||||
TestUtils.assert_true(
|
||||
progress >= 0.0 and progress <= 1.0,
|
||||
"XP progress is between 0.0 and 1.0"
|
||||
)
|
||||
|
||||
# Test level calculation with BigNumber
|
||||
var calculated_level: int = research_data.get_level_for_xp(final_xp)
|
||||
print("[TARGET] calculated_level: %d" % calculated_level)
|
||||
|
||||
TestUtils.assert_true(
|
||||
calculated_level >= 0,
|
||||
"Calculated level is non-negative"
|
||||
)
|
||||
|
||||
_print_summary()
|
||||
_test_complete = true
|
||||
if failed == 0:
|
||||
quit(0)
|
||||
else:
|
||||
quit(1)
|
||||
|
||||
func _wait(seconds: float = 0.1) -> void:
|
||||
await create_timer(seconds).timeout
|
||||
|
||||
func _print_summary():
|
||||
TestUtils.print_result()
|
||||
passed = TestUtils.get_passed()
|
||||
failed = TestUtils.get_failed()
|
||||
|
||||
func get_passed() -> int:
|
||||
return passed
|
||||
|
||||
func get_failed() -> int:
|
||||
return failed
|
||||
Reference in New Issue
Block a user