summaryrefslogtreecommitdiff
path: root/src/inventory.rs
diff options
context:
space:
mode:
authorArne Dußin2021-04-26 10:06:58 +0200
committerArne Dußin2021-04-26 10:06:58 +0200
commit7ae33fba15b2adf9f903869b3c896a7490427b04 (patch)
treecc6605131081ee444165e92284c8ffe9fa6b9f63 /src/inventory.rs
downloadcappuccino-7ae33fba15b2adf9f903869b3c896a7490427b04.tar.gz
cappuccino-7ae33fba15b2adf9f903869b3c896a7490427b04.zip
Initial commit
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);
+ }
+}