mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-04 02:34:10 +02:00
remove some more nom
This commit is contained in:
parent
d326e1bb6a
commit
311345cf4e
15 changed files with 103 additions and 91 deletions
|
|
@ -25,7 +25,7 @@ pub struct ChatMessage {
|
|||
impl ChatMessage {
|
||||
fn from_bare(bare: BareChatMessage, subjects: &SubjectMap) -> Self {
|
||||
let (name, steam_id) = match &subjects[bare.subject] {
|
||||
(SubjectData::Player { name, steam_id, .. }, _) => (name.clone(), steam_id.clone()),
|
||||
(SubjectData::Player { name, steam_id, .. }, _) => (name.clone(), *steam_id),
|
||||
_ => {
|
||||
unreachable!("only player messages are added");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ impl EventHandler for ClassStatsHandler {
|
|||
}
|
||||
|
||||
fn finish_global(self, _subjects: &SubjectMap) -> Self::GlobalOutput {
|
||||
()
|
||||
|
||||
}
|
||||
|
||||
fn finish_per_subject(
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ impl FromStr for LobbyLeader {
|
|||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
if let Some((name, steam_id)) = s.rsplit_once(" (") {
|
||||
if let Ok(steam_id) = steam_id.trim_end_matches(")").parse::<u64>() {
|
||||
if let Ok(steam_id) = steam_id.trim_end_matches(')').parse::<u64>() {
|
||||
Ok(LobbyLeader {
|
||||
name: name.into(),
|
||||
steam_id: steam_id.into(),
|
||||
|
|
@ -90,8 +90,14 @@ pub struct Settings {
|
|||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self::with_id(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn with_id(id: u32) -> Self {
|
||||
Settings {
|
||||
id: 0,
|
||||
id,
|
||||
leader: LobbyLeader::default(),
|
||||
map: "".to_string(),
|
||||
game_type: GameType::Sixes,
|
||||
|
|
@ -157,8 +163,7 @@ impl LobbySettingsHandler {
|
|||
.strip_prefix("TF2Center Lobby #")
|
||||
.and_then(|s| str::split_once(s, " |"))
|
||||
{
|
||||
let mut settings = Settings::default();
|
||||
settings.id = id.parse()?;
|
||||
let settings = Settings::with_id(id.parse()?);
|
||||
*self = LobbySettingsHandler::Active(settings);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ impl PlayerSpecificData for MedicStatsBuilder {
|
|||
}
|
||||
GameEvent::MedicDeath(death) => {
|
||||
let charge = death.charge.unwrap_or_default();
|
||||
if charge >= 95 && charge < 100 {
|
||||
if (95..100).contains(&charge) {
|
||||
self.near_full_charge_death += 1;
|
||||
} else if charge >= 100 {
|
||||
self.drops += 1;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ pub use healspread::HealSpread;
|
|||
pub use lobbysettings::{
|
||||
LobbySettingsError, LobbySettingsHandler, Location, Settings as LobbySettings,
|
||||
};
|
||||
pub use medicstats::MedicStats;
|
||||
pub use medicstats::{MedicStats, MedicStatsBuilder};
|
||||
use serde::Serialize;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
|
@ -108,11 +108,11 @@ macro_rules! handler {
|
|||
paste::paste! {
|
||||
#[derive(Default)]
|
||||
pub struct $name {
|
||||
$($child: $ty),*
|
||||
pub $($child: $ty),*
|
||||
}
|
||||
|
||||
pub struct [<$name GlobalOutput>] {
|
||||
$($child: <$ty as $crate::EventHandler>::GlobalOutput),*
|
||||
pub $($child: <$ty as $crate::EventHandler>::GlobalOutput),*
|
||||
}
|
||||
|
||||
impl serde::Serialize for [<$name GlobalOutput>] {
|
||||
|
|
@ -144,7 +144,7 @@ macro_rules! handler {
|
|||
}
|
||||
|
||||
pub struct [<$name PerSubjectOutput>] {
|
||||
$($child: <$ty as $crate::EventHandler>::PerSubjectOutput),*
|
||||
pub $($child: <$ty as $crate::EventHandler>::PerSubjectOutput),*
|
||||
}
|
||||
|
||||
impl serde::Serialize for [<$name PerSubjectOutput>] {
|
||||
|
|
@ -235,7 +235,7 @@ impl<T: GlobalData> EventHandler for T {
|
|||
_subject: &SubjectData,
|
||||
_data: Self::PerSubjectData,
|
||||
) -> Self::PerSubjectOutput {
|
||||
()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ impl<T: PlayerSpecificData + Default> EventHandler for PlayerHandler<T> {
|
|||
}
|
||||
|
||||
fn finish_global(self, _subjects: &SubjectMap) -> Self::GlobalOutput {
|
||||
()
|
||||
|
||||
}
|
||||
|
||||
fn finish_per_subject(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue