summaryrefslogtreecommitdiff
path: root/src/inventory.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.rs')
-rw-r--r--src/inventory.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/inventory.rs b/src/inventory.rs
new file mode 100644
index 0000000..0e44313
--- /dev/null
+++ b/src/inventory.rs
@@ -0,0 +1,41 @@
+use crate::dice::RiskDie;
+
+#[derive(Clone, Debug)]
+pub enum Item
+{
+ Countable(String, u8),
+ Approximate(String, RiskDie),
+}
+
+#[derive(Clone, Debug)]
+pub struct Inventory
+{
+ items: Vec<Item>,
+}
+
+impl Inventory
+{
+ pub fn new() -> Self { Self { items: Vec::new() } }
+
+ pub fn size(&self) -> usize { self.items.len() }
+
+ pub fn add_item(&mut self, item: Item) { self.items.push(item); }
+}
+
+impl Default for Inventory
+{
+ fn default() -> Self { Self::new() }
+}
+
+#[cfg(test)]
+mod tests
+{
+ use super::*;
+
+ #[test]
+ pub fn new_empty_inventory()
+ {
+ let inventory = Inventory::new();
+ assert_eq!(inventory.size(), 0);
+ }
+}