player object

This commit is contained in:
2026-06-25 00:04:42 -05:00
parent d8a3f17379
commit db8c8e615d
15 changed files with 207 additions and 168 deletions
+3 -3
View File
@@ -3,7 +3,7 @@ use crate::board::Board;
use crate::game::GameState;
use crate::glyph::Glyph;
use crate::layer::Layer;
use crate::utils::{Direction, Player, PortalDef};
use crate::utils::{Direction, PlayerPos, PortalDef};
use crate::world::World;
use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap};
@@ -18,7 +18,7 @@ fn make_board(px: i32, py: i32, portals: Vec<PortalDef>) -> Board {
layers: vec![Layer {
cells: vec![(Glyph::transparent(), Archetype::Empty); 9],
}],
player: Player { x: px, y: py },
player: PlayerPos { x: px, y: py },
objects: BTreeMap::new(),
next_object_id: 1,
portals,
@@ -112,7 +112,7 @@ fn enter_board_unknown_entry_logs_error() {
fn try_move_onto_portal_switches_board() {
let world = two_board_world();
// Start the player one cell west of the portal at (2, 0).
world.boards["b1"].borrow_mut().player = Player { x: 1, y: 0 };
world.boards["b1"].borrow_mut().player = PlayerPos { x: 1, y: 0 };
let mut game = GameState::from_world(world);
game.try_move(Direction::East);
assert_eq!(game.current_board_name(), "b2");
+2 -2
View File
@@ -11,7 +11,7 @@ use crate::game::GameState;
use crate::glyph::Glyph;
use crate::layer::Layer;
use crate::object_def::ObjectDef;
use crate::utils::Player;
use crate::utils::PlayerPos;
use std::collections::{BTreeMap, HashMap};
/// Builds a 1×1 board with a single object that optionally references a script,
@@ -32,7 +32,7 @@ fn board_with_object(
layers: vec![Layer {
cells: vec![(Glyph::transparent(), Archetype::Empty)],
}],
player: Player { x: 0, y: 0 },
player: PlayerPos { x: 0, y: 0 },
objects: BTreeMap::from([(1, object)]),
next_object_id: 2,
portals: Vec::new(),