Rework how a game starts: dev mode, a bare opening, and fleet growth

Adds a Dev Mode entry to the main menu and takes the play-testing
conveniences out of a normal game, which turn out to be the same change
from two directions.

DEV MODE. Banks 2000 of every resource, grants 500 research points, and
plants one of each planet type in the chunks around the spawn. Built ON TOP
of reset_new_game() rather than beside it, so a dev game is a normal game
plus a stock rather than a second definition of "fresh game" to keep in
sync. Offered only when running from Godot - OS.has_feature("editor"), the
tag an export clears - as is the map editor. Hidden AND guarded: pressing
either anyway is refused, because visibility is presentation and the rule is
the rule.

The menu now lays its stack out in code. Hiding two of four entries with
scene-authored offsets would leave holes in a shipped build - the same
failure the HUD columns had - so it measures the entries that actually exist
and centres on them.

A NORMAL GAME NOW HANDS OVER NOTHING. No 500 banked ore (removed from both
reset_new_game and the autoload's own default, so the two cannot disagree),
and no gas giant guaranteed in the origin chunk. Both were play-testing
conveniences that had become part of the real world's shape: every player
got the same landmark in the same place. Play-testing wanted all four planet
types anyway, and a normal game wanted none of them - different needs, now
different mechanisms.

WorldGen cannot read GameState back (an autoload is not resolvable as a
global identifier that early, the hazard PlanetSetups.gd already works
around), so GameState.dev_mode's setter PUSHES the flag down. World
generation stays static and dependency-free, GameState stays the single
source of truth, and dev planting is applied after every rng draw so a dev
world and a normal one differ only in those four chunks.

FLEET SIZE. BASE_FLEET_SIZE was doing two jobs - how many slots exist AND
how many ships you start with - which forced a new game to open with a full
fleet, leaving the first ship crafter nothing to do. Split into
BASE_FLEET_SIZE (3 slots) and STARTING_SHIP_COUNT (1 vessel), so the opening
has two empty slots to fill. A third copy of the old value turned up in
PlanetAtmosphereController, hardcoded as spawn_ships(5) and silently
degraded into "however many slots exist" once max_fleet_size() clamped it.

The doctrine branch now runs 3 -> 10 slots. Wing (30 -> 15) and Squadron
(70 -> 35, 2 -> 1 points) are cut hardest: they are no longer a mid-game
luxury but the ordinary way out of the opening, and pricing them as a luxury
made the early game feel stuck. Armada follows at 90/2. Two new tiers,
Battlegroup and Grand Fleet, grant +2 each - seven single-vessel nodes in
one lane would be a long monotonous chain for a branch that only ever does
one thing. DEFAULT_FORMATION grows to 10 slots, because max_fleet_size()
clamps to its length and a doctrine past that would charge real resources
for nothing; test_fleet_growth.gd asserts that invariant directly.

TEST FALLOUT, all of it from the deliberate change rather than a defect:

- Tests that silently inherited the old 5-ship default now ask for the fleet
  they need. Several had to crew it from their first frame rather than
  _initialize(), where the engine's deferred tree-entry finalization undoes
  it - the same hazard those tests already documented for set_process(false).
- test_planet_landing_proximity and test_return_position_matches_planet take
  the FIRST chunk holding a planet and land there. The guaranteed gas giant
  had been masking that this can now be a black hole, which destroys ships on
  contact. They exclude it, and clear the asteroids the field already placed.
- test_pivot_controls measured rotation with angle_difference, which wraps at
  +/-pi, so a hold that turned a full circle read as no rotation. Latent
  flakiness that only ever showed under load; it now reads the controller's
  unwrapped pivot_hold_amount.
- test_research_points was failing on ore, not points: can_unlock() checks
  the ore price too, and a fresh game banks nothing now.
- test_gas_system's "a reachable gas source near the spawn" premise moved to
  dev mode, which is where that guarantee now lives.

Full suite green at 97/97.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-18 12:10:14 +02:00
commit a3c6316676
19 changed files with 663 additions and 35 deletions

View file

@ -5,6 +5,10 @@ const RESOURCE_DEFINITIONS = preload("res://ResourceDefinitions.gd")
const BUILDING_DEFINITIONS = preload("res://BuildingDefinitions.gd")
const VESSEL_DEFINITIONS = preload("res://VesselDefinitions.gd")
const PLANET_DEFINITIONS = preload("res://PlanetDefinitions.gd")
# By path, not by its `WorldGen` global name: an autoload compiles before the
# global class table is necessarily populated, the same hazard PlanetSetups.gd
# works around.
const WORLD_GEN = preload("res://WorldGen.gd")
# Autoload singleton - the one thing that survives change_scene_to_file()
@ -14,7 +18,7 @@ const PLANET_DEFINITIONS = preload("res://PlanetDefinitions.gd")
# survive the trip has to live here instead.
var has_return_position: bool = false
var surviving_ship_count: int = 5
var surviving_ship_count: int = STARTING_SHIP_COUNT
var surviving_vessel_types: PackedStringArray = PackedStringArray()
var return_world_position: Vector2 = Vector2.ZERO
var return_camera_zoom: float = 1.0
@ -52,6 +56,20 @@ func set_fleet_speed_multiplier(value: float) -> void:
signal research_points_changed(total: int)
var research_points: int = 0
# Set only by start_dev_game(), which the main menu offers only when running
# from Godot. Makes WorldGen plant one of every planet type around the spawn.
# Cleared by reset_new_game(), so starting a normal game after a dev one
# cannot leave a dev world behind.
#
# The setter mirrors it into WorldGen, which cannot read it back: world
# generation is static and dependency-free by design. This stays the single
# place to set it - assigning dev_mode anywhere, tests included, reaches
# world generation.
var dev_mode: bool = false:
set(value):
dev_mode = value
WORLD_GEN.dev_planets_enabled = value
# Explored-chunk history for the world map's fog-of-war reveal. Lives
# here (not on ExplorationTracker, which gets destroyed and recreated on
# every scene swap) so exploration progress isn't lost every time the
@ -68,7 +86,11 @@ const RESOURCE_TYPES: PackedStringArray = RESOURCE_DEFINITIONS.ORDER
# All resource-bearing locations use the same container. The old public
# names below are computed compatibility accessors, not separate storage.
var bank_inventory: RefCounted = INVENTORY.new({RESOURCE_ORE: 500})
# Starts EMPTY. A new game used to open with 500 ore banked, which quietly
# skipped the opening of the game - the first mining run is what teaches the
# fleet hold, the return trip and the mothership. Dev mode (start_dev_game)
# is where a stocked start belongs.
var bank_inventory: RefCounted = INVENTORY.new()
var fleet_inventory: RefCounted = INVENTORY.new()
var rocks: int:
@ -324,7 +346,11 @@ const SKILL_TREE: Array = [
"desc": "Build gas burners. Each converts gas into energy at its own site - hub transporters keep it stocked and collect what it makes.",
},
{
"id": "wing", "name": "Wing Doctrine", "cost": 30, "requires": "coordination",
# Cheaper than it was (30 ore / 1 point): the fleet now starts at
# BASE_FLEET_SIZE 3 rather than 5, so the first two doctrines are no
# longer a mid-game luxury but the ordinary way out of the opening.
# Pricing them as a luxury made the early game feel stuck.
"id": "wing", "name": "Wing Doctrine", "cost": 15, "requires": "coordination",
"x": 0.82, "fleet_bonus": 1, "research_points": 1,
"desc": "Permanent: +1 vessel in the fleet.",
},
@ -335,18 +361,41 @@ const SKILL_TREE: Array = [
# prerequisite, also x=0.82) instead, so the whole fleet-size
# doctrine branch now runs straight rather than zigzagging into
# someone else's lane.
"id": "squadron", "name": "Squadron Doctrine", "cost": 70, "requires": "wing",
# Also cut (70 ore / 2 points), for the same reason as wing.
"id": "squadron", "name": "Squadron Doctrine", "cost": 35, "requires": "wing",
"x": 0.82, "fleet_bonus": 1, "research_points": 1,
"desc": "Permanent: +1 vessel in the fleet.",
},
{
"id": "armada", "name": "Armada Doctrine", "cost": 90, "requires": "squadron",
"x": 0.82, "fleet_bonus": 1, "research_points": 2,
"desc": "Permanent: +1 vessel in the fleet.",
},
{
"id": "armada", "name": "Armada Doctrine", "cost": 150, "requires": "squadron",
"x": 0.82, "fleet_bonus": 1, "research_points": 3,
"desc": "Permanent: +1 vessel in the fleet.",
# The last two tiers grant +2 rather than +1. Seven single-vessel
# nodes in one lane would be a long, monotonous chain for a branch
# that only ever does one thing; two larger, costlier steps carry the
# ceiling from 6 to 10 while keeping the branch a readable length.
"id": "battlegroup", "name": "Battlegroup Doctrine", "cost": 180, "requires": "armada",
"x": 0.82, "fleet_bonus": 2, "research_points": 4,
"desc": "Permanent: +2 vessels in the fleet.",
},
{
"id": "grand_fleet", "name": "Grand Fleet Doctrine", "cost": 320, "requires": "battlegroup",
"x": 0.82, "fleet_bonus": 2, "research_points": 6,
"desc": "Permanent: +2 vessels in the fleet.",
},
]
const BASE_FLEET_SIZE: int = 5
# How many SLOTS the fleet has before any doctrine is researched. Distinct
# from STARTING_SHIP_COUNT below: this is capacity, that is how many vessels
# are actually flying. The two used to be one constant, which forced a new
# game to open with a full fleet and left the first crafter with nothing to
# do - there was no room to put a vessel until a doctrine was researched.
const BASE_FLEET_SIZE: int = 3
# A new game opens with a SINGLE vessel. Building the fleet up is the early
# game, so the two empty slots are the first thing a ship crafter is for.
const STARTING_SHIP_COUNT: int = 1
var unlocked: Array = []
@ -448,7 +497,7 @@ func reset_progression() -> void:
# fresh game.
func reset_new_game() -> void:
has_return_position = false
surviving_ship_count = BASE_FLEET_SIZE
surviving_ship_count = STARTING_SHIP_COUNT
surviving_vessel_types = PackedStringArray()
return_world_position = Vector2.ZERO
return_camera_zoom = 1.0
@ -459,8 +508,9 @@ func reset_new_game() -> void:
_distorder_drain_progress = 0.0
boost_depleted_notice = false
research_points = 0
dev_mode = false
explored_chunks.clear()
bank_inventory = INVENTORY.new({RESOURCE_ORE: 500})
bank_inventory = INVENTORY.new()
fleet_inventory = INVENTORY.new()
buildings.clear()
next_building_id = 1
@ -473,6 +523,29 @@ func reset_new_game() -> void:
reset_formation()
# Amounts a dev game opens with: enough of everything to reach any part of
# the game immediately, without being so large that costs stop registering.
const DEV_RESOURCE_AMOUNT: int = 2000
const DEV_RESEARCH_POINTS: int = 500
# A new game stocked for play-testing: every resource banked, research points
# to spend, and one of each planet type next to the spawn (WorldGen reads
# dev_mode for that). Offered by the main menu only when running from Godot -
# see MainMenu.gd - so it cannot be reached in a shipped build.
#
# Deliberately built ON TOP of reset_new_game() rather than beside it, so a
# dev game is a normal game plus a stock rather than a second, separately
# maintained definition of what a fresh game is.
func start_dev_game() -> void:
reset_new_game()
dev_mode = true
for resource_type in resource_types():
bank_inventory.set_amount(resource_type, DEV_RESOURCE_AMOUNT)
research_points = DEV_RESEARCH_POINTS
research_points_changed.emit(research_points)
# --- building stock and production queue (#16) -----------------------------
# Since #12, a building cannot just deduct from the bank at the moment of
@ -1101,9 +1174,13 @@ func get_mothership_position() -> Variant:
# capacity upgrade is researched, but they are defined up front so the wedge
# keeps a deliberate shape as it grows rather than having positions invented
# at unlock time.
# Ten slots, because max_fleet_size() caps itself on this array's length -
# so the wedge has to be long enough for every doctrine to be worth buying.
# The last pair continues the V rather than starting a new shape.
const DEFAULT_FORMATION: Array = [
Vector2(0, -48), Vector2(-30, -8), Vector2(30, -8), Vector2(-60, 32), Vector2(60, 32),
Vector2(-90, 72), Vector2(90, 72), Vector2(0, 56),
Vector2(-120, 112), Vector2(120, 112),
]
var formation: Array = DEFAULT_FORMATION.duplicate()