From 13e9ab2c859b9a6a1935acbb93d34a7f10b7e122 Mon Sep 17 00:00:00 2001 From: troido Date: Fri, 17 Apr 2020 11:15:02 +0200 Subject: added Mine interaction --- src/components/equipment.rs | 4 +++- src/components/interactable.rs | 9 ++++++--- src/components/mod.rs | 7 +++++++ 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/components') diff --git a/src/components/equipment.rs b/src/components/equipment.rs index 386ef38..ab573d8 100644 --- a/src/components/equipment.rs +++ b/src/components/equipment.rs @@ -27,7 +27,8 @@ impl Slot { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Stat { Strength, - Defence + Defence, + Mining } impl Stat { @@ -35,6 +36,7 @@ impl Stat { match txt { "strength" => Some(Self::Strength), "defence" => Some(Self::Defence), + "mining" => Some(Self::Mining), _ => None } } diff --git a/src/components/interactable.rs b/src/components/interactable.rs index f1f0508..f48fb9d 100644 --- a/src/components/interactable.rs +++ b/src/components/interactable.rs @@ -8,7 +8,7 @@ use specs::{ use crate::{ exchange::Exchange, ItemId, - components::Trigger, + components::{Trigger, equipment::Stat}, RoomId }; @@ -19,7 +19,8 @@ pub enum Interactable { Say(String), Reply(String), Exchange(String, HashMap), - Visit(RoomId) + Visit(RoomId), + Mine(Stat) } use Interactable::*; @@ -47,6 +48,7 @@ impl Interactable { .collect::>>()? ), "visit" => Visit(RoomId::from_str(arg.as_str()?)), + "mine" => Mine(Stat::from_str(arg.as_str()?)?), _ => None? }) } @@ -62,7 +64,7 @@ impl Interactable { } else { true } - } + }, Visit(_) => { if let Some(txt) = arg { txt.starts_with("visit ") || txt.starts_with("disallow ") || txt.starts_with("allow ") || txt.starts_with("whitelist") @@ -70,6 +72,7 @@ impl Interactable { false } } + Mine(_) => arg.is_none() } } } diff --git a/src/components/mod.rs b/src/components/mod.rs index 64fa717..8ffe30d 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -240,3 +240,10 @@ pub struct Dedup { pub priority: i64 } + +#[derive(Component, Debug, Clone)] +pub struct Minable { + pub progress: i64, + pub total: i64, + pub trigger: Trigger +} -- cgit