aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2018-04-23 15:14:35 +0200
committerDaniel Schadt <kingdread@gmx.de>2018-04-23 15:14:35 +0200
commit1a465ee75229d1268f20f2739ba29c4f84f70e7f (patch)
tree747cb3d817aa66f150824f799b3987cbea80e877 /src/main.rs
parent6e7431f0ce600502c335b75c8acfe0cf448b68e6 (diff)
downloadevtclib-1a465ee75229d1268f20f2739ba29c4f84f70e7f.tar.gz
evtclib-1a465ee75229d1268f20f2739ba29c4f84f70e7f.tar.bz2
evtclib-1a465ee75229d1268f20f2739ba29c4f84f70e7f.zip
add basic translation to more readable events
This basically implements the "event logic" as described in the README, though it produces easier-to-digest events. The test binary show 0 failed events on an example log, but of course, not all mechanics are used there, and the parsing logic may very well contain some errors.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs79
1 files changed, 77 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 03418d0..94a8abf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,13 +3,88 @@ extern crate evtclib;
use byteorder::{ReadBytesExt, BE, LE};
use std::fs::File;
-use std::io::{Seek, SeekFrom};
+use std::io::BufReader;
+use std::collections::HashMap;
+
+// My addr: 5480786193115521456
+// My instid: 624
+// Samarog: 18003064748228432752
pub fn main() -> Result<(), evtclib::raw::parser::ParseError> {
println!("Hello World!");
- let mut f = File::open("material/Samarog.evtc")?;
+ let mut f = BufReader::new(File::open("material/Samarog.evtc")?);
let result = evtclib::raw::parse_file(&mut f)?;
+/*
+ for agent in result.agents.iter().filter(|a| a.is_player()) {
+ println!("Agent: {:?}", agent);
+ }
+
+ let mut damage: HashMap<u16, u64> = HashMap::new();
+ let mut count = 0;
+ for event in result.events.iter() {
+ if event.is_statechange == evtclib::raw::CbtStateChange::None {
+ if (event.dst_agent != 0 && event.dst_instid == 0) || (event.dst_instid != 0 && event.dst_agent == 0) {
+ println!("{:#?}", event);
+ }
+ }
+ let must_take = if event.src_instid == 624 && event.skillid == 19426 && (event.value == 287 || event.buff_dmg == 287) {
+ println!("Event in question: {:#?}", event);
+ true
+ } else { false };
+ let mut taken = false;
+ if event.src_instid == 624 || event.src_master_instid == 624 {
+ //for target in result.agents.iter().filter(|a| a.is_character()) {
+ if event.iff == evtclib::raw::IFF::Foe && event.dst_agent != 0 {
+ if event.is_statechange == evtclib::raw::CbtStateChange::None && event.is_buffremove == evtclib::raw::CbtBuffRemove::None {
+ let dmg = if event.buff == 1 && event.buff_dmg != 0 {
+ event.buff_dmg
+ } else if event.buff == 0 && event.value != 0 {
+ event.value
+ } else if [5, 6, 7].contains(&(event.result as u32)) { event.value }
+ else {
+ if must_take && !taken {
+ panic!("Failing event: {:#?}", event);
+ };
+ continue;
+ };
+ println!("{} {} {}", event.src_agent, event.skillid, dmg);
+ *damage.entry(event.skillid).or_insert(0) += dmg as u64;
+ count += 1;
+ taken = true;
+ }
+ }
+ //}
+ }
+ if must_take && !taken {
+ panic!("Failing event: {:#?}", event);
+ }
+ }
+ println!("Damage: {:#?}, Total: {}, Count: {}", damage, damage.values().sum::<u64>(), count);
+ println!("Event count: {}", result.events.len());
+ println!("Events for me: {}", result.events.iter().filter(|e| e.src_instid == 624).count());
+*/
+ //let processed = evtclib::process(&result);
+ use evtclib::EventKind;
+ let mut count = 0;
+ let mut damage = 0;
+ let mut failed = 0;
+ for event in &result.events {
+ let shiny = if let Some(c) = evtclib::Event::from_raw(event) {
+ c
+ } else {
+ println!("Failed: {:#?}", event);
+ failed += 1;
+ continue
+ };
+ match &shiny.kind {
+ &EventKind::Physical { source_agent_addr: src, damage: dmg, .. } if src == 5480786193115521456 => { count += 1; damage += dmg as u64; },
+ &EventKind::ConditionTick { source_agent_addr: src, damage: dmg, .. } if src == 5480786193115521456 => { count += 1; damage += dmg as u64; },
+ _ => (),
+ }
+ }
+ println!("Count: {}, Damage: {}", count, damage);
+ println!("Failed events: {}", failed);
Ok(())
}