diff options
author | Daniel Schadt <kingdread@gmx.de> | 2021-11-16 23:44:14 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2021-11-16 23:44:14 +0100 |
commit | b962896e0d31667162b0a844e3f2186707b641ad (patch) | |
tree | 80a51a0b6fcbfddfaef97b0b958769c457f4c8e9 /src/lib.rs | |
parent | 8e1e84cac23894f40fab49c03c782ad96d535111 (diff) | |
download | evtclib-b962896e0d31667162b0a844e3f2186707b641ad.tar.gz evtclib-b962896e0d31667162b0a844e3f2186707b641ad.tar.bz2 evtclib-b962896e0d31667162b0a844e3f2186707b641ad.zip |
Add GameMode and Log::game_mode
For a lot of applications, it can be useful to distinguish between logs
made in raids, fractals, ...
Note that we probably don't want further categorization (as for example
done in ezau).
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -134,6 +134,27 @@ pub enum EvtcError { Utf8Error(#[from] std::str::Utf8Error), } +/// The game mode in which a log was produced. +/// +/// Note that the distinction made here is relatively arbitrary, but hopefully still useful. In +/// Guild Wars 2 terms, there is no clear definition of what a "game mode" is. +/// +/// The game mode of a [`Log`] is obtained through [`Log::game_mode()`]. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +pub enum GameMode { + /// The log is from a raid encounter. + Raid, + /// The log is from a fractal fight. + Fractal, + /// The log is from a strike mission. + Strike, + /// The log is from a training golem. + Golem, + /// The log is from a world-versus-world fight. + WvW, +} + /// A fully processed log file. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone)] @@ -274,6 +295,33 @@ impl Log { pub fn is_generic(&self) -> bool { self.boss_id == 1 } + + /// Returns the game mode that the log was made in. + /// + /// Note that if the game mode cannot be determined or is unknown to `evtclib`, `None` is + /// returned. + pub fn game_mode(&self) -> Option<GameMode> { + // Here we assume that any generic log is a WvW log, I'm not aware of other generic logs + // being produced at the moment. + if self.is_generic() { + return Some(GameMode::WvW); + } + use Encounter::*; + match self.encounter()? { + MAMA | Siax | Ensolyss | Skorvald | Artsariiv | Arkk | Ai => Some(GameMode::Fractal), + + ValeGuardian | Gorseval | Sabetha | Slothasor | BanditTrio | Matthias + | KeepConstruct | Xera | Cairn | MursaatOverseer | Samarog | Deimos + | SoullessHorror | RiverOfSouls | BrokenKing | EaterOfSouls | StatueOfDarkness + | VoiceInTheVoid | ConjuredAmalgamate | TwinLargos | Qadim | CardinalAdina + | CardinalSabir | QadimThePeerless => Some(GameMode::Raid), + + IcebroodConstruct | Boneskinner | SuperKodanBrothers | FraenirOfJormag + | WhisperOfJormag => Some(GameMode::Strike), + + StandardKittyGolem | MediumKittyGolem | LargeKittyGolem => Some(GameMode::Golem), + } + } } /// Convenience data accessing funtions for [`Log`][Log]s. |