more test cleanup
This commit is contained in:
+8
-41
@@ -1,4 +1,4 @@
|
||||
use crate::action::{apply_push, apply_shift, apply_teleport, Action, BoardAction, Consequence, SendArg};
|
||||
use crate::action::{apply_push, apply_shift, apply_teleport, Action, BoardAction, SendArg};
|
||||
use crate::board::Board;
|
||||
use crate::log::LogLine;
|
||||
use crate::script::ScriptHost;
|
||||
@@ -9,32 +9,6 @@ use std::collections::{BTreeSet, HashSet, VecDeque};
|
||||
use std::hash::Hash;
|
||||
use std::time::Duration;
|
||||
|
||||
/// A single `send` to an object, with an arg.
|
||||
///
|
||||
/// Most things (bump, etc) are only triggered by player actions now.
|
||||
/// However, sends still might trigger other sends! So we need to keep a
|
||||
/// list of sends that we trigger in the process of resolving a list of
|
||||
/// actions. When we resolve these sends, we'll keep a list of things we've
|
||||
/// resolved, so we refuse to do the same send twice in a tick: this prevents
|
||||
/// us from accidentally doing an infinite recursion.
|
||||
#[derive(Clone, Debug)]
|
||||
struct SendAction(ObjectId, String, SendArg);
|
||||
|
||||
impl Hash for SendAction {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.0.hash(state);
|
||||
self.1.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for SendAction {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.1 == other.1 && self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for SendAction {}
|
||||
|
||||
/// How long a `say()` speech bubble stays on screen, in seconds.
|
||||
pub const SAY_DURATION: f64 = 3.0;
|
||||
|
||||
@@ -43,7 +17,7 @@ pub const SAY_DURATION: f64 = 3.0;
|
||||
pub use crate::action::ScrollLine;
|
||||
use crate::player::{Player, PlayerRef};
|
||||
use crate::portal::Portal;
|
||||
use crate::tile::{EnterResponse, LocatedObject, Tile};
|
||||
use crate::tile::{EnterResponse, Tile};
|
||||
|
||||
/// An active scroll overlay opened by a scripted object via `scroll()`.
|
||||
///
|
||||
@@ -358,7 +332,7 @@ impl GameState {
|
||||
{
|
||||
// Dispatch the choice back to the source object and apply whatever it
|
||||
// queues (plus any bump/send cascade), the same as a tick.
|
||||
let actions = self.scripts.run_send(scroll.source, &choice, SendArg::None);
|
||||
self.scripts.run_send(scroll.source, &choice, SendArg::None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,8 +365,12 @@ impl GameState {
|
||||
// Clear per-board transient state.
|
||||
self.speech_bubbles.clear();
|
||||
self.active_scroll = None;
|
||||
// Switch to the new board and place the player at the arrival portal.
|
||||
// Switch to the new board
|
||||
self.current_board_name = target_map.to_string();
|
||||
// Clear any player instance that's already on the new board
|
||||
let new_board_player_pos = self.board().player_pos();
|
||||
self.board_mut().get_mut(new_board_player_pos.0, new_board_player_pos.1).take();
|
||||
// place the player at the arrival portal.
|
||||
self.board_mut().get_mut(ax, ay).replace(Tile::Player);
|
||||
self.board_mut().clear_all_queues();
|
||||
// Rebuild the script host for the new board's objects.
|
||||
@@ -522,17 +500,6 @@ impl GameState {
|
||||
}
|
||||
}
|
||||
|
||||
/// What a [`step_object`] call produced, for the caller to resolve after the board
|
||||
/// borrow drops.
|
||||
struct StepOutcome {
|
||||
/// The solid object the move pressed into (directly or at a crate-chain's end),
|
||||
/// which receives a `bump`.
|
||||
bumped: Option<ObjectId>,
|
||||
/// Non-solid objects a solid landed on this move — the mover itself (only if it
|
||||
/// is solid) and every crate it shoved — each of which receives an `enter`.
|
||||
entered: Vec<ObjectId>,
|
||||
}
|
||||
|
||||
/// Moves object `id` one cell in `dir` on `board`, reporting the `bump`/`enter`
|
||||
/// reactions for the caller to resolve after the board borrow drops.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user