Render the Settings page and the Library via view models #227
|
@ -2,6 +2,7 @@ use crate::{
|
||||||
parser::{self, Annotation, Evaluation, Move, SetupInstr, Size, UnknownProperty},
|
parser::{self, Annotation, Evaluation, Move, SetupInstr, Size, UnknownProperty},
|
||||||
Color, Date, GameResult, GameType,
|
Color, Date, GameResult, GameType,
|
||||||
};
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{collections::HashSet, time::Duration};
|
use std::{collections::HashSet, time::Duration};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ pub enum GameNodeError {
|
||||||
ConflictingPosition,
|
ConflictingPosition,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Default)]
|
#[derive(Clone, Debug, PartialEq, Default, Deserialize, Serialize)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub rank: Option<String>,
|
pub rank: Option<String>,
|
||||||
|
@ -51,7 +52,7 @@ pub struct Player {
|
||||||
/// syntax issues, the result of the Game is to have a fully-understood game. However, this doesn't
|
/// syntax issues, the result of the Game is to have a fully-understood game. However, this doesn't
|
||||||
/// (yet?) go quite to the level of apply the game type (i.e., this is Go, Chess, Yinsh, or
|
/// (yet?) go quite to the level of apply the game type (i.e., this is Go, Chess, Yinsh, or
|
||||||
/// whatever).
|
/// whatever).
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct Game {
|
pub struct Game {
|
||||||
pub game_type: GameType,
|
pub game_type: GameType,
|
||||||
|
|
||||||
|
@ -216,7 +217,7 @@ impl TryFrom<&parser::Tree> for Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum GameNode {
|
pub enum GameNode {
|
||||||
MoveNode(MoveNode),
|
MoveNode(MoveNode),
|
||||||
SetupNode(SetupNode),
|
SetupNode(SetupNode),
|
||||||
|
@ -317,7 +318,7 @@ impl TryFrom<&parser::Node> for GameNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct MoveNode {
|
pub struct MoveNode {
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
color: Color,
|
color: Color,
|
||||||
|
@ -426,7 +427,7 @@ impl TryFrom<&parser::Node> for MoveNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct SetupNode {
|
pub struct SetupNode {
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ use nom::{
|
||||||
multi::{many0, many1, separated_list1},
|
multi::{many0, many1, separated_list1},
|
||||||
IResult, Parser,
|
IResult, Parser,
|
||||||
};
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{num::ParseIntError, time::Duration};
|
use std::{num::ParseIntError, time::Duration};
|
||||||
|
|
||||||
impl From<ParseSizeError> for Error {
|
impl From<ParseSizeError> for Error {
|
||||||
|
@ -29,7 +30,7 @@ impl From<ParseIntError> for ParseSizeError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum Annotation {
|
pub enum Annotation {
|
||||||
BadMove,
|
BadMove,
|
||||||
DoubtfulMove,
|
DoubtfulMove,
|
||||||
|
@ -37,7 +38,7 @@ pub enum Annotation {
|
||||||
Tesuji,
|
Tesuji,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum Evaluation {
|
pub enum Evaluation {
|
||||||
Even,
|
Even,
|
||||||
GoodForBlack,
|
GoodForBlack,
|
||||||
|
@ -147,7 +148,7 @@ impl ToString for GameType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct Size {
|
pub struct Size {
|
||||||
pub width: i32,
|
pub width: i32,
|
||||||
pub height: i32,
|
pub height: i32,
|
||||||
|
@ -200,7 +201,7 @@ pub struct Node {
|
||||||
pub next: Vec<Node>,
|
pub next: Vec<Node>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum SetupInstr {
|
pub enum SetupInstr {
|
||||||
Piece((Color, String)),
|
Piece((Color, String)),
|
||||||
Clear(String),
|
Clear(String),
|
||||||
|
@ -288,7 +289,7 @@ impl ToString for Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum Move {
|
pub enum Move {
|
||||||
Move(String),
|
Move(String),
|
||||||
Pass,
|
Pass,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use thiserror::Error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum GameType {
|
pub enum GameType {
|
||||||
Go,
|
Go,
|
||||||
Othello,
|
Othello,
|
||||||
|
@ -96,7 +96,7 @@ impl From<nom::error::Error<&str>> for ParseError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
Black,
|
Black,
|
||||||
White,
|
White,
|
||||||
|
|
Loading…
Reference in New Issue