#162 - a single tap bought a research node outright. One physical tap arrives TWICE: Godot emulates a mouse button from every touch AND a touch from every mouse button, both project settings are on, and the menu's dispatcher routes InputEventScreenTouch and InputEventMouseButton alike to the tree. The second arrival found the node already selected and took itself for the confirming tap. Measured, not reasoned about - one tap produced two picks and two confirms. What is ignored is specifically the TWIN: same frame, same place, arriving through the other input kind. Deduping on frame and position alone also swallowed two genuine taps in one frame, which the test caught. #164 - the build menu predicted a caption's height from the COLUMN WIDTH: wide column, assume one line. Right for most names and wrong for the long ones, so "Spacial Workshop" wrapped onto the price beneath it. Captions are now measured against the font that draws them, and prices sized from PriceTag.wanted_height(), which existed for exactly this and was not being asked. Prices are set before anything is measured, because the old order laid out first and priced afterwards. The ship lab: its buy button is gone and a second tap on an option buys it, the same rule as the research tree; the explanation drops into the room that freed; research points move up into the resource table, where everything else being spent already is; the second row of options is placed from the first row's measured bottom rather than a constant; and the vessel strip is spaced from the panel's own width, so the eighth vessel is no longer half off the right edge. #160 - the quest panel was drawn BEFORE the sticks and the pivot pair, so they sat on top of it. Moved after them, under the narration banner. Its title rule ran straight through the close button; the header band is now as tall as that button. #161 - the prologue widens the formation into a freight convoy by writing over GameState.formation, and nothing put it back. The player flew the convoy's 600-unit spread for the rest of the game - a shape nobody chose, which reads as the fleet having drifted apart. #163 - a quest to station a vessel at the outpost, after the one that asks for the outpost. Building one and crewing it are different acts, and an empty outpost holds nothing. #165 - the gas bomb's blast and a vessel arriving fast both damage a structure. The blast used to stop politely at anything the player owned, which made a bomb dropped on a besieged mothership a free way to sweep the attackers off it. Collisions are caught on ENTRY, not on the 0.7s strike tick: a vessel is only moving fast for the instant it arrives, and a ship sent in at 900 did no damage at all until this moved. Docking is free - the fleet sits on its own mothership constantly to bank ore - and garrison vessels are exempt outright, because they launch from their outpost and re-dock with it at speed. The suite caught that one: the ram rule was destroying the garrison as it launched. Suite 153/153. Four tests changed because what they pinned moved: the lab's buy button, the intro's formation, the research tree's tap delivery, and the build menu's own preview. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
4c920f10b0
commit
3fcc26c8bc
18 changed files with 645 additions and 173 deletions
|
|
@ -1,22 +1,22 @@
|
|||
extends Node2D
|
||||
|
||||
# Preview, not a test. Opens the build menu itself, so the three-row layout
|
||||
# added for the Transport Hub (#18) can be checked for fit on the real phone
|
||||
# viewport - every button, label and price moved, and a bad offset is
|
||||
# invisible to a headless test.
|
||||
# Preview, not a test - the build menu with every structure unlocked, so the
|
||||
# long captions and the three-resource prices are on screen together.
|
||||
#
|
||||
# bash tests/screenshot.sh res://tests/_build_menu_preview.tscn /tmp/menu.png 20 720x1280
|
||||
# bash tests/screenshot.sh res://tests/_build_menu_preview.tscn /tmp/b.png 25 720x1280
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
GameState.buildings.clear()
|
||||
GameState.extractors.clear()
|
||||
GameState.rocks = 500
|
||||
# Everything researched, so nothing is greyed out and the whole menu is
|
||||
# legible at full strength.
|
||||
# Partly researched, to show the menu repacking around what is hidden.
|
||||
GameState.unlocked = ["shipyards", "logistics"]
|
||||
GameState.reset_progression()
|
||||
for node in GameState.SKILL_TREE:
|
||||
if not GameState.is_unlocked(String(node.id)):
|
||||
GameState.unlocked.append(String(node.id))
|
||||
for resource_type in GameState.resource_types():
|
||||
GameState.bank_inventory.set_amount(resource_type, 1500)
|
||||
var main: Node = load("res://world/Main.tscn").instantiate()
|
||||
add_child(main)
|
||||
main.get_node("UI/BuildMenu").visible = true
|
||||
main.get_node("BuildController")._refresh_build_status()
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("AsteroidField").set_process(false)
|
||||
var build: Node = main.get_node("BuildController")
|
||||
build.build_menu.visible = true
|
||||
build._refresh_build_status()
|
||||
|
|
|
|||
134
tests/test_building_collateral.gd
Normal file
134
tests/test_building_collateral.gd
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
extends SceneTree
|
||||
|
||||
# Headless gameplay test: run with
|
||||
# godot --headless -s res://tests/test_building_collateral.gd
|
||||
# Forgejo #165: a gas bomb and a vessel flying fast enough both damage a
|
||||
# structure. The blast used to stop politely at anything the player owned,
|
||||
# which made a bomb dropped on a besieged mothership a free way to sweep the
|
||||
# attackers off it.
|
||||
#
|
||||
# Covers:
|
||||
# A. a bomb landing on a structure damages it
|
||||
# B. a bomb landing clear of it does not - the radius is the radius, and
|
||||
# this is a weapon that has to be aimed
|
||||
# C. a vessel resting against a structure does NOT damage it. The fleet
|
||||
# sits on its own mothership constantly to bank ore; if that hurt, the
|
||||
# game's own economy loop would grind its buildings down
|
||||
# D. a vessel arriving fast does
|
||||
|
||||
var game_state: Node
|
||||
var main: Node
|
||||
var fleet: Node
|
||||
var building_id: int = 0
|
||||
var stage: int = 0
|
||||
var elapsed: float = 0.0
|
||||
var hp_before: int = 0
|
||||
const BUILDING_AT := Vector2(1200.0, 0.0)
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
game_state = root.get_node("GameState")
|
||||
game_state.buildings.clear()
|
||||
game_state.extractors.clear()
|
||||
game_state.reset_progression()
|
||||
main = load("res://world/Main.tscn").instantiate()
|
||||
root.add_child(main)
|
||||
current_scene = main
|
||||
fleet = main.get_node("Fleet")
|
||||
|
||||
|
||||
func _hp() -> int:
|
||||
return int(game_state.find_building(building_id).get("hp", 0))
|
||||
|
||||
|
||||
func _detonate_at(at: Vector2) -> void:
|
||||
var bomb: Node2D = load("res://vfx/GasBombEffect.gd").new()
|
||||
main.add_child(bomb)
|
||||
bomb.target = at
|
||||
bomb.damage = 6
|
||||
bomb._explode()
|
||||
bomb.queue_free()
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
elapsed += delta
|
||||
match stage:
|
||||
0:
|
||||
if elapsed < 0.4:
|
||||
return false
|
||||
main.get_node("EnemySpawner").set_process(false)
|
||||
main.get_node("AsteroidField").set_process(false)
|
||||
for hazard in get_nodes_in_group("asteroids") + get_nodes_in_group("enemies"):
|
||||
if is_instance_valid(hazard):
|
||||
hazard.queue_free()
|
||||
main.get_node("BuildingField").place(GameState.BUILDING_MOTHERSHIP, BUILDING_AT)
|
||||
building_id = int(game_state.buildings[0].id)
|
||||
if _hp() <= 0:
|
||||
return _fail("the structure has no hit points to lose")
|
||||
stage = 1
|
||||
elapsed = 0.0
|
||||
return false
|
||||
1:
|
||||
if elapsed < 0.2:
|
||||
return false
|
||||
# --- B. a bomb well clear of it does nothing ------------------
|
||||
hp_before = _hp()
|
||||
_detonate_at(BUILDING_AT + Vector2(900.0, 0.0))
|
||||
if _hp() != hp_before:
|
||||
return _fail("a bomb 900 away still damaged the structure")
|
||||
print("a bomb clear of the structure leaves it alone")
|
||||
|
||||
# --- A. a bomb on top of it does --------------------------------
|
||||
_detonate_at(BUILDING_AT)
|
||||
if _hp() >= hp_before:
|
||||
return _fail("a bomb landing on the structure did not damage it (hp %d)" % _hp())
|
||||
print("a bomb on the structure took it from %d to %d" % [hp_before, _hp()])
|
||||
|
||||
# --- C. resting against it is free ------------------------------
|
||||
hp_before = _hp()
|
||||
fleet.spawn_ships(1, BUILDING_AT, PackedStringArray([GameState.VESSEL_INTERCEPTOR]))
|
||||
for ship in fleet.ships:
|
||||
ship.global_position = BUILDING_AT
|
||||
ship.velocity = Vector2.ZERO
|
||||
stage = 2
|
||||
elapsed = 0.0
|
||||
return false
|
||||
2:
|
||||
# Long enough for several strike ticks to have passed.
|
||||
if elapsed < 2.0:
|
||||
return false
|
||||
for ship in fleet.ships:
|
||||
ship.velocity = Vector2.ZERO
|
||||
if _hp() != hp_before:
|
||||
return _fail("a vessel resting on the structure damaged it (%d -> %d) - the fleet docks here to bank ore" \
|
||||
% [hp_before, _hp()])
|
||||
print("a vessel parked on the structure for %.1fs did nothing to it" % elapsed)
|
||||
|
||||
# --- D. arriving fast does --------------------------------------
|
||||
hp_before = _hp()
|
||||
for ship in fleet.ships:
|
||||
# Placed clear and sent IN, because the impact is detected on
|
||||
# entry - a ship spawned already overlapping never enters.
|
||||
ship.global_position = BUILDING_AT - Vector2(400.0, 0.0)
|
||||
ship.velocity = Vector2(900.0, 0.0)
|
||||
ship.set_move_target(BUILDING_AT + Vector2(600.0, 0.0))
|
||||
stage = 3
|
||||
elapsed = 0.0
|
||||
return false
|
||||
3:
|
||||
if elapsed < 1.2:
|
||||
return false
|
||||
if _hp() >= hp_before:
|
||||
return _fail("a vessel arriving at 900 did not damage the structure")
|
||||
print("a vessel arriving fast took it from %d to %d" % [hp_before, _hp()])
|
||||
|
||||
print("TEST_BUILDING_COLLATERAL: PASS")
|
||||
quit(0)
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _fail(message: String) -> bool:
|
||||
print("TEST_BUILDING_COLLATERAL: FAIL (%s)" % message)
|
||||
quit(1)
|
||||
return true
|
||||
1
tests/test_building_collateral.gd.uid
Normal file
1
tests/test_building_collateral.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bqsx7ba1p3y8s
|
||||
|
|
@ -455,6 +455,20 @@ func _process(delta: float) -> bool:
|
|||
print("skipping clears %d props and lands where playing it through does" \
|
||||
% skipped_props.size())
|
||||
|
||||
# #161: the prologue widens the formation into a freight convoy
|
||||
# by writing over game_state.formation. Finishing has to put the
|
||||
# fleet's own wedge back, or the player flies the convoy's
|
||||
# 600-unit spread for the rest of the game - a shape nobody chose,
|
||||
# which reads as the fleet having drifted apart.
|
||||
for i in range(mini(game_state.formation.size(),
|
||||
game_state.DEFAULT_FORMATION.size())):
|
||||
if not game_state.formation[i].is_equal_approx(game_state.DEFAULT_FORMATION[i]):
|
||||
print("TEST_INTRO_SCENE: FAIL (slot %d is %s after the prologue, expected the default %s)" \
|
||||
% [i, game_state.formation[i], game_state.DEFAULT_FORMATION[i]])
|
||||
quit(1)
|
||||
return true
|
||||
print("formation restored to the fleet's own wedge")
|
||||
|
||||
print("TEST_INTRO_SCENE: PASS")
|
||||
quit(0)
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ extends SceneTree
|
|||
# D. moving to a DIFFERENT node resets that - two taps on two nodes must
|
||||
# never add up to a purchase
|
||||
# E. tapping an unaffordable node twice buys nothing and says why
|
||||
# F. one physical tap counts ONCE, even though the device delivers it twice
|
||||
# - as a touch and as the mouse button emulated from it. It did not, and
|
||||
# that is #162: the duplicate found the node already selected, took
|
||||
# itself for the confirming tap, and bought the research on first touch
|
||||
|
||||
var game_state: Node
|
||||
var main: Node
|
||||
|
|
@ -36,20 +40,43 @@ func _initialize() -> void:
|
|||
tree_view = main.get_node("UI/SkillMenu/Tree")
|
||||
|
||||
|
||||
func _node_position(id: String) -> Vector2:
|
||||
return tree_view.global_position + tree_view.node_screen_pos(game_state.skill_node(id))
|
||||
|
||||
|
||||
# ONE physical tap, delivered the way a real device delivers it: as a touch
|
||||
# AND as the mouse button Godot emulates from it. Both settings are on
|
||||
# (emulate_mouse_from_touch and emulate_touch_from_mouse), and the menu's
|
||||
# dispatcher routes both kinds to the tree - so a handler that is not
|
||||
# idempotent per gesture sees every tap twice. It did, and that made the FIRST
|
||||
# tap buy (#162). Going through both paths here is the whole point; tapping
|
||||
# only one of them would pass while the game stayed broken.
|
||||
func _tap(id: String) -> void:
|
||||
# Straight at the node's own position in the tree's local space, so this
|
||||
# exercises the same hit test a finger does.
|
||||
var node: Dictionary = game_state.skill_node(id)
|
||||
var event := InputEventScreenTouch.new()
|
||||
event.index = 1
|
||||
event.pressed = true
|
||||
event.position = tree_view.global_position + tree_view.node_screen_pos(node)
|
||||
tree_view.handle_touch(event)
|
||||
var at: Vector2 = _node_position(id)
|
||||
var press := InputEventScreenTouch.new()
|
||||
press.index = 1
|
||||
press.pressed = true
|
||||
press.position = at
|
||||
tree_view.handle_touch(press)
|
||||
|
||||
var emulated := InputEventMouseButton.new()
|
||||
emulated.button_index = MOUSE_BUTTON_LEFT
|
||||
emulated.pressed = true
|
||||
emulated.position = at
|
||||
emulated.global_position = at
|
||||
tree_view.handle_mouse_button(emulated)
|
||||
|
||||
var release := InputEventScreenTouch.new()
|
||||
release.index = 1
|
||||
release.pressed = false
|
||||
release.position = event.position
|
||||
release.position = at
|
||||
tree_view.handle_touch(release)
|
||||
var emulated_release := InputEventMouseButton.new()
|
||||
emulated_release.button_index = MOUSE_BUTTON_LEFT
|
||||
emulated_release.pressed = false
|
||||
emulated_release.position = at
|
||||
emulated_release.global_position = at
|
||||
tree_view.handle_mouse_button(emulated_release)
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ func _process(delta: float) -> bool:
|
|||
var lab_card_2: Control = controller.get_node("../UI/LabMenu/Upgrade2")
|
||||
var lab_card_3: Control = controller.get_node("../UI/LabMenu/Upgrade3")
|
||||
var lab_detail: Label = controller.get_node("../UI/LabMenu/DetailLabel")
|
||||
var lab_buy: IconButton = controller.get_node("../UI/LabMenu/BuyButton")
|
||||
lab_menu.visible = true
|
||||
controller.call("_on_lab_vessel", 1)
|
||||
if not lab_card_0.visible or lab_card_1.visible:
|
||||
|
|
@ -108,7 +107,11 @@ func _process(delta: float) -> bool:
|
|||
quit(1)
|
||||
return true
|
||||
controller.call("_on_lab_upgrade", 0)
|
||||
if not "Unlock Shield Vessel" in lab_detail.text or not lab_buy.enabled:
|
||||
# lab_can_buy, not a button's `enabled`: #164 removed the separate
|
||||
# buy button, so the option itself is the control and a second tap
|
||||
# on it is the purchase. What is being checked is unchanged -
|
||||
# selecting the unlock card offers something actually buyable.
|
||||
if not "Unlock Shield Vessel" in lab_detail.text or not controller.lab_can_buy:
|
||||
print("TEST_SHIP_LAB: FAIL (unlock card did not select a purchasable detail)")
|
||||
quit(1)
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in a new issue