use evtclib::{AgentName, Log}; use super::{SearchField, LogResult, Opt}; /// Do filtering based on the character or account name. pub fn filter_name(log: &Log, opt: &Opt) -> bool { for player in log.players() { match player.name() { AgentName::Player { account_name, character_name, .. } => { if (opt.field.contains(&SearchField::Account) && opt.expression.is_match(account_name)) || (opt.field.contains(&SearchField::Character) && opt.expression.is_match(character_name)) { return true; } } _ => unreachable!(), } } false } /// Do filtering based on the fight outcome. pub fn filter_outcome(result: &LogResult, opt: &Opt) -> bool { opt.outcome.contains(&result.outcome) } /// Do filtering based on encounter time. pub fn filter_time(result: &LogResult, opt: &Opt) -> bool { let after_ok = match opt.after { Some(time) => time <= result.time, None => true, }; let before_ok = match opt.before { Some(time) => time >= result.time, None => true, }; after_ok && before_ok }