Research the Fleet Office, and give it one hull
Fleet Offices sit behind a new Berth Authority doctrine. It costs ore and no research points, deliberately: points come only from conquering a planet, conquering needs a fleet, and the fleet caps at its opening hull until an office exists - so pricing the fleet's own gate in them would lock a player behind a fight that one vessel has to win first. The research unlocks the STRUCTURE; capacity is still the built, supplied thing #219 made it. The tree gains a sixth lane for it, so the branch that fleet size vacated is occupied again rather than reading as a hole. Also fixes a shape #216 exposed: a stationed transporter drew a hull written into its own script while a delivered one drew the definition's, and the transporter's definition declared none at all - so one in flight was an empty polygon. Both vessels now draw the definition, and a test pins that the two paths agree. The repair drone had the same fault, off by two units. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
parent
11773a63cf
commit
cc71811d89
8 changed files with 161 additions and 64 deletions
|
|
@ -9,8 +9,7 @@ extends SceneTree
|
|||
# holes where they used to be - it is repacked from whatever is researched.
|
||||
#
|
||||
# Verifies:
|
||||
# 1. with nothing researched only the mothership and the Fleet Office are
|
||||
# offered (the mothership is
|
||||
# 1. with nothing researched only the mothership is offered (it is
|
||||
# deliberately never gated - it is where research happens)
|
||||
# 2. researching a structure adds it, and it is placed, not left at
|
||||
# whatever offsets it happened to have in the scene file
|
||||
|
|
@ -80,36 +79,23 @@ func _process(delta: float) -> bool:
|
|||
|
||||
# --- 1. nothing researched ----------------------------------
|
||||
controller._refresh_build_status()
|
||||
# #219 put the Fleet Office beside the mothership at the opening:
|
||||
# it is the only way the fleet grows now, so gating it behind
|
||||
# research would gate fleet size behind research again - which is
|
||||
# the thing that ticket removed.
|
||||
var opening: Array = [GameState.BUILDING_MOTHERSHIP,
|
||||
GameState.BUILDING_FLEET_OFFICE]
|
||||
# The Fleet Office sits behind Berth Authority, so the opening is
|
||||
# the mothership alone again - the fallback that is always there.
|
||||
var shown: Array = _shown()
|
||||
var shown_ids: Array = []
|
||||
for e in shown:
|
||||
shown_ids.append(e[0])
|
||||
shown_ids.sort()
|
||||
opening.sort()
|
||||
if shown_ids != opening:
|
||||
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (opening offer was %s, expected %s)" \
|
||||
% [shown_ids, opening])
|
||||
if shown.size() != 1 or shown[0][0] != GameState.BUILDING_MOTHERSHIP:
|
||||
var names: Array = []
|
||||
for e in shown:
|
||||
names.append(e[0])
|
||||
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (unresearched structures on offer: %s)" % [names])
|
||||
quit(1)
|
||||
return true
|
||||
# --- 4. and the row is centred as a whole -------------------
|
||||
# Two entries now, so "centred" is the pair straddling the middle
|
||||
# rather than one sitting on it. The rule being checked is the
|
||||
# same one: a short row is not left hanging off to one side.
|
||||
var slots: Array = _slots()
|
||||
var spread: float = 0.0
|
||||
for slot in slots:
|
||||
spread += float(slot[1])
|
||||
if absf(spread) > 0.01:
|
||||
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (the opening row is off-centre by %.1f)" % spread)
|
||||
# --- 4. and it is centred, being alone on its row -----------
|
||||
var only: Array = _slots()[0]
|
||||
if absf(only[1]) > 0.01:
|
||||
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (the only entry sits at x=%.1f instead of centred)" % only[1])
|
||||
quit(1)
|
||||
return true
|
||||
print("nothing researched -> the mothership and a Fleet Office, centred")
|
||||
print("nothing researched -> only the mothership, centred")
|
||||
|
||||
# --- 2. research three more ---------------------------------
|
||||
game_state.unlocked = ["shipyards", "logistics", "coordination"]
|
||||
|
|
@ -117,11 +103,9 @@ func _process(delta: float) -> bool:
|
|||
stage = 1
|
||||
return false
|
||||
1:
|
||||
# Three doctrines add three structures to the two the opening
|
||||
# already offers (#219's Fleet Office is one of those two).
|
||||
var shown2: Array = _shown()
|
||||
if shown2.size() != 5:
|
||||
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (researched 3, expected 5 entries, got %d)" % shown2.size())
|
||||
if shown2.size() != 4:
|
||||
print("TEST_BUILD_MENU_HIDES_LOCKED: FAIL (researched 3, expected 4 entries, got %d)" % shown2.size())
|
||||
quit(1)
|
||||
return true
|
||||
for e in shown2:
|
||||
|
|
|
|||
|
|
@ -62,16 +62,38 @@ func _process(delta: float) -> bool:
|
|||
if game_state.max_fleet_size() != 1:
|
||||
return _fail("an unbuilt fleet caps at %d, expected 1" % game_state.max_fleet_size())
|
||||
|
||||
# The whole tree, researched, must not add a single berth: #219
|
||||
# moved fleet size out of research entirely.
|
||||
# --- the gate on the office ----------------------------------
|
||||
# Fleet Offices are researched (Berth Authority), but the research
|
||||
# only unlocks the STRUCTURE - it grants no capacity by itself.
|
||||
if game_state.is_building_unlocked(GameState.BUILDING_FLEET_OFFICE):
|
||||
return _fail("Fleet Offices are buildable with nothing researched")
|
||||
var gate: Dictionary = game_state.skill_node("berth_authority")
|
||||
if gate.is_empty():
|
||||
return _fail("no skill node unlocks the Fleet Office")
|
||||
# Ore only, deliberately: research points come solely from
|
||||
# conquering a planet, and conquering one needs a fleet. Pricing
|
||||
# the fleet's own gate in them would lock the player at their
|
||||
# opening hull behind a fight that hull has to win first.
|
||||
if int(gate.get("research_points", 0)) != 0:
|
||||
return _fail("Berth Authority costs %d research points - unreachable with one vessel" \
|
||||
% int(gate.get("research_points", 0)))
|
||||
for cost_resource in game_state.skill_costs("berth_authority"):
|
||||
if String(cost_resource) != GameState.RESOURCE_ORE:
|
||||
return _fail("Berth Authority asks for %s, which needs a built economy first" \
|
||||
% cost_resource)
|
||||
|
||||
# The whole tree, researched, must still not add a single berth:
|
||||
# #219 moved fleet SIZE out of research and onto the structure.
|
||||
for node in GameState.SKILL_TREE:
|
||||
if int(node.get("fleet_bonus", 0)) != 0:
|
||||
return _fail("skill node '%s' still grants fleet capacity" % node.id)
|
||||
game_state.unlocked.append(String(node.id))
|
||||
if not game_state.is_building_unlocked(GameState.BUILDING_FLEET_OFFICE):
|
||||
return _fail("researching Berth Authority did not unlock the Fleet Office")
|
||||
if game_state.max_fleet_size() != 1:
|
||||
return _fail("researching the entire tree raised the fleet cap to %d" \
|
||||
% game_state.max_fleet_size())
|
||||
print("a new game: 1 vessel, 1 berth, and no research anywhere raises it")
|
||||
print("a new game: 1 vessel, 1 berth; research unlocks the office, not the berth")
|
||||
|
||||
# --- B. offices are the berths -------------------------------
|
||||
for i in range(3):
|
||||
|
|
|
|||
65
tests/test_logistics_hull_identity.gd
Normal file
65
tests/test_logistics_hull_identity.gd
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
extends SceneTree
|
||||
|
||||
# A logistics vessel is ONE vessel, so it looks the same wherever it is drawn.
|
||||
#
|
||||
# #216 made transporters and repair drones fly out from the mothership as
|
||||
# ordinary vessel deliveries. A delivery draws the hull off the vessel
|
||||
# DEFINITION; the stationed nodes each drew a copy written into their own
|
||||
# script. The copies had drifted - the transporter's definition declared no
|
||||
# hull at all, so one in flight was an empty polygon, and the drone's two
|
||||
# shapes differed by a couple of units - which is why a transporter changed
|
||||
# shape the moment it was assigned.
|
||||
#
|
||||
# Covers:
|
||||
# A. every vessel that can be delivered declares a hull to be drawn by
|
||||
# B. the stationed node draws that same hull, not a second copy
|
||||
# C. and the colours agree, so it does not change livery either
|
||||
|
||||
const DELIVERABLE: Array = ["transporter", "repair_drone"]
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var definitions: Script = load("res://vessels/VesselDefinitions.gd")
|
||||
var nodes: Dictionary = {
|
||||
"transporter": load("res://logistics/Transporter.gd"),
|
||||
"repair_drone": load("res://logistics/RepairDrone.gd"),
|
||||
}
|
||||
|
||||
for vessel_type in DELIVERABLE:
|
||||
var definition: Resource = definitions.get_definition(vessel_type)
|
||||
if definition == null:
|
||||
return _fail("no definition for '%s'" % vessel_type)
|
||||
|
||||
# --- A. there is a hull at all -------------------------------
|
||||
# An empty one is not a small bug: VesselDelivery draws exactly this,
|
||||
# so a vessel with no hull is invisible for the whole flight.
|
||||
if definition.hull_points.is_empty():
|
||||
return _fail("'%s' declares no hull, so it is invisible in flight" % vessel_type)
|
||||
|
||||
# --- B. and the stationed node draws that one ----------------
|
||||
var node: Node2D = nodes[vessel_type].new()
|
||||
root.add_child(node)
|
||||
var drawn: PackedVector2Array = node._hull()
|
||||
node.free()
|
||||
if drawn != definition.hull_points:
|
||||
return _fail("'%s' is drawn as %s at its post and %s in flight" \
|
||||
% [vessel_type, drawn, definition.hull_points])
|
||||
|
||||
# --- C. same livery too ---------------------------------------
|
||||
var node_colour: Color = nodes[vessel_type].HULL_COLOR
|
||||
var definition_colour: Color = definition.glow_color
|
||||
if not is_equal_approx(node_colour.r, definition_colour.r) \
|
||||
or not is_equal_approx(node_colour.g, definition_colour.g) \
|
||||
or not is_equal_approx(node_colour.b, definition_colour.b):
|
||||
return _fail("'%s' is %s at its post and %s in flight" \
|
||||
% [vessel_type, node_colour, definition_colour])
|
||||
print("%s: one hull of %d points, one colour, both places" \
|
||||
% [vessel_type, definition.hull_points.size()])
|
||||
|
||||
print("TEST_LOGISTICS_HULL_IDENTITY: PASS")
|
||||
quit(0)
|
||||
|
||||
|
||||
func _fail(message: String) -> void:
|
||||
print("TEST_LOGISTICS_HULL_IDENTITY: FAIL (%s)" % message)
|
||||
quit(1)
|
||||
Loading…
Reference in a new issue