This commit is contained in:
2026-07-14 23:48:50 -05:00
parent 03185c9c68
commit 5146cc9bcc
25 changed files with 380 additions and 272 deletions
+6 -1
View File
@@ -7,6 +7,7 @@ use crate::game::GameState;
use crate::map_file::MapFile;
use crate::object_def::ObjectDef;
use std::time::Duration;
use crate::{Board, Builtin};
/// Finds the pusher object on a board (by its built-in tag).
fn pusher<'a>(board: &'a crate::board::Board, id: &mut u32) -> &'a ObjectDef {
@@ -42,6 +43,10 @@ fn pusher_loads_as_a_tagged_scripted_solid_object() {
assert!(!board.is_passable(0, 0), "pusher is solid");
}
fn is_tag(board: &Board, x: usize, y: usize, tag: &str) -> bool {
board.object_ids_at(x, y).iter().any(|id| board.objects[id].tags.contains(tag))
}
#[test]
fn pusher_advances_and_shoves_a_crate() {
// Pusher at (0,0), crate at (1,0), the player parked at the east edge.
@@ -74,7 +79,7 @@ fn pusher_advances_and_shoves_a_crate() {
"crate left its start cell"
);
assert!(
(2..b.width).any(|x| b.get(x, 0).1 == Archetype::Crate),
(2..b.width).any(|x| is_tag(&b, x, 0, "BUILTIN_crate")),
"crate was shoved east"
);
}