Fix PAT notation and Touchdown notations. Backwards compatible w/ v3.0.0 if

`implicit_some` enabled in RON log and no PAT specified within.
This commit is contained in:
Cutieguwu
2025-03-31 18:39:05 -04:00
parent 46c806e537
commit f2a41be8d1
8 changed files with 31 additions and 20 deletions

2
gamelog/Cargo.lock generated
View File

@@ -19,7 +19,7 @@ dependencies = [
[[package]]
name = "gamelog"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"ron",
"semver",

View File

@@ -1,6 +1,6 @@
[package]
name = "gamelog"
version = "0.3.0"
version = "0.3.1"
edition = "2024"
[dependencies]

View File

@@ -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,
}

View File

@@ -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<File> for LogFile {
type Error = ron::error::SpannedError;
fn try_from(file: File) -> Result<Self, Self::Error> {
ron::de::from_reader(file)
ron::Options::default()
.with_default_extension(ron::extensions::Extensions::EXPLICIT_STRUCT_NAMES)
.from_reader(file)
}
}

View File

@@ -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;

View File

@@ -6,11 +6,17 @@ pub trait PlayHandle {
fn plays(&self) -> Vec<Play>;
}
pub trait Distance {
fn distance(&self) -> u8;
fn delta<D: Distance>(&self, d: D);
}
#[derive(Debug, Deserialize, Clone, Default, PartialEq)]
pub struct Play {
pub action: Action,
pub down: Down,
pub terrain: TerrainState,
pub down: Option<Down>,
pub terrain: Option<TerrainState>,
}
impl PlayHandle for Play {
@@ -19,6 +25,12 @@ impl PlayHandle for Play {
}
}
impl Distance for Play {
fn distance(&self) -> u8 {}
fn delta<D: Distance>(&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<u8>),
}
#[derive(Debug, Deserialize, Clone, PartialEq)]

View File

@@ -1,8 +0,0 @@
use crate::Team;
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone, PartialEq)]
pub struct ScoreChange {
pub team: Team,
pub score: u8,
}

2
miller/Cargo.lock generated
View File

@@ -64,7 +64,7 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "gamelog"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"ron",
"semver",