more test cleanup
This commit is contained in:
@@ -266,38 +266,6 @@ impl Board {
|
||||
}
|
||||
}
|
||||
|
||||
/// The object that a move **into** `(x, y)` heading `dir` bumps, if any.
|
||||
///
|
||||
/// Walks the chain of pushable crates from the target cell in `dir` until it
|
||||
/// reaches something that stops it, and reports the object it presses against:
|
||||
/// - a `Block` object in the target cell (or at the end of a pushable chain) is the
|
||||
/// bumped object,
|
||||
/// - open space or the player means nothing is bumped,
|
||||
///
|
||||
/// This is what lets *any* solid — the player, another object, or a pushed
|
||||
/// crate — trigger a `bump`: the bumper need not be an object, since we only
|
||||
/// return the *bumped* object's id (the direction it came from is supplied by
|
||||
/// the caller from its move direction).
|
||||
pub fn bump_target(&self, x: usize, y: usize, dir: Direction) -> Option<ObjectId> {
|
||||
let (dx, dy): (i64, i64) = dir.into();
|
||||
let (mut cx, mut cy) = (x, y);
|
||||
loop {
|
||||
if !self.in_bounds((cx as i64, cy as i64)) {
|
||||
return None; // push chain runs off the board
|
||||
}
|
||||
|
||||
if let Some(Tile::Object(obj)) = self.get(cx, cy) {
|
||||
if obj.enter_response.transmits_push(dir) {
|
||||
// An object we can push through, go to the next cell
|
||||
cx = (cx as i64 + dx) as usize;
|
||||
cy = (cy as i64 + dy) as usize;
|
||||
} else if obj.enter_response.bumpable(dir) {
|
||||
return Some(obj.scripting.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the chain of pushable solids starting at `(x, y)` can be shoved one
|
||||
/// step in `dir` — i.e. the chain ends at a passable cell rather than the board
|
||||
/// edge or a non-pushable solid.
|
||||
|
||||
Reference in New Issue
Block a user