summaryrefslogtreecommitdiff
path: root/src/storage.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-02-19 13:24:25 -0600
committertom barrett <spalf0@gmail.com>2019-02-19 13:24:25 -0600
commita4efade392aa7127c373b0247d39274cb0decd10 (patch)
tree72ff44e69917873ca9933c4a56794a15b99fb90c /src/storage.rs
parent892088d723fd3dc0aae969273331c2765f322e6f (diff)
unified all server->client connection and brought logic to modules
Diffstat (limited to 'src/storage.rs')
-rw-r--r--src/storage.rs14
1 files changed, 9 insertions, 5 deletions
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<Item> {
- match self.items.iter().position(|item| item.itemtype == itemtype) {
+ pub fn take_item(&mut self, item_type: ItemType) -> Option<Item> {
+ 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<Vec<Item>> {
+ pub fn take_items(&mut self, item_type: ItemType, count: usize) -> Option<Vec<Item>> {
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;