redoing bump

This commit is contained in:
2026-07-08 13:21:27 -05:00
parent f407b5d9a6
commit e545395ac6
12 changed files with 243 additions and 90 deletions
+43 -5
View File
@@ -56,9 +56,9 @@ fn bumping_a_transporter_drops_you_on_its_far_side() {
#[test]
fn a_blocked_far_side_transports_out_of_the_paired_transporter() {
// Player, east transporter, a wall blocking its far side, the free entrance
// cell, then the paired west transporter. The player should pop out at the
// west transporter's entrance (the cell just before it), across the wall.
// Player, east transporter, a wall blocking its far side, a gap, the paired
// west transporter, then a free cell. The player should pop out on the paired
// transporter's far side (the cell just past it), across the wall.
let board = load_board(&map(
6,
1,
@@ -81,11 +81,49 @@ fn a_blocked_far_side_transports_out_of_the_paired_transporter() {
let b = game.board();
assert_eq!(
(b.player.x, b.player.y),
(3, 0),
"transported to the paired transporter's entrance",
(5, 0),
"transported past the paired transporter",
);
}
#[test]
fn a_pushed_crate_is_transported_through() {
// Player, a crate, an east transporter, then a free cell. Pushing the crate
// east into the transporter bumps it (through the crate chain); the transporter
// moves the crate — a plain terrain solid, no object id — out its far side.
let board = load_board(&map(
4,
1,
&[layer(
"@oT ",
&[
("@", "kind = \"player\""),
("o", "kind = \"crate\""),
("T", "kind = \"transporter_east\""),
],
)],
));
let mut game = GameState::new(board);
game.run_init();
// Push east into the crate: the crate can't move (the transporter blocks it),
// but the transporter is bumped from the West and teleports the crate to (3,0).
game.try_move(Direction::East);
game.tick(Duration::from_secs_f64(0.1));
{
let b = game.board();
assert!(b.solid_at(3, 0).is_some(), "crate transported to the far side");
assert!(b.is_passable(1, 0), "crate's old cell is now empty");
assert_eq!((b.player.x, b.player.y), (0, 0), "player didn't move yet");
}
// With the crate gone, a second push walks the player onto the vacated cell.
game.try_move(Direction::East);
game.tick(Duration::from_secs_f64(0.1));
let b = game.board();
assert_eq!((b.player.x, b.player.y), (1, 0), "player follows into the gap");
}
#[test]
fn transporter_round_trips_to_its_keyword() {
let board = load_board(&map(