Skill tree, node-based building animation, bigger UI, and a 19x faster test suite
Gameplay and UI - Research tree at the mothership gates which structures can be built and grants permanent fleet-capacity upgrades (GameState.SKILL_TREE, SkillTreeView). Node depth is derived from prerequisites, so the layout cannot drift out of step with the dependencies. - Building info popup before committing to a build, with per-building cost and description. - Ship crafter redrawn as a space factory with an assembly animation; mothership redrawn as a radial flagship; command centre as a plotting hub. - Keyboard and mouse support (WASD, Q/E pivot, wheel zoom) for the web build. - UI and font scaled up for phone use, via a custom Theme resource - gui/theme/default_font_size does not reach the default theme. - Asteroids no longer spawn on top of the fleet's start position. - Fleet formation origin derived from the layout's own offsets rather than the centroid, fixing the lurch when a lopsided formation started moving. - Fleet.stop() brakes from the ship's TRUE motion (velocity + fleet_velocity). Ship zeroes its velocity when seated in its slot even while the anchor drags that slot forward, so braking from velocity alone stopped the fleet dead instead of coasting - and whether it did depended on the frame rate. Animation architecture (issue #10) - Buildings, projectiles and explosion VFX no longer animate by redrawing. Static geometry is rasterised once in _draw(); moving parts are NeonPiece children animated through node properties, which reuse the cached geometry. Every NeonDraw call expands into four antialiased polylines, so redrawing to move something re-tessellated all of it. Test suite (issue #8): 1075s -> ~55s - Runs from a copy on Termux's own filesystem. The project lives on Android's FUSE bridge, read through proot, where load("res://Main.tscn") alone cost 8.5s per test against ~2s natively - and nearly every test loads it. - Runs 6 tests at a time, in a single proot-distro login, with output buffered per test and printed only on failure. - --fixed-fps 60 pins delta instead of measuring the wall clock, so a test's result no longer depends on how busy the machine is. Without it, parallelism made two tests fail on 2 of 3 runs. - A test passes only if it both exits 0 and prints ": PASS". - 38 tests, green on three consecutive runs. Bundles Carrois Gothic SC (Apache 2.0) with its licence text. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
85814ce88c
commit
b641fa5891
48 changed files with 1985 additions and 303 deletions
137
GameState.gd
137
GameState.gd
|
|
@ -48,6 +48,138 @@ const EXTRACTOR_COST: int = 25
|
|||
|
||||
var buildings: Array = []
|
||||
|
||||
# --- Skill tree ------------------------------------------------------------
|
||||
|
||||
# Researched at the mothership. Two things hang off it: which structures the
|
||||
# player is allowed to build at all, and permanent upgrades that have no
|
||||
# building of their own. The mothership itself is deliberately NOT in the
|
||||
# tree - it is the thing you research AT, so gating it behind research would
|
||||
# be a deadlock.
|
||||
#
|
||||
# `x` is a horizontal position on a 0..1 grid; the vertical position is NOT
|
||||
# stored, it is derived from how many prerequisites deep the node is, so the
|
||||
# tree always reads root-at-the-bottom and cannot drift out of step with the
|
||||
# dependencies when nodes are added. `requires` is a single prerequisite id
|
||||
# ("" for a root).
|
||||
const SKILL_TREE: Array = [
|
||||
{
|
||||
"id": "shipyards", "name": "Shipyards", "cost": 15, "requires": "",
|
||||
"x": 0.5, "unlocks": BUILDING_SHIP_CRAFTER,
|
||||
"desc": "Build ship crafters, and buy extra vessels at them.",
|
||||
},
|
||||
{
|
||||
"id": "logistics", "name": "Logistics", "cost": 25, "requires": "shipyards",
|
||||
"x": 0.18, "unlocks": BUILDING_EXTRACTOR,
|
||||
"desc": "Build extractors on planets. They mine ore whether or not you are nearby.",
|
||||
},
|
||||
{
|
||||
"id": "coordination", "name": "Coordination", "cost": 20, "requires": "shipyards",
|
||||
"x": 0.82, "unlocks": BUILDING_COMMAND_CENTER,
|
||||
"desc": "Build command centers, where the fleet formation is arranged.",
|
||||
},
|
||||
{
|
||||
"id": "wing", "name": "Wing Doctrine", "cost": 30, "requires": "coordination",
|
||||
"x": 0.82, "fleet_bonus": 1,
|
||||
"desc": "Permanent: +1 vessel in the fleet.",
|
||||
},
|
||||
{
|
||||
"id": "squadron", "name": "Squadron Doctrine", "cost": 70, "requires": "wing",
|
||||
"x": 0.65, "fleet_bonus": 1,
|
||||
"desc": "Permanent: +1 vessel in the fleet.",
|
||||
},
|
||||
{
|
||||
"id": "armada", "name": "Armada Doctrine", "cost": 150, "requires": "squadron",
|
||||
"x": 0.3, "fleet_bonus": 1,
|
||||
"desc": "Permanent: +1 vessel in the fleet.",
|
||||
},
|
||||
]
|
||||
|
||||
const BASE_FLEET_SIZE: int = 5
|
||||
|
||||
var unlocked: Array = []
|
||||
|
||||
|
||||
func skill_node(id: String) -> Dictionary:
|
||||
for node in SKILL_TREE:
|
||||
if node.id == id:
|
||||
return node
|
||||
return {}
|
||||
|
||||
|
||||
func skill_depth(id: String) -> int:
|
||||
# How many prerequisites deep this node sits. Drives its height in the
|
||||
# tree view: roots at the bottom, everything that depends on something
|
||||
# above it.
|
||||
var depth: int = 0
|
||||
var node: Dictionary = skill_node(id)
|
||||
while not node.is_empty() and node.requires != "":
|
||||
depth += 1
|
||||
node = skill_node(node.requires)
|
||||
if depth > SKILL_TREE.size():
|
||||
break # a cycle in the data would otherwise hang here
|
||||
return depth
|
||||
|
||||
|
||||
func max_skill_depth() -> int:
|
||||
var deepest: int = 0
|
||||
for node in SKILL_TREE:
|
||||
deepest = maxi(deepest, skill_depth(node.id))
|
||||
return deepest
|
||||
|
||||
|
||||
func is_unlocked(id: String) -> bool:
|
||||
return id in unlocked
|
||||
|
||||
|
||||
func prerequisite_met(id: String) -> bool:
|
||||
var node: Dictionary = skill_node(id)
|
||||
if node.is_empty():
|
||||
return false
|
||||
return node.requires == "" or is_unlocked(node.requires)
|
||||
|
||||
|
||||
func can_unlock(id: String) -> bool:
|
||||
return not is_unlocked(id) and prerequisite_met(id) and can_afford(int(skill_node(id).cost))
|
||||
|
||||
|
||||
func unlock(id: String) -> bool:
|
||||
if not can_unlock(id):
|
||||
return false
|
||||
if not spend(int(skill_node(id).cost)):
|
||||
return false
|
||||
unlocked.append(id)
|
||||
return true
|
||||
|
||||
|
||||
func is_building_unlocked(type: String) -> bool:
|
||||
# The mothership is always buildable: it is where research happens, so
|
||||
# locking it would leave a player with no mothership unable to ever get
|
||||
# one.
|
||||
if type == BUILDING_MOTHERSHIP:
|
||||
return true
|
||||
for node in SKILL_TREE:
|
||||
if node.get("unlocks", "") == type:
|
||||
return is_unlocked(node.id)
|
||||
return true
|
||||
|
||||
|
||||
func research_for_building(type: String) -> String:
|
||||
for node in SKILL_TREE:
|
||||
if node.get("unlocks", "") == type:
|
||||
return node.name
|
||||
return ""
|
||||
|
||||
|
||||
func max_fleet_size() -> int:
|
||||
var n: int = BASE_FLEET_SIZE
|
||||
for id in unlocked:
|
||||
n += int(skill_node(id).get("fleet_bonus", 0))
|
||||
return mini(n, DEFAULT_FORMATION.size())
|
||||
|
||||
|
||||
func reset_progression() -> void:
|
||||
unlocked.clear()
|
||||
|
||||
|
||||
func add_building(type: String, at_position: Vector2) -> void:
|
||||
buildings.append({"type": type, "position": at_position})
|
||||
|
|
@ -84,8 +216,13 @@ func get_mothership_position() -> Variant:
|
|||
# centre. Lives here (not as a const on Fleet) so a layout the player has
|
||||
# arranged survives the trip to a planet's surface and back, and so a
|
||||
# rebuilt fleet keeps their arrangement.
|
||||
# Slots beyond BASE_FLEET_SIZE only become usable once the matching fleet
|
||||
# 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.
|
||||
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),
|
||||
]
|
||||
|
||||
var formation: Array = DEFAULT_FORMATION.duplicate()
|
||||
|
|
|
|||
Loading…
Reference in a new issue