blob: 0e443132d83400d96b50eab962e21e967d7d0250 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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);
}
}
|