summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/componentparameter.rs2
-rw-r--r--src/components.rs2
-rw-r--r--src/componentwrapper.rs2
-rw-r--r--src/main.rs2
-rw-r--r--src/systems/take.rs2
5 files changed, 5 insertions, 5 deletions
diff --git a/src/componentparameter.rs b/src/componentparameter.rs
index a76f243..6003b0d 100644
--- a/src/componentparameter.rs
+++ b/src/componentparameter.rs
@@ -39,7 +39,7 @@ impl ComponentParameter {
}
pub fn from_json(value: &Value) -> Result<Self, &'static str> {
- let paramvalue = value.get(1).ok_or("index 0 not in component parameter")?;
+ let paramvalue = value.get(1).ok_or("index 1 not in component parameter")?;
let typename = value.get(0).ok_or("index 0 not in component parameter")?.as_str().ok_or("compparam type not a string")?;
if let Some(paramtype) = ParameterType::from_str(typename) {
Ok(Self::Constant(Parameter::from_typed_json(paramtype, paramvalue).ok_or("failed to parse parameter constant")?))
diff --git a/src/components.rs b/src/components.rs
index 8be8364..5e1c979 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -69,7 +69,7 @@ impl Player {
#[derive(Debug, Clone, Default)]
pub struct Inventory {
pub items: Vec<Item>,
- pub capacity: u64
+ pub capacity: usize
}
impl Component for Inventory {
type Storage = FlaggedStorage<Self, HashMapStorage<Self>>;
diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs
index c21d263..bcb750d 100644
--- a/src/componentwrapper.rs
+++ b/src/componentwrapper.rs
@@ -93,7 +93,7 @@ components!(
Floor () {Floor};
Player (name: String) {Player::new(name)};
Item (ent: Template) {Item{ent}};
- Inventory () {Inventory::default()}
+ Inventory (capacity: Int) {Inventory{items: Vec::new(), capacity: capacity as usize}}
);
diff --git a/src/main.rs b/src/main.rs
index 9020fe7..26ca3e0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -241,7 +241,7 @@ fn default_assemblages() -> Encyclopedia {
["Player", {
"name": ["arg", "name"]
}],
- ["Inventory", {}]
+ ["Inventory", {"capacity": ["int", 3]}]
]
}
})).unwrap()
diff --git a/src/systems/take.rs b/src/systems/take.rs
index 95bec1b..f0e3990 100644
--- a/src/systems/take.rs
+++ b/src/systems/take.rs
@@ -41,7 +41,7 @@ impl <'a> System<'a> for Take {
fn run(&mut self, (entities, controllers, positions, ground, mut removed, items, mut inventories, mut new): Self::SystemData) {
for (ent, controller, position, inventory) in (&entities, &controllers, &positions, &mut inventories).join(){
match &controller.0 {
- Control::Take(_rank) => {
+ Control::Take(_rank) if inventory.items.len() < inventory.capacity => {
let mut ents = ground.cells.get(&position.pos).unwrap_or(&HashSet::new()).clone();
ents.remove(&ent);
for ent in ents {