diff options
| author | troido <troido@protonmail.com> | 2020-04-05 23:22:36 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-05 23:22:36 +0200 |
| commit | ff457701ff56072914acb8a7160cd02c2a07095a (patch) | |
| tree | a9f7c9130ce274887924ee140824dc15af061b73 /src/components/inventory.rs | |
| parent | 48c24ec8b011d081550dc78329cbe61de67b30e9 (diff) | |
trading now works
Diffstat (limited to 'src/components/inventory.rs')
| -rw-r--r-- | src/components/inventory.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/components/inventory.rs b/src/components/inventory.rs index c3282e9..fa65b03 100644 --- a/src/components/inventory.rs +++ b/src/components/inventory.rs @@ -5,6 +5,7 @@ use crate::{ ItemId, item::{Item, ItemAction}, components::equipment::{Stat, Equippable}, + Encyclopedia }; #[derive(Debug, Clone)] @@ -25,6 +26,14 @@ impl Component for Inventory { impl Inventory { + pub fn add_item(&mut self, itemid: ItemId, enc: &Encyclopedia) { + self.items.insert(0, InventoryEntry{ + itemid: itemid.clone(), + item: enc.get_item(&itemid).unwrap(), + is_equipped: false + }); + } + fn equipped(&self) -> Vec<Equippable> { let mut equippables = Vec::new(); for entry in self.items.iter() { |
