Update main to gamelog v0.7.1 and early tui model from dev. #15
10
README.adoc
10
README.adoc
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
== Prelude
|
== Prelude
|
||||||
|
|
||||||
VERY EARLY ALPHA -- NOT YET FUNCTIONAL
|
|
||||||
|
|
||||||
For my stats course (4U Data Management) I have to interpret a bunch of data generated in class.
|
For my stats course (4U Data Management) I have to interpret a bunch of data generated in class.
|
||||||
In an effort to not spend ages mindlessly using a calculator every summative check-in, I have started this project.
|
In an effort to not spend ages mindlessly using a calculator every summative check-in, I have started this project.
|
||||||
|
|
||||||
@@ -14,6 +12,14 @@ I figured, that since I already had to digitize every note, that I was required
|
|||||||
|
|
||||||
== Goals
|
== Goals
|
||||||
|
|
||||||
|
* [ ] Data Visualizer?
|
||||||
|
* [ ] Dynamic Web Page?
|
||||||
|
** Server Side Events?
|
||||||
|
** IDK frontend web at all.
|
||||||
|
** plotly.rs?
|
||||||
|
** charming.rs?
|
||||||
|
** WASM?
|
||||||
|
|
||||||
=== Gamelog
|
=== Gamelog
|
||||||
* [*] Data Format
|
* [*] Data Format
|
||||||
** [*] Support recording multiple games
|
** [*] Support recording multiple games
|
||||||
|
|||||||
12
gamelog.ron
12
gamelog.ron
@@ -5,7 +5,7 @@
|
|||||||
[
|
[
|
||||||
Game(
|
Game(
|
||||||
version: "0.5.0",
|
version: "0.5.0",
|
||||||
flags: [IgnoreScore],
|
flags: [Interval(2), IgnoreScore],
|
||||||
periods: [
|
periods: [
|
||||||
Period(
|
Period(
|
||||||
start: First,
|
start: First,
|
||||||
@@ -190,7 +190,7 @@
|
|||||||
),
|
),
|
||||||
Game(
|
Game(
|
||||||
version: "0.5.0",
|
version: "0.5.0",
|
||||||
flags: [IgnoreScore],
|
flags: [Interval(2), IgnoreScore],
|
||||||
periods: [
|
periods: [
|
||||||
Period(
|
Period(
|
||||||
start: First,
|
start: First,
|
||||||
@@ -344,7 +344,7 @@
|
|||||||
),
|
),
|
||||||
Game(
|
Game(
|
||||||
version: "0.5.0",
|
version: "0.5.0",
|
||||||
flags: [],
|
flags: [Interval(2)],
|
||||||
periods: [
|
periods: [
|
||||||
Period(
|
Period(
|
||||||
start: First,
|
start: First,
|
||||||
@@ -557,7 +557,7 @@
|
|||||||
),
|
),
|
||||||
Game(
|
Game(
|
||||||
version: "0.5.0",
|
version: "0.5.0",
|
||||||
flags: [],
|
flags: [Interval(2)],
|
||||||
periods: [
|
periods: [
|
||||||
Period(
|
Period(
|
||||||
start: First,
|
start: First,
|
||||||
@@ -767,7 +767,7 @@
|
|||||||
),
|
),
|
||||||
Game(
|
Game(
|
||||||
version: "0.5.0",
|
version: "0.5.0",
|
||||||
flags: [],
|
flags: [Interval(2)],
|
||||||
periods: [
|
periods: [
|
||||||
Period(
|
Period(
|
||||||
start: First,
|
start: First,
|
||||||
@@ -994,7 +994,7 @@
|
|||||||
// TexasAnM were opponents, but not recorded as
|
// TexasAnM were opponents, but not recorded as
|
||||||
// they were not present; Miller played in place.
|
// they were not present; Miller played in place.
|
||||||
version: "0.5.0",
|
version: "0.5.0",
|
||||||
flags: [IgnoreTeam(TexasAnM)],
|
flags: [Interval(2), IgnoreTeam(TexasAnM)],
|
||||||
periods: [
|
periods: [
|
||||||
Period(
|
Period(
|
||||||
start: First,
|
start: First,
|
||||||
|
|||||||
2
gamelog/Cargo.lock
generated
2
gamelog/Cargo.lock
generated
@@ -19,7 +19,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gamelog"
|
name = "gamelog"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ron",
|
"ron",
|
||||||
"semver",
|
"semver",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gamelog"
|
name = "gamelog"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -168,8 +168,10 @@ impl Game {
|
|||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, PartialEq)]
|
#[derive(Debug, Deserialize, Clone, PartialEq)]
|
||||||
pub enum Flags {
|
pub enum Flags {
|
||||||
|
IgnoreActions,
|
||||||
IgnoreTeam(Team),
|
IgnoreTeam(Team),
|
||||||
IgnoreScore,
|
IgnoreScore,
|
||||||
|
Interval(u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ impl Period {
|
|||||||
let mut record: bool = true;
|
let mut record: bool = true;
|
||||||
let assume_team_known = assume_team_known.unwrap_or(false);
|
let assume_team_known = assume_team_known.unwrap_or(false);
|
||||||
|
|
||||||
for event in self.events.iter() {
|
self.events.iter().for_each(|event| {
|
||||||
if let Event::Kickoff(_) | Event::Turnover(_) = event {
|
if let Event::Kickoff(_) | Event::Turnover(_) = event {
|
||||||
record = {
|
record = {
|
||||||
if team == event.team().unwrap() {
|
if team == event.team().unwrap() {
|
||||||
@@ -42,7 +42,7 @@ impl Period {
|
|||||||
if record {
|
if record {
|
||||||
events.push(event.to_owned());
|
events.push(event.to_owned());
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// If already handled or assumption override applicable
|
// If already handled or assumption override applicable
|
||||||
if !first || (first && assume_team_known) {
|
if !first || (first && assume_team_known) {
|
||||||
@@ -115,11 +115,7 @@ impl Period {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_overtime(&self) -> bool {
|
pub fn is_overtime(&self) -> bool {
|
||||||
if self.start.is_overtime() || self.end.as_ref().is_some_and(|some| some.is_overtime()) {
|
self.start.is_overtime() || self.end.as_ref().is_some_and(|some| some.is_overtime())
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
miller/Cargo.lock
generated
2
miller/Cargo.lock
generated
@@ -64,7 +64,7 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gamelog"
|
name = "gamelog"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ron",
|
"ron",
|
||||||
"semver",
|
"semver",
|
||||||
|
|||||||
@@ -48,50 +48,49 @@ fn main() {
|
|||||||
|
|
||||||
// Work on knocking down the nesting here?
|
// Work on knocking down the nesting here?
|
||||||
for game in log.0.iter() {
|
for game in log.0.iter() {
|
||||||
if let Ok(teams) = game.teams() {
|
let teams = match game.teams() {
|
||||||
for team in teams {
|
Ok(teams) => teams,
|
||||||
if !game.flags.contains(&Flags::IgnoreTeam(team.to_owned())) {
|
Err(_) => continue,
|
||||||
// Team is to have their stats recorded this game of file.
|
};
|
||||||
let team_idx = stats
|
|
||||||
.iter()
|
|
||||||
.position(|stat| {
|
|
||||||
if stat.team == team.to_owned() {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
stats[team_idx]
|
for team in teams {
|
||||||
.avg_terrain_gain
|
// Skip team if they are to be ignored this game.
|
||||||
.push(game.avg_gain(team.to_owned()));
|
if game.flags.contains(&Flags::IgnoreTeam(team.to_owned())) {
|
||||||
|
continue;
|
||||||
stats[team_idx]
|
|
||||||
.avg_terrain_loss
|
|
||||||
.push(game.avg_loss(team.to_owned()));
|
|
||||||
|
|
||||||
stats[team_idx]
|
|
||||||
.avg_terrain_delta
|
|
||||||
.push(game.avg_delta(team.to_owned()));
|
|
||||||
|
|
||||||
stats[team_idx]
|
|
||||||
.plays_per_quarter
|
|
||||||
.push(game.avg_plays_per_quarter(team.to_owned()));
|
|
||||||
|
|
||||||
stats[team_idx]
|
|
||||||
.plays_per_game
|
|
||||||
.push(game.team_plays(team.to_owned()));
|
|
||||||
|
|
||||||
stats[team_idx]
|
|
||||||
.penalties_per_game
|
|
||||||
.push(game.penalties(team.to_owned()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let team_idx = stats
|
||||||
|
.iter()
|
||||||
|
.position(|stat| stat.team == team.to_owned())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.avg_terrain_gain
|
||||||
|
.push(game.avg_gain(team.to_owned()));
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.avg_terrain_loss
|
||||||
|
.push(game.avg_loss(team.to_owned()));
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.avg_terrain_delta
|
||||||
|
.push(game.avg_delta(team.to_owned()));
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.plays_per_quarter
|
||||||
|
.push(game.avg_plays_per_quarter(team.to_owned()));
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.plays_per_game
|
||||||
|
.push(game.team_plays(team.to_owned()));
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.penalties_per_game
|
||||||
|
.push(game.penalties(team.to_owned()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dbg!(config.display_results) {
|
if config.display_results {
|
||||||
// :#? for pretty-printing.
|
// :#? for pretty-printing.
|
||||||
stats.iter().for_each(|team| println!("{:#?}", team));
|
stats.iter().for_each(|team| println!("{:#?}", team));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user