|
|
|
@ -15,7 +15,7 @@ mod lib { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
use lib::point::Point; |
|
|
|
|
use lib::screen::{BoardCommand, Screen}; |
|
|
|
|
use lib::screen::{init_screen, BoardCommand, Screen}; |
|
|
|
|
use lib::world::World; |
|
|
|
|
use lib::entity::{Queen, Entities}; |
|
|
|
|
|
|
|
|
@ -38,6 +38,12 @@ fn simulate(e: &mut Entities, w: &mut World, b: &mut Screen) { |
|
|
|
|
|
|
|
|
|
for cmd in cmds { |
|
|
|
|
match cmd { |
|
|
|
|
BoardCommand::Move(old_pos, pos) => { |
|
|
|
|
// still makes no difference
|
|
|
|
|
// occupied needs to be updated as soon as the move is made...
|
|
|
|
|
w.occupied.remove(&old_pos); |
|
|
|
|
w.occupied.insert(pos); |
|
|
|
|
} |
|
|
|
|
BoardCommand::Dig(pos) => { |
|
|
|
|
w.clear(pos); |
|
|
|
|
} |
|
|
|
@ -56,23 +62,11 @@ fn simulate(e: &mut Entities, w: &mut World, b: &mut Screen) { |
|
|
|
|
BoardCommand::Noop => {} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
w.occupied.clear(); |
|
|
|
|
let _ = e.data.values().map(|p| w.occupied.insert(p.get_position())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn main() { |
|
|
|
|
initscr(); |
|
|
|
|
|
|
|
|
|
/* Invisible cursor. */ |
|
|
|
|
curs_set(CURSOR_VISIBILITY::CURSOR_INVISIBLE); |
|
|
|
|
|
|
|
|
|
let mut max_x = 0; |
|
|
|
|
let mut max_y = 0; |
|
|
|
|
|
|
|
|
|
getmaxyx(stdscr(), &mut max_y, &mut max_x); |
|
|
|
|
|
|
|
|
|
let mut board = Screen::new(max_x, max_y); |
|
|
|
|
let mut board = init_screen();
|
|
|
|
|
let mut world = World::new(); |
|
|
|
|
|
|
|
|
|
let mut entities = Entities::new(); |
|
|
|
|