aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs19
-rw-r--r--src/output.rs11
2 files changed, 27 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 29f482f..567991d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -75,6 +75,7 @@ pub struct LogResult {
time: NaiveDateTime,
boss_name: String,
players: Vec<Player>,
+ outcome: FightOutcome,
}
#[derive(Debug, Clone)]
@@ -85,6 +86,12 @@ pub struct Player {
subgroup: u8,
}
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum FightOutcome {
+ Success,
+ Wipe,
+}
+
fn main() {
let opt = Opt::from_args();
let result = grep(&opt);
@@ -195,6 +202,7 @@ fn extract_info(entry: &DirEntry, log: &Log) -> LogResult {
time: NaiveDateTime::from_timestamp(get_start_timestamp(log) as i64, 0),
boss_name,
players,
+ outcome: get_fight_outcome(log),
}
}
@@ -210,6 +218,17 @@ fn get_start_timestamp(log: &Log) -> u32 {
0
}
+fn get_fight_outcome(log: &Log) -> FightOutcome {
+ for event in log.events() {
+ if let EventKind::ChangeDead { agent_addr } = event.kind {
+ if log.is_boss(agent_addr) {
+ return FightOutcome::Success;
+ }
+ }
+ }
+ FightOutcome::Wipe
+}
+
fn get_profession_name(profession: u32, elite: u32) -> &'static str {
match (profession, elite) {
(1, 0) => "Guardian",
diff --git a/src/output.rs b/src/output.rs
index 848eab5..9458e48 100644
--- a/src/output.rs
+++ b/src/output.rs
@@ -1,4 +1,4 @@
-use super::LogResult;
+use super::{LogResult, FightOutcome};
use super::errors::RuntimeError;
use std::io::Write;
@@ -7,13 +7,18 @@ use std::io::Write;
pub fn colored<W: Write>(mut f: W, item: &LogResult) -> Result<(), RuntimeError> {
use colored::Colorize;
writeln!(f, "{}: {:?}", "File".green(), item.log_file)?;
+ let outcome = match item.outcome {
+ FightOutcome::Success => "SUCCESS".green(),
+ FightOutcome::Wipe => "WIPE".red(),
+ };
writeln!(
f,
- "{}: {} - {}: {}",
+ "{}: {} - {}: {} {}",
"Date".green(),
item.time,
"Boss".green(),
- item.boss_name
+ item.boss_name,
+ outcome,
)?;
for player in &item.players {
writeln!(