Files
tidewall/test/capture/tutorial_scene.gd
T
claudeandClaude Opus 5.5 b604ced923 A12: Tutorial
A short, skippable tutorial on an island of your own: leave the barge, glide
down, walk and jump, cut materials with the boathook, place a wall, aim and
fire, and get above the line the tide will reach after its next rise.

- MatchRules.tutorial(): one player, no bots, last_team_wins off (alone is
  not a win, only the tide or a fall ends it) and starting_kit (a dock
  carbine with a full magazine and 60 cartridges, Tuning.TUTORIAL_KIT).
  Both rules go in command logs; older logs read with the defaults.
- Tutorial watches the client's own view (predicted player, world copy,
  FX) and moves on when each step is done. Instructions name the player's
  own key bindings. TutorialCard shows it under the minimap.
- TutorialPilot plays it through ClientInput for --tutorial --autoplay,
  the tests and make tutorial-check (12 seeds, all finish).
- First launch offers it (welcome screen, remembered in settings); it is
  always on the main menu; Leave in the pause menu skips it. Finishing is
  saved. --tutorial on the command line.
- make tutorial-captures; PLAY.md, the man page, ARCHITECTURE.md and
  CLAUDE.md updated.

Closes #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:47:31 -05:00

51 lines
1.8 KiB
GDScript

## Capture scenario for the tutorial (A12): the real ClientSession playing the tutorial
## offline, driven by its scripted player (TutorialPilot) until `step` begins, then held
## there so the HUD's tutorial card shows that step's instruction and progress.
##
## Stages: move (just landed), build (build mode on, the ghost showing) and tide (the
## last step, with the tide post and the line to beat).
extends Node3D
const DT: float = 1.0 / Tuning.TICK_RATE_HZ
const LIMIT_FRAMES: int = 300 * Tuning.TICK_RATE_HZ
@export var step: String = "move"
@export var match_seed: int = 3
var _session: ClientSession
func _ready() -> void:
_session = ClientSession.new()
_session.input.autoplay = true
_session.play_tutorial(match_seed)
add_child(_session)
_session.set_process(false)
var wanted: int = Tutorial.STEP_NAMES.find(step)
var frames: int = 0
while frames < LIMIT_FRAMES and _session.tutorial.step < wanted:
_session.pump(DT)
frames += 1
if _session.tutorial.step != wanted:
push_error("tutorial capture: never reached step '%s' (stopped at '%s')" % [step, _session.tutorial.step_name()])
return
# A moment into the step: long enough for build mode to come on, too short for the
# script to finish it.
for _frame: int in 6:
_session.pump(DT)
if _session.tutorial.step != wanted:
push_error("tutorial capture: step '%s' was over before the picture" % step)
return
_session.input.map_open = false
_session.input.buttons = 0
_session.hud.show_state(_session.hud_state())
_session.view.settle()
_session._show_charts(DT)
_session.tutorial_card.show_tutorial(_session.tutorial, true)
func _process(_delta: float) -> void:
# The session is held still; only the card is laid out again as its labels settle.
if _session != null and _session.tutorial_card != null:
_session.tutorial_card.show_tutorial(_session.tutorial, true)