|
@ -4,7 +4,7 @@ use libpso::character::character::InventoryItem; |
|
|
|
|
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
use crate::entity::character::CharacterEntity;
|
|
|
use crate::entity::character::CharacterEntity;
|
|
|
use crate::entity::item::{Item, ItemId, ItemDetail, ItemLocation};
|
|
|
|
|
|
|
|
|
use crate::entity::item::{ItemEntity, ItemId, ItemDetail, ItemLocation};
|
|
|
use crate::entity::item::weapon::Weapon;
|
|
|
use crate::entity::item::weapon::Weapon;
|
|
|
use crate::entity::item::armor::Armor;
|
|
|
use crate::entity::item::armor::Armor;
|
|
|
use crate::entity::item::shield::Shield;
|
|
|
use crate::entity::item::shield::Shield;
|
|
@ -15,8 +15,8 @@ use crate::entity::item::mag::Mag; |
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
pub enum StackedItem {
|
|
|
pub enum StackedItem {
|
|
|
Individual(Item),
|
|
|
|
|
|
Stacked(Vec<Item>),
|
|
|
|
|
|
|
|
|
Individual(ItemEntity),
|
|
|
|
|
|
Stacked(Vec<ItemEntity>),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
@ -68,12 +68,12 @@ impl ActiveInventory { |
|
|
|
|
|
|
|
|
// does this do anything?
|
|
|
// does this do anything?
|
|
|
inventory[index].equipped = match item.item {
|
|
|
inventory[index].equipped = match item.item {
|
|
|
StackedItem::Individual(Item {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 1,
|
|
|
|
|
|
|
|
|
StackedItem::Individual(ItemEntity {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 1,
|
|
|
_ => 0,
|
|
|
_ => 0,
|
|
|
};
|
|
|
};
|
|
|
// because this actually equips the item
|
|
|
// because this actually equips the item
|
|
|
inventory[index].flags |= match item.item {
|
|
|
inventory[index].flags |= match item.item {
|
|
|
StackedItem::Individual(Item {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 8,
|
|
|
|
|
|
|
|
|
StackedItem::Individual(ItemEntity {location: ItemLocation::Inventory{ equipped: true, ..}, ..}) => 8,
|
|
|
_ => 0,
|
|
|
_ => 0,
|
|
|
};
|
|
|
};
|
|
|
inventory
|
|
|
inventory
|
|
@ -102,7 +102,7 @@ fn inventory_item_index(item: &StackedItem) -> usize { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn stack_items(items: Vec<Item>) -> Vec<StackedItem> {
|
|
|
|
|
|
|
|
|
fn stack_items(items: Vec<ItemEntity>) -> Vec<StackedItem> {
|
|
|
let mut stacks = HashMap::new();
|
|
|
let mut stacks = HashMap::new();
|
|
|
|
|
|
|
|
|
for item in items {
|
|
|
for item in items {
|
|
@ -174,10 +174,10 @@ mod test { |
|
|
use super::*;
|
|
|
use super::*;
|
|
|
use crate::entity::character::CharacterEntityId;
|
|
|
use crate::entity::character::CharacterEntityId;
|
|
|
use crate::entity::item;
|
|
|
use crate::entity::item;
|
|
|
use crate::entity::item::{Item, ItemDetail, ItemEntityId, ItemLocation};
|
|
|
|
|
|
|
|
|
use crate::entity::item::{ItemEntity, ItemDetail, ItemEntityId, ItemLocation};
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_stack_items() {
|
|
|
fn test_stack_items() {
|
|
|
let item1 = Item {
|
|
|
|
|
|
|
|
|
let item1 = ItemEntity {
|
|
|
id: ItemEntityId(1),
|
|
|
id: ItemEntityId(1),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -192,7 +192,7 @@ mod test { |
|
|
tekked: true,
|
|
|
tekked: true,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item2 = Item {
|
|
|
|
|
|
|
|
|
let item2 = ItemEntity {
|
|
|
id: ItemEntityId(2),
|
|
|
id: ItemEntityId(2),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -203,7 +203,7 @@ mod test { |
|
|
tool: item::tool::ToolType::Monofluid,
|
|
|
tool: item::tool::ToolType::Monofluid,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item3 = Item {
|
|
|
|
|
|
|
|
|
let item3 = ItemEntity {
|
|
|
id: ItemEntityId(3),
|
|
|
id: ItemEntityId(3),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -218,7 +218,7 @@ mod test { |
|
|
tekked: true,
|
|
|
tekked: true,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item4 = Item {
|
|
|
|
|
|
|
|
|
let item4 = ItemEntity {
|
|
|
id: ItemEntityId(4),
|
|
|
id: ItemEntityId(4),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -229,7 +229,7 @@ mod test { |
|
|
tool: item::tool::ToolType::Monofluid,
|
|
|
tool: item::tool::ToolType::Monofluid,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item5 = Item {
|
|
|
|
|
|
|
|
|
let item5 = ItemEntity {
|
|
|
id: ItemEntityId(5),
|
|
|
id: ItemEntityId(5),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -240,7 +240,7 @@ mod test { |
|
|
tool: item::tool::ToolType::Monofluid,
|
|
|
tool: item::tool::ToolType::Monofluid,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item6 = Item {
|
|
|
|
|
|
|
|
|
let item6 = ItemEntity {
|
|
|
id: ItemEntityId(6),
|
|
|
id: ItemEntityId(6),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -255,7 +255,7 @@ mod test { |
|
|
tekked: true,
|
|
|
tekked: true,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item7 = Item {
|
|
|
|
|
|
|
|
|
let item7 = ItemEntity {
|
|
|
id: ItemEntityId(7),
|
|
|
id: ItemEntityId(7),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -266,7 +266,7 @@ mod test { |
|
|
tool: item::tool::ToolType::Monomate,
|
|
|
tool: item::tool::ToolType::Monomate,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item8 = Item {
|
|
|
|
|
|
|
|
|
let item8 = ItemEntity {
|
|
|
id: ItemEntityId(8),
|
|
|
id: ItemEntityId(8),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
@ -277,7 +277,7 @@ mod test { |
|
|
tool: item::tool::ToolType::Monomate,
|
|
|
tool: item::tool::ToolType::Monomate,
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
};
|
|
|
let item9 = Item {
|
|
|
|
|
|
|
|
|
let item9 = ItemEntity {
|
|
|
id: ItemEntityId(9),
|
|
|
id: ItemEntityId(9),
|
|
|
location: ItemLocation::Inventory {
|
|
|
location: ItemLocation::Inventory {
|
|
|
character_id: CharacterEntityId(0),
|
|
|
character_id: CharacterEntityId(0),
|
|
|