|
|
@ -19,6 +19,9 @@ pub struct InMemoryGateway { |
|
|
|
equips: Arc<Mutex<BTreeMap<CharacterEntityId, EquippedEntity>>>,
|
|
|
|
mag_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<mag::MagModifier>>>>,
|
|
|
|
weapon_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<weapon::WeaponModifier>>>>,
|
|
|
|
armor_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<armor::ArmorModifier>>>>,
|
|
|
|
shield_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<shield::ShieldModifier>>>>,
|
|
|
|
unit_modifiers: Arc<Mutex<BTreeMap<ItemEntityId, Vec<unit::UnitModifier>>>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl InMemoryGateway {
|
|
|
@ -33,6 +36,9 @@ impl InMemoryGateway { |
|
|
|
equips: Arc::new(Mutex::new(BTreeMap::new())),
|
|
|
|
mag_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
|
|
|
weapon_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
|
|
|
armor_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
|
|
|
shield_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
|
|
|
unit_modifiers: Arc::new(Mutex::new(BTreeMap::new())),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -273,6 +279,30 @@ impl EntityGateway for InMemoryGateway { |
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn add_armor_modifier(&mut self, item_id: &ItemEntityId, modifier: armor::ArmorModifier) -> Result<(), GatewayError> {
|
|
|
|
self.armor_modifiers.lock().unwrap()
|
|
|
|
.entry(*item_id)
|
|
|
|
.or_insert(Vec::new())
|
|
|
|
.push(modifier);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn add_shield_modifier(&mut self, item_id: &ItemEntityId, modifier: shield::ShieldModifier) -> Result<(), GatewayError> {
|
|
|
|
self.shield_modifiers.lock().unwrap()
|
|
|
|
.entry(*item_id)
|
|
|
|
.or_insert(Vec::new())
|
|
|
|
.push(modifier);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn add_unit_modifier(&mut self, item_id: &ItemEntityId, modifier: unit::UnitModifier) -> Result<(), GatewayError> {
|
|
|
|
self.unit_modifiers.lock().unwrap()
|
|
|
|
.entry(*item_id)
|
|
|
|
.or_insert(Vec::new())
|
|
|
|
.push(modifier);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn get_character_inventory(&mut self, char_id: &CharacterEntityId) -> Result<InventoryEntity, GatewayError> {
|
|
|
|
println!("getting inv");
|
|
|
|
let inventories = self.inventories.lock().unwrap();
|
|
|
|