Place a stone onto the drawing area #38
|
@ -1,6 +1,6 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
Black,
|
Black,
|
||||||
White,
|
White,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::types::{Color, Size};
|
use crate::types::{Color, Size};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct Jitter {
|
pub struct Jitter {
|
||||||
pub x: i8,
|
pub x: i8,
|
||||||
pub y: i8,
|
pub y: i8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct StoneElement {
|
pub struct StoneElement {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
pub jitter: Jitter,
|
pub jitter: Jitter,
|
||||||
|
@ -21,13 +21,13 @@ impl StoneElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct PlayStoneRequest {
|
pub struct PlayStoneRequest {
|
||||||
col: u8,
|
col: u8,
|
||||||
row: u8,
|
row: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum IntersectionElement {
|
pub enum IntersectionElement {
|
||||||
Unplayable,
|
Unplayable,
|
||||||
Empty(PlayStoneRequest),
|
Empty(PlayStoneRequest),
|
||||||
|
|
|
@ -131,7 +131,15 @@ impl ObjectImpl for BoardPrivate {
|
||||||
});
|
});
|
||||||
|
|
||||||
let cursor = cursor_location.borrow();
|
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();
|
let motion_controller = gtk::EventControllerMotion::new();
|
||||||
|
|
|
@ -90,9 +90,13 @@ impl PlayingField {
|
||||||
|
|
||||||
#[cfg(feature = "screenplay")]
|
#[cfg(feature = "screenplay")]
|
||||||
pub fn playing_field_view() -> PlayingFieldView {
|
pub fn playing_field_view() -> PlayingFieldView {
|
||||||
let mut board = Board::default();
|
let mut board = BoardElement::new(Size {
|
||||||
*board.stone_mut(4, 4) = Some(StoneElement::new(Color::White));
|
width: 19,
|
||||||
*board.stone_mut(15, 15) = Some(StoneElement::new(Color::Black));
|
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 {
|
let player_card_black = PlayerCardElement {
|
||||||
color: Color::Black,
|
color: Color::Black,
|
||||||
name: "Savanni".to_owned(),
|
name: "Savanni".to_owned(),
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[toolchain]
|
|
||||||
channel = "1.68.2"
|
|
||||||
components = ["rust-src"]
|
|
Loading…
Reference in New Issue