aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authortslil clingman <>2020-01-20 23:09:52 -0800
committertslil clingman <>2020-01-20 23:09:52 -0800
commitec4ae2a749315720cc12f3d71f0860e2a32f96d2 (patch)
tree36c884dbfc6f1e04e0a02d6a7be78a98d2930fd6 /src/main.rs
parent42e504281ba8c36c0bf5c679dd767f04310655f3 (diff)
Move rules were incorrectly/incompletely implemented
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs
index 2100073..6bbe52d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -36,7 +36,7 @@ fn main() {
let board_bottom = (size * cell_height + 3) as i32;
let board_right = (size * cell_width + hoff + 3) as i32;
- let mut board_gui = BoardGUI::new(
+ let board_gui = BoardGUI::new(
0,
0,
size,
@@ -48,7 +48,15 @@ fn main() {
black_colour,
);
- let game_log = GameLog::new(0, board_right, height, 20);
+ let game_log = GameLog::new(
+ 0,
+ board_right,
+ height,
+ 20,
+ has_colours,
+ white_colour,
+ black_colour,
+ );
// Need room for '8___011111111', for example
let action_entry = ActionEntry::new(board_bottom, 0, 13);
@@ -64,30 +72,37 @@ fn main() {
let (mut game, warning) = Game::new(5, "tslil", "taktician");
message_log.log_error(warning);
-
- let pos = Position { x: 0, y: 0 };
- let action = Action::Place(Player::White, pos, Stone::Flat);
-
- if let Err(e) = game.perform_action(action) {
- message_log.log_error(e);
- }
-
- board_gui.update(&game);
game_log.update(&game);
loop {
let inp = action_entry.read_action();
- match parse_action(game.query_current_player(), &inp) {
- Ok(act) => message_log.log_error(format!("{}", act)),
+ let stone_owner = game.query_stone_owner();
+ let player = game.query_current_player();
+ match parse_action(stone_owner, &inp) {
Err(err) => message_log.log_error(format!("Input \"{}\": {}", inp, err)),
+ Ok(act) => {
+ message_log.log_message(format!(
+ "{} performs {}{}",
+ player,
+ act,
+ if stone_owner != player {
+ format!(" with a {} stone.", stone_owner)
+ } else {
+ String::from(".")
+ }
+ ));
+ match game.perform_action(act) {
+ Err(e) => message_log.log_error(e),
+ Ok(pos_vec) => {
+ board_gui.update(&game, pos_vec);
+ game_log.update(&game);
+ }
+ }
+ }
}
action_entry.clear_entry_area();
}
- // 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);
-
// board_gui.read_action();
// endwin();
}