From f2a41be8d17d19f10aab3727a02ae6d32b225ae8 Mon Sep 17 00:00:00 2001 From: Cutieguwu Date: Mon, 31 Mar 2025 18:39:05 -0400 Subject: [PATCH] Fix PAT notation and Touchdown notations. Backwards compatible w/ v3.0.0 if `implicit_some` enabled in RON log and no PAT specified within. --- gamelog/Cargo.lock | 2 +- gamelog/Cargo.toml | 2 +- gamelog/src/event.rs | 12 ++++++++++-- gamelog/src/file.rs | 6 ++++-- gamelog/src/lib.rs | 2 -- gamelog/src/play.rs | 17 ++++++++++++++--- gamelog/src/score.rs | 8 -------- miller/Cargo.lock | 2 +- 8 files changed, 31 insertions(+), 20 deletions(-) delete mode 100644 gamelog/src/score.rs diff --git a/gamelog/Cargo.lock b/gamelog/Cargo.lock index 93a3f7b..b7fd1f5 100644 --- a/gamelog/Cargo.lock +++ b/gamelog/Cargo.lock @@ -19,7 +19,7 @@ dependencies = [ [[package]] name = "gamelog" -version = "0.3.0" +version = "0.3.1" dependencies = [ "ron", "semver", diff --git a/gamelog/Cargo.toml b/gamelog/Cargo.toml index ac307c4..4b28b0b 100644 --- a/gamelog/Cargo.toml +++ b/gamelog/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gamelog" -version = "0.3.0" +version = "0.3.1" edition = "2024" [dependencies] diff --git a/gamelog/src/event.rs b/gamelog/src/event.rs index bc385b8..8f0b1c5 100644 --- a/gamelog/src/event.rs +++ b/gamelog/src/event.rs @@ -1,4 +1,4 @@ -use crate::{Play, ScoreChange, Team, TerrainState}; +use crate::{Play, Team, TerrainState}; use serde::Deserialize; @@ -10,5 +10,13 @@ pub enum Event { Kickoff(Offence), Turnover(Offence), Penalty(TerrainState), - ScoreChange(ScoreChange), + Score(u8), + Pat(PatPoints), +} + +#[derive(Debug, Deserialize, Clone, PartialEq)] +pub enum PatPoints { + Fail, + One, + Two, } diff --git a/gamelog/src/file.rs b/gamelog/src/file.rs index 71d4334..48f5413 100644 --- a/gamelog/src/file.rs +++ b/gamelog/src/file.rs @@ -20,7 +20,7 @@ impl LogFile { /// Returns if the LogFile min version is compatible. pub fn is_compatible(&self) -> bool { - self.min_ver().cmp_precedence(&super::MIN_VER).is_lt() + self.min_ver().cmp_precedence(&crate::MIN_VER).is_lt() } } @@ -28,7 +28,9 @@ impl TryFrom for LogFile { type Error = ron::error::SpannedError; fn try_from(file: File) -> Result { - ron::de::from_reader(file) + ron::Options::default() + .with_default_extension(ron::extensions::Extensions::EXPLICIT_STRUCT_NAMES) + .from_reader(file) } } diff --git a/gamelog/src/lib.rs b/gamelog/src/lib.rs index 9dd1de2..1722a2c 100644 --- a/gamelog/src/lib.rs +++ b/gamelog/src/lib.rs @@ -7,7 +7,6 @@ mod file; mod game; mod period; mod play; -mod score; mod terrain; #[allow(unused)] @@ -19,5 +18,4 @@ pub use file::LogFile; pub use game::{Game, GameRecord}; pub use period::*; pub use play::*; -pub use score::ScoreChange; pub use terrain::TerrainState; diff --git a/gamelog/src/play.rs b/gamelog/src/play.rs index f1a4eee..c159a14 100644 --- a/gamelog/src/play.rs +++ b/gamelog/src/play.rs @@ -6,11 +6,17 @@ pub trait PlayHandle { fn plays(&self) -> Vec; } +pub trait Distance { + fn distance(&self) -> u8; + + fn delta(&self, d: D); +} + #[derive(Debug, Deserialize, Clone, Default, PartialEq)] pub struct Play { pub action: Action, - pub down: Down, - pub terrain: TerrainState, + pub down: Option, + pub terrain: Option, } impl PlayHandle for Play { @@ -19,6 +25,12 @@ impl PlayHandle for Play { } } +impl Distance for Play { + fn distance(&self) -> u8 {} + + fn delta(&self, d: D) {} +} + #[derive(Debug, Deserialize, Clone, Default, PartialEq)] pub enum Down { #[default] @@ -26,7 +38,6 @@ pub enum Down { Second, Third, Fourth, - PointAfterTouchdown(Option), } #[derive(Debug, Deserialize, Clone, PartialEq)] diff --git a/gamelog/src/score.rs b/gamelog/src/score.rs deleted file mode 100644 index 51d2d69..0000000 --- a/gamelog/src/score.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::Team; -use serde::Deserialize; - -#[derive(Debug, Deserialize, Clone, PartialEq)] -pub struct ScoreChange { - pub team: Team, - pub score: u8, -} diff --git a/miller/Cargo.lock b/miller/Cargo.lock index a6f648d..8b6e181 100644 --- a/miller/Cargo.lock +++ b/miller/Cargo.lock @@ -64,7 +64,7 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "gamelog" -version = "0.3.0" +version = "0.3.1" dependencies = [ "ron", "semver",