From 12049c7e393799dc456bb312d14a3b98aecebd28 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 28 Apr 2020 16:36:46 +0200 Subject: add more shorthands to Agent --- src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 2080ca4..d53e5fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -442,6 +442,31 @@ impl Agent { pub fn player(&self) -> &Player { self.kind.as_player().expect("Agent had no player!") } + + /// Shorthand to get the player's account name. + pub fn account_name(&self) -> &str { + self.player().account_name() + } + + /// Shorthand to get the player's character name. + pub fn character_name(&self) -> &str { + self.player().character_name() + } + + /// Shorthand to get the player's elite specialization. + pub fn elite(&self) -> Option { + self.player().elite() + } + + /// Shorthand to get the player's profession. + pub fn profession(&self) -> Profession { + self.player().profession() + } + + /// Shorthand to get the player's subgroup. + pub fn subgroup(&self) -> u8 { + self.player().subgroup() + } } impl Agent { @@ -449,6 +474,16 @@ impl Agent { pub fn gadget(&self) -> &Gadget { self.kind.as_gadget().expect("Agent had no gadget!") } + + /// Shorthand to get the gadget's id. + pub fn id(&self) -> u16 { + self.gadget().id() + } + + /// Shorthand to get the gadget's name. + pub fn name(&self) -> &str { + self.gadget().name() + } } impl Agent { @@ -458,6 +493,16 @@ impl Agent { .as_character() .expect("Agent had no character!") } + + /// Shorthand to get the character's id. + pub fn id(&self) -> u16 { + self.character().id() + } + + /// Shorthand to get the character's name. + pub fn name(&self) -> &str { + self.character().name() + } } /// A fully processed log file. -- cgit v1.2.3