diff options
| author | tslil clingman <> | 2020-01-14 20:44:29 -0500 |
|---|---|---|
| committer | tslil clingman <> | 2020-01-14 20:44:29 -0500 |
| commit | 7dcf57f6f2e987d44391ae68b8c48824ba7523a6 (patch) | |
| tree | a5966c819ba848c31e7b7ffde60780d9644b29a5 /src/main.rs | |
| parent | 0c3c243d60d49e1c18e5a18fc2300e7e47292938 (diff) | |
Second draft of checking code, beginning on perform actions
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 5794458..4528e96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ impl BoardGui { let y: i32 = pos.y as i32; let x: i32 = pos.x as i32; if (y < self.size) && (x < self.size) { - let y = y * self.cell_height + 1; + let y = (self.size - y) * self.cell_height + 1; let x = self.hoff + x * self.cell_width + 1; self.win.mv(y, x); self.win.refresh(); @@ -123,6 +123,24 @@ impl MoveEntry { // self.win.mvchgat(0,12,10,A_NORMAL,COLOR_PAIR(1)); self.win.refresh(); } + + fn read_action(&self) -> &str { + "a1" + } +} + +struct MessageLog { + win: Window, +} + +impl MessageLog { + fn init(&self) {} + + fn log_error(&self, str: String) { + // self.win.clear(); + self.win.addstr(str); + self.win.refresh(); + } } fn main() { @@ -143,6 +161,7 @@ fn main() { let bgw = newwin(25, 40, 0, 0); let mew = newwin(1, 30, 25, 0); + let mlw = newwin(3, 70, 26, 0); let mut bg = BoardGui { win: bgw, @@ -155,8 +174,18 @@ fn main() { let me = MoveEntry { win: mew }; + let ml = MessageLog { win: mlw }; + bg.init(); me.init(); + ml.init(); + + let board_option = Board::new(5, |s| MessageLog::log_error(&ml, s)); + if let Some(mut board) = board_option { + 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])); + } loop { if let Some(inp) = screen.getch() { |
