From a4efade392aa7127c373b0247d39274cb0decd10 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Tue, 19 Feb 2019 13:24:25 -0600 Subject: unified all server->client connection and brought logic to modules --- src/storage.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/storage.rs') diff --git a/src/storage.rs b/src/storage.rs index b9ca287..5cbd55e 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -20,8 +20,12 @@ impl Storage { } } - pub fn take_item(&mut self, itemtype: ItemType) -> Option { - match self.items.iter().position(|item| item.itemtype == itemtype) { + pub fn take_item(&mut self, item_type: ItemType) -> Option { + match self + .items + .iter() + .position(|item| item.item_type == item_type) + { Some(index) => { let item = self.items.remove(index); self.carrying -= item.size; @@ -31,11 +35,11 @@ impl Storage { } } - pub fn take_items(&mut self, itemtype: ItemType, count: usize) -> Option> { + pub fn take_items(&mut self, item_type: ItemType, count: usize) -> Option> { if self .items .iter() - .filter(|item| item.itemtype == itemtype) + .filter(|item| item.item_type == item_type) .count() >= count { @@ -44,7 +48,7 @@ impl Storage { let index = self .items .iter() - .position(|item| item.itemtype == itemtype) + .position(|item| item.item_type == item_type) .unwrap(); let item = self.items.remove(index); self.carrying -= item.size; -- cgit v1.2.3