mirror of
https://codeberg.org/icewind/log-normalizer.git
synced 2026-11-30 02:20:47 +01:00
normalized database
This commit is contained in:
parent
05be5b1e0a
commit
d6c622fcda
8 changed files with 677 additions and 591 deletions
|
|
@ -1,8 +1,10 @@
|
|||
pub use crate::data::TeamId;
|
||||
use crate::data::{GameMode, MapType};
|
||||
use crate::raw::RawLog;
|
||||
pub use crate::raw::{
|
||||
ChatMessage, ClassNumbers, Event, Player, RoundPlayer, Team, Teams, Uploader,
|
||||
};
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
use steamid_ng::SteamID;
|
||||
|
|
@ -24,6 +26,22 @@ pub struct NormalizedLog {
|
|||
pub info: Info,
|
||||
}
|
||||
|
||||
impl NormalizedLog {
|
||||
pub fn game_mode(&self) -> GameMode {
|
||||
if self.info.map_type() == MapType::UltiDuo {
|
||||
return GameMode::UltiDuo;
|
||||
}
|
||||
|
||||
match self.players.len() {
|
||||
7..=9 => GameMode::Fours,
|
||||
11..=13 => GameMode::Sixes,
|
||||
14 => GameMode::Sevens,
|
||||
17..=19 => GameMode::Highlander,
|
||||
_ => GameMode::Other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Info {
|
||||
pub map: String,
|
||||
|
|
@ -49,6 +67,30 @@ pub struct Info {
|
|||
pub uploader: Uploader,
|
||||
}
|
||||
|
||||
impl Info {
|
||||
pub fn map_type(&self) -> MapType {
|
||||
if map_is_stopwatch(&self.map) {
|
||||
MapType::Stopwatch
|
||||
} else if self.map.starts_with("cp") {
|
||||
MapType::Cp
|
||||
} else if self.map.starts_with("koth") {
|
||||
MapType::KOTH
|
||||
} else if self.map.starts_with("ctf") {
|
||||
MapType::CTF
|
||||
} else if self.map.starts_with("ultiduo") {
|
||||
MapType::UltiDuo
|
||||
} else if self.map.starts_with("bball") {
|
||||
MapType::BBall
|
||||
} else {
|
||||
MapType::Other
|
||||
}
|
||||
}
|
||||
|
||||
pub fn date(&self) -> DateTime<Utc> {
|
||||
DateTime::from_utc(NaiveDateTime::from_timestamp(self.date as i64, 0), Utc)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Round {
|
||||
pub start_time: u64,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue