Place a stone onto the drawing area #38

Merged
savanni merged 7 commits from feature/place-stone into main 2023-04-07 12:14:04 +00:00
5 changed files with 21 additions and 12 deletions
Showing only changes of commit b64eda7efd - Show all commits

View File

@ -1,6 +1,6 @@
use std::time::Duration;
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Color {
Black,
White,

View File

@ -1,12 +1,12 @@
use crate::types::{Color, Size};
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Jitter {
pub x: i8,
pub y: i8,
}
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct StoneElement {
pub color: Color,
pub jitter: Jitter,
@ -21,13 +21,13 @@ impl StoneElement {
}
}
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct PlayStoneRequest {
col: u8,
row: u8,
}
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum IntersectionElement {
Unplayable,
Empty(PlayStoneRequest),

View File

@ -131,7 +131,15 @@ impl ObjectImpl for BoardPrivate {
});
let cursor = cursor_location.borrow();
pen.ghost_stone(context, cursor.row, cursor.column, *current_player.borrow());
match board.stone(cursor.row, cursor.column) {
IntersectionElement::Empty(_) => pen.ghost_stone(
context,
cursor.row,
cursor.column,
*current_player.borrow(),
),
_ => {}
}
});
let motion_controller = gtk::EventControllerMotion::new();

View File

@ -90,9 +90,13 @@ impl PlayingField {
#[cfg(feature = "screenplay")]
pub fn playing_field_view() -> PlayingFieldView {
let mut board = Board::default();
*board.stone_mut(4, 4) = Some(StoneElement::new(Color::White));
*board.stone_mut(15, 15) = Some(StoneElement::new(Color::Black));
let mut board = BoardElement::new(Size {
width: 19,
height: 19,
});
*board.stone_mut(4, 4) = IntersectionElement::Filled(StoneElement::new(Color::White));
*board.stone_mut(15, 15) = IntersectionElement::Filled(StoneElement::new(Color::Black));
*board.stone_mut(18, 18) = IntersectionElement::Unplayable;
let player_card_black = PlayerCardElement {
color: Color::Black,
name: "Savanni".to_owned(),

View File

@ -1,3 +0,0 @@
[toolchain]
channel = "1.68.2"
components = ["rust-src"]