spaceship/tests/_fleet_upkeep_preview.gd
Loïc Wisniewski 2bb46cba94 Charge more for each berth, and show the bill
#220: every berth past the first paid one costs 1.12x the one before it, on
top of the flat per-vessel charge. A linear bill makes the tenth hull no more
of a decision than the second; compounding weighs each addition against the
whole fleet behind it. Shallow on purpose - the thirteenth berth costs about
three and a half times the second, the twentieth about seven and a half.

Fleet Offices gain a menu naming the whole bill per minute, a line per paying
berth with its multiplier, and the arithmetic in words. It renders
fleet_upkeep_breakdown(), which is the calculation the charging loop itself
runs: a readout that summed independently could quote a bill the game does
not take, which is the thing worth preventing here. The test pins that what
the menu quotes for a berth is what that office is charged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
2026-09-05 22:36:21 +02:00

34 lines
1.5 KiB
GDScript

extends Node2D
# Preview, not a test - #220's upkeep readout with a fleet worth reading:
# several berths of different hulls, so the per-berth lines, the compounding
# multiplier and the per-minute total all have something to show.
#
# bash tests/screenshot.sh res://tests/_fleet_upkeep_preview.tscn shots/fleet_upkeep.png 3 720x1280
func _ready() -> void:
GameState.buildings.clear()
GameState.extractors.clear()
GameState.transporters.clear()
GameState.reset_progression()
GameState.intro_active = false
GameState.add_building(GameState.BUILDING_MOTHERSHIP, Vector2.ZERO)
var office_ids: Array = []
for i in range(5):
office_ids.append(GameState.add_building(GameState.BUILDING_FLEET_OFFICE,
Vector2(400.0 * float(i + 1), 300.0)))
var main: Node = load("res://world/Main.tscn").instantiate()
add_child(main)
main.get_node("AsteroidField").set_process(false)
main.get_node("EnemySpawner").set_process(false)
# Spawned for real rather than by writing fleet_vessel_types directly: the
# Fleet rewrites that from what is actually flying the moment it composes
# itself, so a value set beforehand is discarded.
main.get_node("Fleet").spawn_ships(6, Vector2.ZERO, PackedStringArray([
GameState.VESSEL_INTERCEPTOR, GameState.VESSEL_LASER,
GameState.VESSEL_GAS_BOMBER, GameState.VESSEL_DISTORDER,
GameState.VESSEL_LASER, GameState.VESSEL_SHIELD]))
# One office left unsupplied, so the unpaid marker is visible too.
GameState.find_building(int(office_ids[3])).starved = true
main.get_node("UI/FleetUpkeepMenu").open_for(int(office_ids[0]))