Continued FULL_GAME_GOAL. The 600-node world existed as data+engine but the playable map still used the 10-node slice. Added an additive world navigator that leaves the proven slice loop untouched. - Skyport entry -> 远征世界 page: 5 region tabs / 12 chapters / 10 nodes (two-column grids), lock rule order <= highest_node+1, node detail card and launch CTA placed above the lists so they are visible on 390x844. - Launch runs a real WorldContent scenario through the shared battle shell with growth modifiers applied. Victory routes through battle_finished: grants gold/crystal once, advances highest_node, derives chapter/region/boss/ final counters from the cleared set, accumulates prestige essence source; defeat returns to the world. zh/en labels incl. 60 chapter-theme translations. - Fixed two real bugs uncovered while wiring: WorldContent's regions()/ chapters()/nodes() did not initialise the lazy cache (first open rendered empty), and GameRoot paused the battle after setup with no resume, freezing real-time play at frame 0. Tests can still pause explicitly after start_node. - world_map_ui_test drives navigation/lock/launch/win/locale through real UI hooks; registered in the full gate. Added a p3a_world capture shot and the regenerated-artifact ignore entries. All gates pass incl. 24 UI captures; P2_CHECKS_PASS. prototype/ untracked.
154 lines
4.3 KiB
GDScript
154 lines
4.3 KiB
GDScript
class_name WorldContent
|
|
extends RefCounted
|
|
|
|
## Read-only view of the FULL-GAME content pack (600 nodes / 60 chapters / 5 regions).
|
|
## Additive to LaunchContent (the 10-node live slice) — the slice runtime is
|
|
## untouched. This class indexes the full pack and generates battle scenarios
|
|
## with the same shape as LaunchContent.scenario_for_node so the existing sim
|
|
## can consume them.
|
|
|
|
const CONTENT_PATH := "res://data/full_game_content.json"
|
|
|
|
static var _cache: Dictionary = {}
|
|
static var _node_index: Dictionary = {}
|
|
static var _enemy_index: Dictionary = {}
|
|
static var _boss_index: Dictionary = {}
|
|
|
|
|
|
static func content() -> Dictionary:
|
|
if not _cache.is_empty():
|
|
return _cache
|
|
var file := FileAccess.open(CONTENT_PATH, FileAccess.READ)
|
|
if file == null:
|
|
push_warning("Full-game content missing: %s" % CONTENT_PATH)
|
|
return {}
|
|
var parsed = JSON.parse_string(file.get_as_text())
|
|
file.close()
|
|
if not parsed is Dictionary:
|
|
return {}
|
|
_cache = parsed
|
|
_reindex()
|
|
return _cache
|
|
|
|
|
|
static func _reindex() -> void:
|
|
_node_index.clear()
|
|
_enemy_index.clear()
|
|
_boss_index.clear()
|
|
for n in _cache.get("nodes", []):
|
|
_node_index[str(n.get("id", ""))] = n
|
|
for e in _cache.get("enemies", []):
|
|
_enemy_index[str(e.get("id", ""))] = e
|
|
for b in _cache.get("bosses", []):
|
|
_boss_index[str(b.get("id", ""))] = b
|
|
|
|
|
|
static func regions() -> Array:
|
|
# The accessors must initialise the lazy cache themselves: on a fresh run
|
|
# the world page can be the first consumer and would otherwise render empty.
|
|
if _cache.is_empty():
|
|
content()
|
|
var out: Array = []
|
|
for r in _cache.get("nodes", []):
|
|
var rid := str(r.get("region", ""))
|
|
if not out.has(rid):
|
|
out.append(rid)
|
|
out.sort()
|
|
return out
|
|
|
|
|
|
static func chapters(region_id: String = "") -> Array:
|
|
if _cache.is_empty():
|
|
content()
|
|
var seen: Dictionary = {}
|
|
var out: Array = []
|
|
for n in _cache.get("nodes", []):
|
|
var ck := str(n.get("chapter", ""))
|
|
if region_id.is_empty() or str(n.get("region", "")) == region_id:
|
|
if not seen.has(ck):
|
|
seen[ck] = true
|
|
out.append(ck)
|
|
out.sort()
|
|
return out
|
|
|
|
|
|
static func nodes(chapter_id: String = "") -> Array:
|
|
if _cache.is_empty():
|
|
content()
|
|
var out: Array = []
|
|
for n in _cache.get("nodes", []):
|
|
if chapter_id.is_empty() or str(n.get("chapter", "")) == chapter_id:
|
|
out.append(n)
|
|
return out
|
|
|
|
|
|
static func node(node_id: String) -> Dictionary:
|
|
if _cache.is_empty():
|
|
content()
|
|
return _node_index.get(node_id, {})
|
|
|
|
|
|
static func enemy(enemy_id: String) -> Dictionary:
|
|
if _cache.is_empty():
|
|
content()
|
|
if _boss_index.has(enemy_id):
|
|
return _boss_index[enemy_id]
|
|
return _enemy_index.get(enemy_id, {})
|
|
|
|
|
|
static func event_for_chapter(chapter_id: String) -> Dictionary:
|
|
for e in _cache.get("events", []):
|
|
if str(e.get("chapter", "")) == chapter_id:
|
|
return e
|
|
return {}
|
|
|
|
|
|
static func scenario_for_node(node_id: String, wave_index: int = 0,
|
|
visible_hero_ids: Array = []) -> Dictionary:
|
|
var row := node(node_id)
|
|
if row.is_empty():
|
|
return {}
|
|
var waves: Array = row.get("waves", [])
|
|
if wave_index >= waves.size():
|
|
return {}
|
|
var enemy_ids: Array = waves[wave_index]
|
|
if enemy_ids.is_empty():
|
|
return {}
|
|
var scaled: Array = []
|
|
var enemy_specs: Dictionary = {}
|
|
for eid in enemy_ids:
|
|
var id := str(eid)
|
|
var spec := enemy(id)
|
|
scaled.append(id)
|
|
enemy_specs[id] = {
|
|
"hp": float(spec.get("base_hp", spec.get("hp", 100.0))),
|
|
"armor": float(spec.get("armor", 1.0)),
|
|
"shield": float(spec.get("shield_max", spec.get("shield", 0.0))),
|
|
"weak_tag": str(spec.get("weak_tag", "")),
|
|
"rebuild_at": spec.get("rebuild_at", []),
|
|
"rebuild_amount": float(spec.get("rebuild_amount", 0.0)),
|
|
}
|
|
var vh: Array = visible_hero_ids if not visible_hero_ids.is_empty() else ["H01", "H02", "H03"]
|
|
return {
|
|
"id": node_id,
|
|
"node_id": node_id,
|
|
"reward_id": str(row.get("reward_id", "")),
|
|
"wave_index": wave_index,
|
|
"mode": "auto" if str(row.get("type", "")) in ["normal", "supply"] else "semi",
|
|
"enemy_ids": scaled,
|
|
"enemy_specs": enemy_specs,
|
|
"visible_hero_ids": vh,
|
|
"input_events": [],
|
|
"timeout_seconds": float(row.get("timeout_seconds", 45.0)),
|
|
"hp_scale": float(row.get("hp_scale", 1.0)),
|
|
"node_type": str(row.get("type", "")),
|
|
"chapter": str(row.get("chapter", "")),
|
|
"region": str(row.get("region", "")),
|
|
}
|
|
|
|
|
|
static func counts() -> Dictionary:
|
|
if _cache.is_empty():
|
|
content()
|
|
return _cache.get("counts", {})
|