aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authortslil clingman <>2020-01-18 17:03:09 -0500
committertslil clingman <>2020-01-18 17:03:09 -0500
commitcdbcc1d2faf198629f5d598bb9a7ba6ab15a922a (patch)
tree9ba2960ba2444d879df42d574ba4b0390c0e8116 /src/main.rs
parentf6a94720061877903487ed98bfee9f19df264a9d (diff)
working on game tracking
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 6d110e1..d664025 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,9 +3,9 @@ extern crate pancurses;
use pancurses::Input::*;
use pancurses::*;
-mod board;
+mod game;
-use crate::board::*;
+use crate::game::*;
struct BoardGui {
win: Window,
@@ -99,8 +99,8 @@ impl BoardGui {
let l = stack.len() as i32;
if l > 0 {
for i in 0..l {
- let (player, stone) = &stack[i as usize];
- self.draw_stone(win, i == l - 1, player, stone);
+ let piece = &stack[i as usize];
+ self.draw_stone(win, i == l - 1, &piece.player, &piece.stone);
}
}
win.refresh();
@@ -108,15 +108,15 @@ impl BoardGui {
}
// Is this really the best way to do this?
- fn draw_board<L: Fn(String)>(&self, board: &Board<L>) {
+ fn draw_game_state(&self, game_state: &GameState) {
// ????
- assert!(board.get_size() == self.size);
+ assert!(game_state.get_size() == self.size);
let mut pos = Position { x: 0, y: 0 };
for y in 0..self.size {
pos.y = y;
for x in 0..self.size {
pos.x = x;
- if let Some(stack) = board.query_square(&pos) {
+ if let Some(stack) = game_state.query_square(&pos) {
self.draw_stack(&pos, stack);
}
}
@@ -288,11 +288,13 @@ fn main() {
me.init();
ml.init();
- let (mut board, _) = Board::new(5, |s| MessageLog::log_error(&ml, s));
+ let log = |s| MessageLog::log_error(&ml, s);
+ let game_state = GameState::new(5);
let pos = Position { x: 0, y: 0 };
- board.perform_action(Action::Place(Player::White, pos, Stone::Flat));
- board.is_legal_action(&Action::Move(Player::White, pos, Direction::Up, vec![0, 1]));
- bg.draw_board(&board);
+ let action = Action::Place(Player::White, pos, Stone::Flat);
+ // game_state.perform_action(&action);
+ // game_state.is_legal_action(&Action::Move(Player::White, pos, Direction::Up, vec![0, 1]));
+ // bg.draw_game_state(&game_state);
loop {
if let Some(inp) = screen.getch() {