summaryrefslogtreecommitdiff
path: root/src/mass.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mass.rs')
-rw-r--r--src/mass.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mass.rs b/src/mass.rs
index 8d9f9fc..7cc7d70 100644
--- a/src/mass.rs
+++ b/src/mass.rs
@@ -272,4 +272,40 @@ impl Mass {
}
}
}
+
+ pub fn take_item(&mut self, item_type: ItemType) -> Option<Item> {
+ match self.mass_type {
+ MassType::Ship {
+ ref mut storage, ..
+ } => storage.take_item(item_type),
+ MassType::Astroid {
+ ref mut resources, ..
+ } => resources.take_item(item_type),
+ _ => None,
+ }
+ }
+
+ pub fn give_item(&mut self, item: Item) -> bool {
+ match self.mass_type {
+ MassType::Ship {
+ ref mut storage, ..
+ } => storage.give_item(item),
+ MassType::Astroid {
+ ref mut resources, ..
+ } => resources.give_item(item),
+ _ => false,
+ }
+ }
+
+ pub fn item_count(&self, item_type: ItemType) -> usize {
+ match &self.mass_type {
+ MassType::Ship {
+ storage, ..
+ } => storage.item_count(item_type),
+ MassType::Astroid {
+ resources, ..
+ } => resources.item_count(item_type),
+ _ => 0,
+ }
+ }
}