Compare commits
18 Commits
5486c3ce37
...
3192c0a142
Author | SHA1 | Date |
---|---|---|
Savanni D'Gerinel | 3192c0a142 | |
Savanni D'Gerinel | acf7ca0c9a | |
Savanni D'Gerinel | 64138b9e90 | |
Savanni D'Gerinel | e587d269e9 | |
Savanni D'Gerinel | 57aadd7597 | |
Savanni D'Gerinel | b70d927eac | |
Savanni D'Gerinel | 3a7f204883 | |
Savanni D'Gerinel | 642351f248 | |
Savanni D'Gerinel | d9bb9d92e5 | |
Savanni D'Gerinel | 30e7bdb817 | |
Savanni D'Gerinel | 556f91b70b | |
Savanni D'Gerinel | 894575b0fb | |
Savanni D'Gerinel | d964ab0d2f | |
Savanni D'Gerinel | 74c8eb6861 | |
Savanni D'Gerinel | 3aac3b8393 | |
Savanni D'Gerinel | 295f0a0411 | |
Savanni D'Gerinel | e694ba74ca | |
Savanni D'Gerinel | 5f9cd2622a |
|
@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with On
|
|||
// documenting) my code from almost a year ago.
|
||||
//
|
||||
use crate::{BoardError, Color, Size};
|
||||
use sgf::{GameNode, Move, MoveNode};
|
||||
use sgf::{GameNode, MoveNode};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
|
@ -221,7 +221,7 @@ impl Goban {
|
|||
) -> Result<Goban, BoardError> {
|
||||
let mut s = self;
|
||||
for m in moves.into_iter() {
|
||||
let s = match m {
|
||||
match m {
|
||||
GameNode::MoveNode(node) => s = s.apply_move_node(node)?,
|
||||
GameNode::SetupNode(_n) => unimplemented!("setup nodes aren't processed yet"),
|
||||
};
|
||||
|
|
|
@ -16,20 +16,22 @@ You should have received a copy of the GNU General Public License along with On
|
|||
|
||||
use crate::CoreApi;
|
||||
use adw::prelude::*;
|
||||
use async_std::task::{block_on, spawn};
|
||||
|
||||
use otg_core::{
|
||||
settings::{SettingsRequest, SettingsResponse},
|
||||
Config, CoreRequest, CoreResponse,
|
||||
CoreRequest, CoreResponse,
|
||||
};
|
||||
use sgf::GameRecord;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use crate::views::{GameReview, HomeView, SettingsView};
|
||||
|
||||
/*
|
||||
#[derive(Clone)]
|
||||
enum AppView {
|
||||
Home,
|
||||
}
|
||||
*/
|
||||
|
||||
// An application window should generally contain
|
||||
// - an overlay widget
|
||||
|
@ -46,7 +48,7 @@ pub struct AppWindow {
|
|||
// we can maintain the state of previous views. Since the two of these work together, they are
|
||||
// a candidate for extraction into a new widget or a new struct.
|
||||
stack: adw::NavigationView,
|
||||
view_states: Vec<AppView>,
|
||||
// view_states: Vec<AppView>,
|
||||
|
||||
// Overlays are for transient content, such as about and settings, which can be accessed from
|
||||
// anywhere but shouldn't be part of the main application flow.
|
||||
|
@ -63,7 +65,7 @@ impl AppWindow {
|
|||
let window = Self::setup_window(app);
|
||||
let overlay = Self::setup_overlay();
|
||||
let stack = adw::NavigationView::new();
|
||||
let view_states = vec![];
|
||||
// let view_states = vec![];
|
||||
|
||||
window.set_content(Some(&overlay));
|
||||
overlay.set_child(Some(&stack));
|
||||
|
@ -71,7 +73,7 @@ impl AppWindow {
|
|||
let s = Self {
|
||||
window,
|
||||
stack,
|
||||
view_states,
|
||||
// view_states,
|
||||
overlay,
|
||||
core,
|
||||
settings_view_model: Default::default(),
|
||||
|
@ -79,7 +81,7 @@ impl AppWindow {
|
|||
|
||||
let home = s.setup_home();
|
||||
|
||||
let _ = s.stack.push(&home);
|
||||
s.stack.push(&home);
|
||||
|
||||
s
|
||||
}
|
||||
|
@ -149,23 +151,18 @@ impl AppWindow {
|
|||
|
||||
pub fn close_overlay(&self) {
|
||||
let mut view = self.settings_view_model.write().unwrap();
|
||||
match *view {
|
||||
Some(ref mut settings) => {
|
||||
if let Some(ref mut settings) = *view {
|
||||
self.overlay.remove_overlay(settings);
|
||||
*view = None;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_window(app: &adw::Application) -> adw::ApplicationWindow {
|
||||
let window = adw::ApplicationWindow::builder()
|
||||
adw::ApplicationWindow::builder()
|
||||
.application(app)
|
||||
.width_request(800)
|
||||
.height_request(500)
|
||||
.build();
|
||||
|
||||
window
|
||||
.build()
|
||||
}
|
||||
|
||||
fn setup_header() -> adw::HeaderBar {
|
||||
|
|
|
@ -36,16 +36,15 @@ You should have received a copy of the GNU General Public License along with On
|
|||
// that.
|
||||
|
||||
use crate::perftrace;
|
||||
use gio::resources_lookup_data;
|
||||
|
||||
use glib::Object;
|
||||
use gtk::{
|
||||
gdk_pixbuf::{InterpType, Pixbuf},
|
||||
prelude::*,
|
||||
subclass::prelude::*,
|
||||
};
|
||||
use image::io::Reader as ImageReader;
|
||||
|
||||
use otg_core::{Color, Coordinate};
|
||||
use std::{cell::RefCell, io::Cursor, rc::Rc};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
const WIDTH: i32 = 800;
|
||||
const HEIGHT: i32 = 800;
|
||||
|
@ -241,6 +240,7 @@ impl Pen {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn ghost_stone(&self, context: &cairo::Context, row: u8, col: u8, color: Color) {
|
||||
match color {
|
||||
Color::White => context.set_source_rgba(0.9, 0.9, 0.9, 0.5),
|
||||
|
|
|
@ -18,14 +18,13 @@ use cairo::Context;
|
|||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use sgf::{GameNode, GameRecord};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
const WIDTH: i32 = 200;
|
||||
const HEIGHT: i32 = 800;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ReviewTreePrivate {
|
||||
record: Rc<RefCell<Option<GameRecord>>>,
|
||||
// record: Rc<RefCell<Option<GameRecord>>>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
@ -44,7 +43,7 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl ReviewTree {
|
||||
pub fn new(record: GameRecord) -> Self {
|
||||
pub fn new(_record: GameRecord) -> Self {
|
||||
let s: Self = Object::new();
|
||||
|
||||
s.set_width_request(WIDTH);
|
||||
|
@ -60,7 +59,7 @@ impl ReviewTree {
|
|||
s
|
||||
}
|
||||
|
||||
pub fn redraw(&self, ctx: &Context, width: i32, height: i32) {
|
||||
pub fn redraw(&self, _ctx: &Context, _width: i32, _height: i32) {
|
||||
// Implement the tree-drawing algorithm here
|
||||
}
|
||||
}
|
||||
|
@ -113,13 +112,14 @@ struct Tree {
|
|||
// out if it has children that would overlap the children of the first node.
|
||||
//
|
||||
// My algorithm right now is likely to generate unnecessarily wide trees in a complex game review.
|
||||
#[allow(dead_code)]
|
||||
fn node_width(node: &GameNode) -> usize {
|
||||
let children: &Vec<GameNode> = match node {
|
||||
GameNode::MoveNode(mn) => &mn.children,
|
||||
GameNode::SetupNode(sn) => &sn.children,
|
||||
};
|
||||
|
||||
if children.len() == 0 {
|
||||
if children.is_empty() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,8 @@ fn node_width(node: &GameNode) -> usize {
|
|||
//
|
||||
// Just having the node is greatly insufficient. I can get better results if I'm calculating the
|
||||
// position of its children.
|
||||
fn node_children_columns(node: &GameNode) -> Vec<usize> {
|
||||
#[allow(dead_code)]
|
||||
fn node_children_columns(_node: &GameNode) -> Vec<usize> {
|
||||
vec![0, 1, 2]
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ pub use app_window::AppWindow;
|
|||
|
||||
mod views;
|
||||
|
||||
use async_std::task::{spawn, yield_now};
|
||||
use async_std::task::{yield_now};
|
||||
use otg_core::{Core, Observable, CoreRequest, CoreResponse};
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
use tokio::runtime::Runtime;
|
||||
use std::{rc::Rc};
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CoreApi {
|
||||
|
@ -51,6 +51,7 @@ where
|
|||
/// LocalObserver creates a task on the current thread which watches the specified observer for notifications and calls the handler function with each one.
|
||||
///
|
||||
/// The LocalObserver starts a task which listens for notifications during the constructor. When the observer goes out of scope, it will make a point of aborting the task. This combination means that anything which uses the observer can create it, hold on to a reference of it, and then drop it when done, and not have to do anything else with the observer object.
|
||||
#[allow(dead_code)]
|
||||
struct LocalObserver<T> {
|
||||
join_handle: glib::JoinHandle<()>,
|
||||
handler: Rc<dyn Fn(T)>,
|
||||
|
@ -61,6 +62,7 @@ impl<T: 'static> LocalObserver<T> {
|
|||
///
|
||||
/// observable -- any object which emits events
|
||||
/// handler -- a function which can process events
|
||||
#[allow(dead_code)]
|
||||
fn new(observable: &dyn Observable<T>, handler: impl Fn(T) + 'static) -> Self {
|
||||
let listener = observable.subscribe();
|
||||
let handler = Rc::new(handler);
|
||||
|
|
|
@ -4,17 +4,15 @@ use async_std::task::spawn;
|
|||
use gio::ActionEntry;
|
||||
use otg_core::{Config, ConfigOption, Core, CoreNotification, LibraryPath, Observable};
|
||||
use otg_gtk::{
|
||||
perftrace,
|
||||
// ui::{ConfigurationPage, Home, PlayingField},
|
||||
AppWindow,
|
||||
CoreApi,
|
||||
};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
|
||||
const APP_ID_DEV: &str = "com.luminescent-dreams.otg.dev";
|
||||
const APP_ID_PROD: &str = "com.luminescent-dreams.otg";
|
||||
|
||||
const RESOURCE_BASE_PATH: &str = "/com/luminescent-dreams/otg/";
|
||||
// const RESOURCE_BASE_PATH: &str = "/com/luminescent-dreams/otg/";
|
||||
|
||||
async fn handler(notifications: Receiver<CoreNotification>, app_id: String) {
|
||||
loop {
|
||||
|
@ -108,7 +106,7 @@ fn main() {
|
|||
APP_ID_PROD
|
||||
};
|
||||
|
||||
let config = load_config(&app_id);
|
||||
let config = load_config(app_id);
|
||||
|
||||
let core = Core::new(config.clone());
|
||||
|
||||
|
|
|
@ -28,13 +28,10 @@ use gtk::{prelude::*, subclass::prelude::*};
|
|||
use otg_core::Color;
|
||||
use sgf::GameRecord;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct GameReviewPrivate {}
|
||||
|
||||
impl Default for GameReviewPrivate {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for GameReviewPrivate {
|
||||
|
@ -52,7 +49,7 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl GameReview {
|
||||
pub fn new(api: CoreApi, record: GameRecord) -> Self {
|
||||
pub fn new(_api: CoreApi, record: GameRecord) -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
|
||||
// It's actually really bad to be just throwing away errors. Panics make everyone unhappy.
|
||||
|
|
|
@ -22,7 +22,7 @@ use otg_core::{
|
|||
CoreRequest, CoreResponse,
|
||||
};
|
||||
use sgf::GameRecord;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
|
||||
/*
|
||||
struct PlayerDataEntryPrivate {
|
||||
|
@ -101,19 +101,13 @@ impl PlayerDataEntry {
|
|||
}
|
||||
*/
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct HomePrivate {
|
||||
// black_player: Rc<RefCell<Option<PlayerDataEntry>>>,
|
||||
// white_player: Rc<RefCell<Option<PlayerDataEntry>>>,
|
||||
}
|
||||
|
||||
impl Default for HomePrivate {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
// black_player: Rc::new(RefCell::new(None)),
|
||||
// white_player: Rc::new(RefCell::new(None)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for HomePrivate {
|
||||
|
@ -158,7 +152,7 @@ impl HomeView {
|
|||
s.append(&new_game_button);
|
||||
*/
|
||||
|
||||
let library = Library::new(move |game| on_select_game(game));
|
||||
let library = Library::new(on_select_game);
|
||||
let library_view = gtk::ScrolledWindow::builder()
|
||||
.hscrollbar_policy(gtk::PolicyType::Never)
|
||||
.min_content_width(360)
|
||||
|
|
|
@ -14,11 +14,11 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License along with On the Grid. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::{borrow::Cow, cell::RefCell, path::Path, rc::Rc};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use adw::prelude::*;
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use gtk::{subclass::prelude::*};
|
||||
use otg_core::{Config, ConfigOption, LibraryPath};
|
||||
|
||||
fn library_chooser_row(
|
||||
|
@ -33,7 +33,7 @@ fn library_chooser_row(
|
|||
.valign(gtk::Align::Center)
|
||||
.build();
|
||||
|
||||
let parent = parent.clone();
|
||||
let _parent = parent.clone();
|
||||
|
||||
let library_row = adw::ActionRow::builder()
|
||||
.title("Library Path")
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "1.73.0"
|
||||
channel = "1.77.0"
|
||||
targets = [ "wasm32-unknown-unknown" ]
|
||||
|
|
|
@ -11,9 +11,5 @@ fn main() {
|
|||
println!("{:?}", file);
|
||||
|
||||
let games = parse_sgf_file(&file).unwrap();
|
||||
for sgf in games {
|
||||
if let Ok(sgf) = sgf {
|
||||
println!("{:?}", sgf.white_player);
|
||||
}
|
||||
}
|
||||
games.into_iter().flatten().for_each(|sgf| println!("{:?}", sgf.white_player));
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ impl GameRecord {
|
|||
/// Generate a list of moves which constitute the main line of the game. This is the game as it
|
||||
/// was actually played out, and by convention consists of the first node in each list of
|
||||
/// children.
|
||||
pub fn mainline<'a>(&'a self) -> Vec<&'a GameNode> {
|
||||
pub fn mainline(&self) -> Vec<&GameNode> {
|
||||
let mut moves: Vec<&GameNode> = vec![];
|
||||
|
||||
let mut next = self.children.get(0);
|
||||
|
@ -150,7 +150,7 @@ impl Node for GameRecord {
|
|||
self.children.iter().collect::<Vec<&'a GameNode>>()
|
||||
}
|
||||
|
||||
fn add_child<'a>(&'a mut self, node: GameNode) -> &'a mut GameNode {
|
||||
fn add_child(&mut self, node: GameNode) -> &mut GameNode {
|
||||
self.children.push(node);
|
||||
self.children.last_mut().unwrap()
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ impl TryFrom<&parser::Tree> for GameRecord {
|
|||
parser::Property::Round(v) => s.round = Some(v.clone()),
|
||||
parser::Property::Ruleset(v) => s.rules = Some(v.clone()),
|
||||
parser::Property::Source(v) => s.source = Some(v.clone()),
|
||||
parser::Property::TimeLimit(v) => s.time_limit = Some(v.clone()),
|
||||
parser::Property::TimeLimit(v) => s.time_limit = Some(*v),
|
||||
parser::Property::Overtime(v) => s.overtime = Some(v.clone()),
|
||||
// parser::Property::Data(v) => s.transcriber = Some(v.clone()),
|
||||
_ => {}
|
||||
|
@ -238,7 +238,7 @@ impl TryFrom<&parser::Tree> for GameRecord {
|
|||
.root
|
||||
.next
|
||||
.iter()
|
||||
.map(|node| GameNode::try_from(node))
|
||||
.map(GameNode::try_from)
|
||||
.collect::<Result<Vec<GameNode>, GameNodeError>>()
|
||||
.map_err(GameError::InvalidGameNode)?;
|
||||
|
||||
|
@ -257,18 +257,17 @@ pub trait Node {
|
|||
fn nodes<'a>(&'a self) -> Vec<&'a GameNode> {
|
||||
self.children()
|
||||
.iter()
|
||||
.map(|node| {
|
||||
.flat_map(|node| {
|
||||
let mut children = node.nodes();
|
||||
let mut v = vec![*node];
|
||||
v.append(&mut children);
|
||||
v
|
||||
})
|
||||
.flatten()
|
||||
.collect::<Vec<&'a GameNode>>()
|
||||
}
|
||||
|
||||
fn children<'a>(&'a self) -> Vec<&'a GameNode>;
|
||||
fn add_child<'a>(&'a mut self, node: GameNode) -> &'a mut GameNode;
|
||||
fn children(&self) -> Vec<&GameNode>;
|
||||
fn add_child(&mut self, node: GameNode) -> &mut GameNode;
|
||||
}
|
||||
|
||||
impl GameNode {
|
||||
|
@ -281,21 +280,21 @@ impl GameNode {
|
|||
}
|
||||
|
||||
impl Node for GameNode {
|
||||
fn children<'a>(&'a self) -> Vec<&'a GameNode> {
|
||||
fn children(&self) -> Vec<&GameNode> {
|
||||
match self {
|
||||
GameNode::MoveNode(node) => node.children(),
|
||||
GameNode::SetupNode(node) => node.children(),
|
||||
}
|
||||
}
|
||||
|
||||
fn nodes<'a>(&'a self) -> Vec<&'a GameNode> {
|
||||
fn nodes(&self) -> Vec<&GameNode> {
|
||||
match self {
|
||||
GameNode::MoveNode(node) => node.nodes(),
|
||||
GameNode::SetupNode(node) => node.nodes(),
|
||||
}
|
||||
}
|
||||
|
||||
fn add_child<'a>(&'a mut self, new_node: GameNode) -> &'a mut GameNode {
|
||||
fn add_child(&mut self, new_node: GameNode) -> &mut GameNode {
|
||||
match self {
|
||||
GameNode::MoveNode(node) => node.add_child(new_node),
|
||||
GameNode::SetupNode(node) => node.add_child(new_node),
|
||||
|
@ -326,7 +325,7 @@ impl TryFrom<&parser::Node> for GameNode {
|
|||
let children = n
|
||||
.next
|
||||
.iter()
|
||||
.map(|n| GameNode::try_from(n))
|
||||
.map(GameNode::try_from)
|
||||
.collect::<Result<Vec<Self>, Self::Error>>()?;
|
||||
|
||||
let node = match (move_node, setup_node) {
|
||||
|
@ -389,7 +388,7 @@ impl Node for MoveNode {
|
|||
self.children.iter().collect::<Vec<&'a GameNode>>()
|
||||
}
|
||||
|
||||
fn add_child<'a>(&'a mut self, node: GameNode) -> &'a mut GameNode {
|
||||
fn add_child(&mut self, node: GameNode) -> &mut GameNode {
|
||||
self.children.push(node);
|
||||
self.children.last_mut().unwrap()
|
||||
}
|
||||
|
@ -417,7 +416,7 @@ impl TryFrom<&parser::Node> for MoveNode {
|
|||
if s.time_left.is_some() {
|
||||
return Err(Self::Error::ConflictingProperty);
|
||||
}
|
||||
s.time_left = Some(duration.clone());
|
||||
s.time_left = Some(*duration);
|
||||
}
|
||||
parser::Property::Comment(cmt) => {
|
||||
if s.comments.is_some() {
|
||||
|
@ -492,7 +491,7 @@ impl Node for SetupNode {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn add_child<'a>(&'a mut self, _node: GameNode) -> &'a mut GameNode {
|
||||
fn add_child(&mut self, _node: GameNode) -> &mut GameNode {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +508,7 @@ impl TryFrom<&parser::Node> for SetupNode {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn path_to_node<'a>(node: &'a GameNode, id: Uuid) -> Vec<&'a GameNode> {
|
||||
pub fn path_to_node(node: &GameNode, id: Uuid) -> Vec<&GameNode> {
|
||||
if node.id() == id {
|
||||
return vec![node];
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ impl From<nom::error::Error<&str>> for ParseError {
|
|||
/// The inner Result is for errors in each individual game in the file. All of the other games can
|
||||
/// still be kept as valid.
|
||||
pub fn parse_sgf(input: &str) -> Result<Vec<Result<GameRecord, game::GameError>>, Error> {
|
||||
let (_, games) = parse_collection::<nom::error::VerboseError<&str>>(&input)?;
|
||||
let (_, games) = parse_collection::<nom::error::VerboseError<&str>>(input)?;
|
||||
let games = games
|
||||
.into_iter()
|
||||
.map(|game| GameRecord::try_from(&game))
|
||||
|
|
|
@ -10,7 +10,7 @@ use nom::{
|
|||
IResult, Parser,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{num::ParseIntError, time::Duration};
|
||||
use std::{fmt::Write, num::ParseIntError, time::Duration};
|
||||
|
||||
impl From<ParseSizeError> for Error {
|
||||
fn from(_: ParseSizeError) -> Self {
|
||||
|
@ -303,9 +303,9 @@ impl Move {
|
|||
if s.len() == 2 {
|
||||
let mut parts = s.chars();
|
||||
let row_char = parts.next().unwrap();
|
||||
let row = row_char as u8 - 'a' as u8;
|
||||
let row = row_char as u8 - b'a';
|
||||
let column_char = parts.next().unwrap();
|
||||
let column = column_char as u8 - 'a' as u8;
|
||||
let column = column_char as u8 - b'a';
|
||||
Some((row, column))
|
||||
} else {
|
||||
unimplemented!("moves must contain exactly two characters");
|
||||
|
@ -527,22 +527,20 @@ impl ToString for Property {
|
|||
Property::WhiteRank(value) => format!("WR[{}]", value),
|
||||
Property::WhiteTeam(value) => format!("WT[{}]", value),
|
||||
Property::Territory(Color::White, positions) => {
|
||||
format!(
|
||||
"TW{}",
|
||||
positions
|
||||
.iter()
|
||||
.map(|Position(p)| format!("[{}]", p))
|
||||
.collect::<String>()
|
||||
)
|
||||
.fold("TW".to_owned(), |mut output, Position(p)| {
|
||||
let _ = write!(output, "{}", p);
|
||||
output
|
||||
})
|
||||
}
|
||||
Property::Territory(Color::Black, positions) => {
|
||||
format!(
|
||||
"TB{}",
|
||||
positions
|
||||
.iter()
|
||||
.map(|Position(p)| format!("[{}]", p))
|
||||
.collect::<String>()
|
||||
)
|
||||
.fold("TB".to_owned(), |mut output, Position(p)| {
|
||||
let _ = write!(output, "{}", p);
|
||||
output
|
||||
})
|
||||
}
|
||||
Property::Unknown(UnknownProperty { ident, value }) => {
|
||||
format!("{}[{}]", ident, value)
|
||||
|
@ -965,7 +963,7 @@ fn parse_win_score<'a, E: nom::error::ParseError<&'a str>>() -> impl Parser<&'a
|
|||
mod test {
|
||||
use super::*;
|
||||
|
||||
const EXAMPLE: &'static str = "(;FF[4]C[root](;C[a];C[b](;C[c])
|
||||
const EXAMPLE: &str = "(;FF[4]C[root](;C[a];C[b](;C[c])
|
||||
(;C[d];C[e]))
|
||||
(;C[f](;C[g];C[h];C[i])
|
||||
(;C[j])))";
|
||||
|
|
Loading…
Reference in New Issue