1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
mod game;
mod gui;
mod parser;
use crate::game::*;
use crate::gui::*;
use crate::parser::*;
fn main() {
let screen = initscr();
cbreak();
noecho();
curs_set(2);
let has_colours = has_colors();
let (black_colour, white_colour, red_colour): (u8, u8, u8) = (1, 2, 3);
if has_colours {
start_color();
use_default_colors();
init_pair(black_colour as i16, -1, COLOR_RED);
init_pair(white_colour as i16, -1, COLOR_BLUE);
init_pair(red_colour as i16, COLOR_RED, -1);
}
screen.refresh();
let mut board_gui = BoardGUI::new(0, 0, 5, 4, 8, 3, has_colours, white_colour, black_colour);
let game_log = GameLog::new(0, 5 * 8 + 3 + 3, 100, 20);
let message_log = MessageLog::new(26, 0, 3, 70, has_colours, red_colour);
let action_entry = ActionEntry::new(25, 0, 10);
let log = |s| message_log.log_error(s);
let mut game = Game::new(5, "tslil", "taktician", log);
let pos = Position { x: 0, y: 0 };
let action = Action::Place(Player::White, pos, Stone::Flat);
game.perform_action(action);
board_gui.update(&game);
game_log.update(&game);
match parse_action(game.query_current_player(), &action_entry.read_action()) {
Ok(act) => log(format!("{}", act)),
Err(err) => log(err),
}
// 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();
}
|