Files
tidewall/test/client/test_match_view.gd
T
claudeandClaude Opus 5.5 07738330b5 A2: Player figure and animation
The islander is built in headless Blender (tools/models/figure.py,
`make figure`, `make art`) as twelve rigid parts with their origins at
their joints: an oilskin coat, a sou'wester, sea boots, a bedding roll
and the canvas wing-sail. Debian's Blender can't write glTF, so the
figure is jointed rather than skinned.

FigureRig hangs the parts on pivots, paints them from Palette with the
coat in the player's own oilskin, and plays FigurePoses' hand-written
key poses through one AnimationTree: idle, walk and run by speed,
crouch and creep, air, skydive, glide, swim and aboard; long, short and
carried holds; reload and use layers; fire, boathook swing, keg throw
and building as one-shots; and a flinch when health drops. The chest
takes a third of the pitch and the held item all of it.

Figures animate from replicated state only: positions, look, health,
the held item and the FLAG_ bits (reloading and using now reach
mirrored players), with actions from FX. Every boathook swing is now a
sim "swing" event, sent as a SHOT with no item, so misses are seen and
heard; the new FX kind PLACE shows pieces placed. Protocol version 4.

Tests: test_figure_rig (15), plus swing and PLACE cases in test_harvest
and test_net_fx. make check passes (604 tests); make client-check
passes. Captures: figure_states, figure_actions, figure_close
(make figure-captures), client_glide and client_landed.

Closes #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 17:35:53 -05:00

83 lines
3.0 KiB
GDScript

extends TestCase
## The client's picture of a match (issue M8): one view over a simulation, with every
## player, the barge, items and chests drawn from it.
func _match(bots: int = 3) -> ServerLoop:
return ServerLoop.new(2, 1, bots)
func test_draws_every_player_and_the_barge() -> void:
var loop: ServerLoop = _match()
var view: MatchView = MatchView.new()
view.setup(loop.sim, 1)
assert_eq(view.entities.figure_count(), 4)
assert_true(view.entities.barge().visible)
assert_true(view.entities.barge().position.distance_to(loop.sim.drop.barge_position(loop.sim.tick)) < 0.001)
# Passengers are spread over the deck, not stacked on one spot.
assert_true(view.entities.figure_of(1).position.distance_to(view.entities.figure_of(2).position) > 1.0)
assert_eq(view.entities.pickup_count(), loop.sim.pickups.size())
assert_eq(view.entities.get_node("Chests").multimesh.instance_count, loop.sim.loot.chest_positions.size())
assert_not_null(view.terrain)
view.free()
func test_follows_the_simulation() -> void:
var loop: ServerLoop = _match()
var view: MatchView = MatchView.new()
view.setup(loop.sim, 1)
while not loop.sim.drop.finished:
loop.run_tick()
loop.sim.entities.find(3).health = 0
loop.run_tick()
loop.sim.set_sea_level(6.5)
view.sync()
assert_false(view.entities.barge().visible, "the barge is gone once the drop is over")
assert_false(view.entities.figure_of(3).visible, "an eliminated player isn't drawn")
var bot: SimEntity = loop.sim.entities.find(2)
if not bot.eliminated:
assert_true(view.entities.figure_of(2).position.distance_to(bot.position) < 0.001)
assert_near(view.water.level, 6.5, 0.001)
assert_eq(view.entities.pickup_count(), loop.sim.pickups.size())
view.free()
func test_gliding_players_show_a_wing_sail() -> void:
var loop: ServerLoop = _match(1)
var view: MatchView = MatchView.new()
view.setup(loop.sim, 1)
var bot: SimEntity = loop.sim.entities.find(2)
assert_false(view.entities.figure_of(2).sail().visible)
var guard: int = 0
while bot.drop_state != Drop.GLIDING and guard < 3000:
loop.run_tick()
guard += 1
view.sync()
view.entities.animate(0.1)
assert_eq(bot.drop_state, Drop.GLIDING)
assert_true(view.entities.figure_of(2).sail().visible)
view.free()
func test_the_camera_follows_a_player_and_frames_one() -> void:
var loop: ServerLoop = _match()
var view: MatchView = MatchView.new()
view.setup(loop.sim, 1)
while not loop.sim.drop.finished:
loop.run_tick()
view.sync()
var bot: SimEntity = loop.sim.entities.find(2)
assert_true(view.follow(2))
var gap: float = view.camera.position.distance_to(bot.position)
assert_true(gap > 0.5 and gap < 6.0, "the camera is %f m from the player" % gap)
assert_eq(view.terrain.focus, view.camera.position)
assert_true(view.frame(2))
var to_player: Vector3 = (bot.position + Vector3(0.0, 1.2, 0.0) - view.camera.position).normalized()
assert_true(to_player.dot(-view.camera.transform.basis.z) > 0.98, "the camera looks at the player")
assert_false(view.follow(999))
assert_false(view.frame(999))
view.overview()
assert_true(view.camera.position.y > 200.0)
view.free()