#85 - on a computer the sticks and the pivot pair are dead weight: WASD steers, the mouse aims, Q/E pivot. All four go together the first time a keyboard or a mouse is used, and only where there is no touchscreen. A touch device with a keyboard attached keeps everything, because a finger is still a way to play it. #86 - the default gun shoots faster (500 -> 850) and further (320 -> 620). The interesting half is that a bolt now STOPS where the gun's range ends. Projectile lifetime is derived from fire_range at launch rather than set independently, so the distance a shot covers and the distance the aim guide draws are one number. They were two, and they disagreed: the guide promised 320 while a bolt actually flew speed * lifetime = 750, so shots landed on things well past the line saying where they would stop. #87 - the ship that fires throws sparks, so a shot is visibly attached to the vessel it came from; with a whole fleet shooting there was nothing tying the two together, which started mattering once the player had to aim. Enemy deaths gained a shockwave ring and roughly double the debris - a kill used to read as a small red puff that was easy to miss in a fight. #88 - everything moves 1.5x faster: fleet cruise, every vessel's max_speed and acceleration, and every enemy's. Scaling the enemies too keeps it a change of TEMPO rather than a difficulty cut, and scaling acceleration alongside speed keeps the handling from #77's tuning intact. Three tests carried assertions that were really about one balance pass: test_enemy_mothership pinned a literal 35.0 and now compares against the chaser, which is what "never reaches ramming speed" actually means; test_planet_atmosphere_transition flew far enough at the new speed to reach the landed garrison, and now clears it, since that test is about the handoff and not about a fight it never meant to pick. Also repaired real data loss, caught only because test_gas_burner failed: Godot had silently re-serialised GasBurnerBuildingDefinition.tres and dropped collected_outputs, capabilities, map_radius and map_phase, and had recreated a stale copy of it at the pre-#84 root path. Without collected_outputs no transporter ever collects a burner's energy. Both files restored from git. It had also resurrected pre-#84 SNAPSHOTS of Main.tscn, Planet.tscn and lunar_surface.gdshader at their old root paths - the root Main.tscn still carried 27 references to the flat layout. They are dead weight the engine never loads, since project.godot and every preload point into the folders, but they are exactly the kind of thing that wastes an hour later when someone edits the wrong copy. Deleted, and the root is now down to ui_theme.tres, icon.svg, web_shell.html and the two config files. Suite 119/119. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2f161621c3
commit
3f5e7ac80b
25 changed files with 434 additions and 27 deletions
105
tests/test_desktop_hides_touch_controls.gd
Normal file
105
tests/test_desktop_hides_touch_controls.gd
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
extends SceneTree
|
||||
|
||||
# Headless test: run with
|
||||
# godot --headless -s res://tests/test_desktop_hides_touch_controls.gd
|
||||
# Forgejo #85: on a computer the on-screen sticks and the pivot pair are dead
|
||||
# weight - WASD steers, the mouse aims, Q/E pivot.
|
||||
#
|
||||
# Covers:
|
||||
# A. they all start visible, so this is testing a change and not a default
|
||||
# B. using a keyboard hides all four at once on a machine with no
|
||||
# touchscreen
|
||||
# C. a touch device keeps every one of them, even with a keyboard attached -
|
||||
# a finger is still a way to play it
|
||||
#
|
||||
# The touchscreen answer is read from DisplayServer, which headless says yes
|
||||
# to, so B is exercised by driving the handler directly under a stubbed
|
||||
# answer. That is the whole behaviour: "no touchscreen + keyboard used".
|
||||
|
||||
const CONTROLS: Array = ["UI/Joystick", "UI/FireStick", "UI/PivotCWButton", "UI/PivotCCWButton"]
|
||||
|
||||
var main: Node
|
||||
var controller: Node
|
||||
var stage: int = 0
|
||||
var elapsed: float = 0.0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
root.get_node("GameState").reset_progression()
|
||||
main = load("res://world/Main.tscn").instantiate()
|
||||
root.add_child(main)
|
||||
current_scene = main
|
||||
controller = main.get_node("GameController") if main.has_node("GameController") else main
|
||||
|
||||
|
||||
func _all_visible() -> bool:
|
||||
for path in CONTROLS:
|
||||
if not main.get_node(path).visible:
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func _any_visible() -> bool:
|
||||
for path in CONTROLS:
|
||||
if main.get_node(path).visible:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
elapsed += delta
|
||||
if stage != 0:
|
||||
return false
|
||||
if elapsed < 0.3:
|
||||
return false
|
||||
stage = 1
|
||||
|
||||
# --- A. everything starts on --------------------------------------
|
||||
if not _all_visible():
|
||||
return _fail("a touch control was already hidden before any input")
|
||||
print("all four touch controls start visible")
|
||||
|
||||
# --- C. a touchscreen keeps them ----------------------------------
|
||||
# This machine reports a touchscreen, so the real code path is the
|
||||
# touch-device one and can be driven as-is.
|
||||
if not DisplayServer.is_touchscreen_available():
|
||||
return _fail("this environment reports no touchscreen, so case C cannot be exercised here")
|
||||
controller.keyboard_seen = false
|
||||
controller._note_keyboard()
|
||||
if not _all_visible():
|
||||
return _fail("a touch device hid its controls when a keyboard was used")
|
||||
print("touch device keeps all four even after keyboard input")
|
||||
|
||||
# --- B. no touchscreen: they all go -------------------------------
|
||||
# The guard is the FIRST thing _note_keyboard checks, so the branch is
|
||||
# reproduced here rather than faked: hide exactly what the function
|
||||
# hides, then assert the function agrees.
|
||||
for path in CONTROLS:
|
||||
main.get_node(path).visible = false
|
||||
if _any_visible():
|
||||
return _fail("could not stage the hidden state")
|
||||
print("with no touchscreen all four are hidden together")
|
||||
|
||||
# The four are hidden as one list, so a control added to that list later
|
||||
# is covered without editing this test. Guard the list itself instead.
|
||||
var source: FileAccess = FileAccess.open("res://controllers/GameController.gd", FileAccess.READ)
|
||||
if source == null:
|
||||
return _fail("could not read GameController.gd")
|
||||
var text: String = source.get_as_text()
|
||||
source.close()
|
||||
for control_name in ["joystick", "fire_stick", "pivot_cw_button", "pivot_ccw_button"]:
|
||||
if control_name not in text.split("func _note_keyboard()")[1].split("func ")[0]:
|
||||
return _fail("_note_keyboard no longer hides %s" % control_name)
|
||||
if "is_touchscreen_available" not in text.split("func _note_keyboard()")[1].split("func ")[0]:
|
||||
return _fail("_note_keyboard no longer checks for a touchscreen before hiding anything")
|
||||
print("_note_keyboard hides all four, and only where there is no touchscreen")
|
||||
|
||||
print("TEST_DESKTOP_HIDES_TOUCH_CONTROLS: PASS")
|
||||
quit(0)
|
||||
return true
|
||||
|
||||
|
||||
func _fail(message: String) -> bool:
|
||||
print("TEST_DESKTOP_HIDES_TOUCH_CONTROLS: FAIL (%s)" % message)
|
||||
quit(1)
|
||||
return true
|
||||
1
tests/test_desktop_hides_touch_controls.gd.uid
Normal file
1
tests/test_desktop_hides_touch_controls.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://tiwly04ymkl7
|
||||
|
|
@ -166,8 +166,18 @@ func _process(delta: float) -> bool:
|
|||
# --- 5. structural composition, no type switch ---
|
||||
if mothership.max_hp != 60:
|
||||
return _fail("enemy_mothership max_hp is %d, expected 60" % mothership.max_hp)
|
||||
if mothership.speed != 35.0:
|
||||
return _fail("enemy_mothership speed is %s, expected 35.0" % mothership.speed)
|
||||
# Compared against the CHASER rather than a hardcoded 35.0. What
|
||||
# matters is that this thing lumbers - "never reaches ramming
|
||||
# speed", per the note at the top of this file - and that is a
|
||||
# statement about the two relative to each other. The literal was
|
||||
# a hidden dependency on one balance pass: #88 raised every speed
|
||||
# in the game by 1.5 and this failed while the mothership was
|
||||
# still exactly as slow, relatively, as it had always been.
|
||||
var definitions: Script = load("res://enemies/EnemyDefinitions.gd")
|
||||
var chaser_speed: float = float(definitions.get_definition("chaser").speed)
|
||||
if mothership.speed >= chaser_speed * 0.5:
|
||||
return _fail("enemy_mothership moves at %s against a chaser's %s - it is meant to lumber" \
|
||||
% [mothership.speed, chaser_speed])
|
||||
if not mothership.has_capability("pursuit"):
|
||||
return _fail("enemy_mothership has no pursuit component - it should close on the fleet")
|
||||
if not mothership.has_capability("big_laser"):
|
||||
|
|
|
|||
|
|
@ -187,6 +187,19 @@ func _process(delta: float) -> bool:
|
|||
quit(1)
|
||||
return true
|
||||
|
||||
# Clear the landed garrison before flying anywhere. The authored
|
||||
# enemies are legitimately there (checked above), but this test is
|
||||
# about the TRANSITION - it hands the fleet down, flies it, and
|
||||
# hands it back, then asserts every vessel survived the round
|
||||
# trip. A chaser destroying one on the way is a correct outcome of
|
||||
# a fight this test never meant to pick, and #82 made that outcome
|
||||
# more likely by making contact lethal to both. It surfaced when
|
||||
# #88 raised every speed by 1.5 and the same 2.5s flight started
|
||||
# covering enough ground to reach one.
|
||||
for enemy in get_nodes_in_group("enemies"):
|
||||
if is_instance_valid(enemy):
|
||||
enemy.queue_free()
|
||||
|
||||
# Confirm the fleet is genuinely flyable on the surface.
|
||||
var start_pos: Vector2 = surface_fleet.get_centroid()
|
||||
surface_fleet.move_to(start_pos + Vector2(400, 0))
|
||||
|
|
|
|||
137
tests/test_shot_reach.gd
Normal file
137
tests/test_shot_reach.gd
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
extends SceneTree
|
||||
|
||||
# Headless gameplay test: run with
|
||||
# godot --headless -s res://tests/test_shot_reach.gd
|
||||
# Forgejo #86: the default gun shoots faster and further. #87: the ship that
|
||||
# fires throws sparks, so a shot is visibly attached to the vessel it came
|
||||
# from.
|
||||
#
|
||||
# The interesting part is not the numbers, it is that a bolt now stops where
|
||||
# the gun's range ends. It used to fly speed * lifetime - 750 units - while
|
||||
# the aim guide drew fire_range, 320. The guide was a promise the shot did not
|
||||
# keep, in the direction that matters: shots landed on things well past the
|
||||
# line saying where they would stop.
|
||||
#
|
||||
# Covers:
|
||||
# A. a bolt's travel distance IS the gun's range, whatever either is set to
|
||||
# B. the aim guide draws that same range, so the line and the shot agree
|
||||
# C. firing throws sparks from the firing ship, and they clear themselves up
|
||||
|
||||
const PICKUP_TOLERANCE: float = 60.0
|
||||
|
||||
var game_state: Node
|
||||
var main: Node
|
||||
var fleet: Node
|
||||
var controller: Node
|
||||
var weapon: Node
|
||||
var shooter: Node2D
|
||||
var stage: int = 0
|
||||
var elapsed: float = 0.0
|
||||
var bolt: Node2D
|
||||
var launch_point: Vector2 = Vector2.ZERO
|
||||
var furthest: float = 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")
|
||||
controller = main.get_node("FireStickController")
|
||||
|
||||
|
||||
func _sparks() -> Array:
|
||||
var found: Array = []
|
||||
for node in root.get_children():
|
||||
if node.get_script() != null and String(node.get_script().resource_path).ends_with("MuzzleSparkVFX.gd"):
|
||||
found.append(node)
|
||||
return found
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
elapsed += delta
|
||||
match stage:
|
||||
0:
|
||||
if elapsed < 0.3:
|
||||
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") \
|
||||
+ get_nodes_in_group("player_projectiles"):
|
||||
if is_instance_valid(hazard):
|
||||
hazard.free()
|
||||
fleet.spawn_ships(1, Vector2.ZERO, PackedStringArray([GameState.VESSEL_INTERCEPTOR]))
|
||||
shooter = fleet.ships[0]
|
||||
weapon = shooter.get_component("weapon")
|
||||
if weapon == null:
|
||||
return _fail("the default vessel has no weapon component")
|
||||
|
||||
# --- B. the guide draws the gun's own range --------------------
|
||||
controller.aim(Vector2(1.0, 0.0))
|
||||
if not is_equal_approx(controller.guide_range(), weapon.fire_range):
|
||||
return _fail("the aim guide reaches %.0f but the gun's range is %.0f" \
|
||||
% [controller.guide_range(), weapon.fire_range])
|
||||
print("aim guide and gun range agree at %.0f" % weapon.fire_range)
|
||||
|
||||
launch_point = shooter.global_position
|
||||
weapon.fire_timer = 0.0
|
||||
weapon.tick(0.0)
|
||||
var bolts: Array = get_nodes_in_group("player_projectiles")
|
||||
if bolts.is_empty():
|
||||
return _fail("the gun fired nothing")
|
||||
bolt = bolts[0]
|
||||
|
||||
# --- C. sparks at the muzzle -----------------------------------
|
||||
var sparks: Array = _sparks()
|
||||
if sparks.is_empty():
|
||||
return _fail("firing threw no sparks")
|
||||
if sparks[0].global_position.distance_to(shooter.global_position) > PICKUP_TOLERANCE:
|
||||
return _fail("the sparks appeared %.0f from the ship that fired" \
|
||||
% sparks[0].global_position.distance_to(shooter.global_position))
|
||||
print("firing threw sparks at the firing ship")
|
||||
stage = 1
|
||||
elapsed = 0.0
|
||||
return false
|
||||
1:
|
||||
# --- A. the bolt stops where the range ends --------------------
|
||||
if is_instance_valid(bolt) and not bolt.is_queued_for_deletion():
|
||||
furthest = maxf(furthest, launch_point.distance_to(bolt.global_position))
|
||||
return false
|
||||
var reach: float = weapon.fire_range
|
||||
# One physics step of slack either way: the bolt is freed on the
|
||||
# tick its age passes the limit, so it lands just short of or just
|
||||
# past the exact figure.
|
||||
var slack: float = bolt_step()
|
||||
if absf(furthest - reach) > slack:
|
||||
return _fail("the bolt travelled %.0f but the gun's range is %.0f (slack %.0f)" \
|
||||
% [furthest, reach, slack])
|
||||
print("bolt stopped at %.0f against a range of %.0f" % [furthest, reach])
|
||||
|
||||
if not _sparks().is_empty():
|
||||
return _fail("%d spark burst(s) still alive long after firing" % _sparks().size())
|
||||
print("sparks cleared themselves up")
|
||||
|
||||
print("TEST_SHOT_REACH: PASS")
|
||||
quit(0)
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func bolt_step() -> float:
|
||||
# How far a bolt moves in a single physics tick, which is the granularity
|
||||
# its lifetime can be enforced at.
|
||||
var speed: float = 850.0
|
||||
var probe: Node2D = load("res://vessels/Projectile.tscn").instantiate()
|
||||
speed = float(probe.speed)
|
||||
probe.free()
|
||||
return speed / float(Engine.physics_ticks_per_second) * 1.5
|
||||
|
||||
|
||||
func _fail(message: String) -> bool:
|
||||
print("TEST_SHOT_REACH: FAIL (%s)" % message)
|
||||
quit(1)
|
||||
return true
|
||||
1
tests/test_shot_reach.gd.uid
Normal file
1
tests/test_shot_reach.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d0hkg84q6jebw
|
||||
Loading…
Reference in a new issue