vboxUnequipApply aka swap construct items
This commit is contained in:
@@ -501,10 +501,10 @@ impl Instance {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn vbox_unequip(mut self, account: Uuid, target: Item, construct_id: Uuid) -> Result<Instance, Error> {
|
||||
pub fn vbox_unequip(mut self, account: Uuid, target: Item, construct_id: Uuid, target_construct_id: Option<Uuid>) -> Result<Instance, Error> {
|
||||
self.vbox_action_allowed(account)?;
|
||||
self.account_player(account)?
|
||||
.vbox_unequip(target, construct_id)?;
|
||||
.vbox_unequip(target, construct_id, target_construct_id)?;
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,8 +324,8 @@ impl Player {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid) -> Result<&mut Player, Error> {
|
||||
if self.vbox.bound.len() >= 9 {
|
||||
pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid, target_construct_id: Option<Uuid>) -> Result<&mut Player, Error> {
|
||||
if self.vbox.bound.len() >= 9 && !target_construct_id.is_some() {
|
||||
return Err(err_msg("too many items bound"));
|
||||
}
|
||||
|
||||
@@ -358,7 +358,12 @@ impl Player {
|
||||
}
|
||||
|
||||
self.vbox.bound.push(target);
|
||||
self.vbox.bound.sort_unstable();
|
||||
|
||||
if target_construct_id.is_some() {
|
||||
let equip_index = self.vbox.bound.len() - 1;
|
||||
self.vbox_apply(equip_index, target_construct_id.expect("no construct"))?;
|
||||
}
|
||||
// self.vbox.bound.sort_unstable();
|
||||
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
+5
-1
@@ -118,6 +118,7 @@ pub enum RpcRequest {
|
||||
VboxCombine { instance_id: Uuid, indices: Vec<usize> },
|
||||
VboxApply { instance_id: Uuid, construct_id: Uuid, index: usize },
|
||||
VboxUnequip { instance_id: Uuid, construct_id: Uuid, target: Item },
|
||||
VboxUnequipApply { instance_id: Uuid, construct_id: Uuid, target: Item, target_construct_id: Uuid },
|
||||
VboxReclaim { instance_id: Uuid, index: usize },
|
||||
}
|
||||
|
||||
@@ -254,7 +255,10 @@ impl Connection {
|
||||
Ok(RpcMessage::InstanceState(vbox_reclaim(&mut tx, account, instance_id, index)?)),
|
||||
|
||||
RpcRequest::VboxUnequip { instance_id, construct_id, target } =>
|
||||
Ok(RpcMessage::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target)?)),
|
||||
Ok(RpcMessage::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target, None)?)),
|
||||
|
||||
RpcRequest::VboxUnequipApply { instance_id, construct_id, target, target_construct_id } =>
|
||||
Ok(RpcMessage::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target, Some(target_construct_id))?)),
|
||||
|
||||
RpcRequest::MtxConstructSpawn {} =>
|
||||
Ok(RpcMessage::ConstructSpawn(mtx::new_construct(&mut tx, account)?)),
|
||||
|
||||
+2
-2
@@ -205,9 +205,9 @@ pub fn vbox_apply(tx: &mut Transaction, account: &Account, instance_id: Uuid, co
|
||||
return instance_update(tx, instance);
|
||||
}
|
||||
|
||||
pub fn vbox_unequip(tx: &mut Transaction, account: &Account, instance_id: Uuid, construct_id: Uuid, target: Item) -> Result<Instance, Error> {
|
||||
pub fn vbox_unequip(tx: &mut Transaction, account: &Account, instance_id: Uuid, construct_id: Uuid, target: Item, target_construct_id: Option<Uuid>) -> Result<Instance, Error> {
|
||||
let instance = instance_get(tx, instance_id)?
|
||||
.vbox_unequip(account.id, target, construct_id)?;
|
||||
.vbox_unequip(account.id, target, construct_id, target_construct_id)?;
|
||||
return instance_update(tx, instance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user