Don't render ghost stones on unplayable or filled spaces
This commit is contained in:
parent
553d3f8496
commit
b64eda7efd
|
@ -1,6 +1,6 @@
|
|||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Color {
|
||||
Black,
|
||||
White,
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[toolchain]
|
||||
channel = "1.68.2"
|
||||
components = ["rust-src"]
|
Loading…
Reference in New Issue