Finish tasks to bring calculation capabilities in line with last interval. #9

Merged
Cutieguwu merged 19 commits from gamelog into main 2025-04-06 12:20:32 -04:00
8 changed files with 31 additions and 20 deletions
Showing only changes of commit f2a41be8d1 - Show all commits

2
gamelog/Cargo.lock generated
View File

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

View File

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

View File

@@ -1,4 +1,4 @@
use crate::{Play, ScoreChange, Team, TerrainState}; use crate::{Play, Team, TerrainState};
use serde::Deserialize; use serde::Deserialize;
@@ -10,5 +10,13 @@ pub enum Event {
Kickoff(Offence), Kickoff(Offence),
Turnover(Offence), Turnover(Offence),
Penalty(TerrainState), 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. /// Returns if the LogFile min version is compatible.
pub fn is_compatible(&self) -> bool { 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; type Error = ron::error::SpannedError;
fn try_from(file: File) -> Result<Self, Self::Error> { 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 game;
mod period; mod period;
mod play; mod play;
mod score;
mod terrain; mod terrain;
#[allow(unused)] #[allow(unused)]
@@ -19,5 +18,4 @@ pub use file::LogFile;
pub use game::{Game, GameRecord}; pub use game::{Game, GameRecord};
pub use period::*; pub use period::*;
pub use play::*; pub use play::*;
pub use score::ScoreChange;
pub use terrain::TerrainState; pub use terrain::TerrainState;

View File

@@ -6,11 +6,17 @@ pub trait PlayHandle {
fn plays(&self) -> Vec<Play>; 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)] #[derive(Debug, Deserialize, Clone, Default, PartialEq)]
pub struct Play { pub struct Play {
pub action: Action, pub action: Action,
pub down: Down, pub down: Option<Down>,
pub terrain: TerrainState, pub terrain: Option<TerrainState>,
} }
impl PlayHandle for Play { 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)] #[derive(Debug, Deserialize, Clone, Default, PartialEq)]
pub enum Down { pub enum Down {
#[default] #[default]
@@ -26,7 +38,6 @@ pub enum Down {
Second, Second,
Third, Third,
Fourth, Fourth,
PointAfterTouchdown(Option<u8>),
} }
#[derive(Debug, Deserialize, Clone, PartialEq)] #[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]] [[package]]
name = "gamelog" name = "gamelog"
version = "0.3.0" version = "0.3.1"
dependencies = [ dependencies = [
"ron", "ron",
"semver", "semver",