Merge branch 'develop' of ssh://git.mnml.gg:40022/~/mnml into develop

This commit is contained in:
ntr
2019-11-05 12:25:14 +11:00
8 changed files with 82 additions and 25 deletions
+4 -4
View File
@@ -473,10 +473,10 @@ impl Instance {
Ok(self)
}
pub fn vbox_accept(mut self, account: Uuid, group: usize, index: usize) -> Result<Instance, Error> {
pub fn vbox_accept(mut self, account: Uuid, group: usize, index: usize, construct_id: Option<Uuid>) -> Result<Instance, Error> {
self.vbox_action_allowed(account)?;
self.account_player(account)?
.vbox_accept(group, index)?;
.vbox_accept(group, index, construct_id)?;
Ok(self)
}
@@ -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)
}
}
+14 -5
View File
@@ -256,8 +256,12 @@ impl Player {
Ok(self)
}
pub fn vbox_accept(&mut self, group: usize, index: usize) -> Result<&mut Player, Error> {
self.vbox.accept(group, index)?;
pub fn vbox_accept(&mut self, group: usize, index: usize, construct_id: Option<Uuid>) -> Result<&mut Player, Error> {
self.vbox.accept(group, index, construct_id)?;
if construct_id.is_some() {
let equip_index = self.vbox.bound.len() - 1;
self.vbox_apply(equip_index, construct_id.expect("no construct"))?;
}
Ok(self)
}
@@ -320,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"));
}
@@ -354,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)
}
+10 -2
View File
@@ -112,10 +112,12 @@ pub enum RpcRequest {
InstanceChat { instance_id: Uuid, index: usize },
VboxAccept { instance_id: Uuid, group: usize, index: usize },
VboxAcceptEquip { instance_id: Uuid, group: usize, index: usize, construct_id: Uuid },
VboxDiscard { instance_id: Uuid },
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 },
}
@@ -234,7 +236,10 @@ impl Connection {
Ok(instance_abandon(&mut tx, account, instance_id)?),
RpcRequest::VboxAccept { instance_id, group, index } =>
Ok(RpcMessage::InstanceState(vbox_accept(&mut tx, account, instance_id, group, index)?)),
Ok(RpcMessage::InstanceState(vbox_accept(&mut tx, account, instance_id, group, index, None)?)),
RpcRequest::VboxAcceptEquip { instance_id, group, index, construct_id } =>
Ok(RpcMessage::InstanceState(vbox_accept(&mut tx, account, instance_id, group, index, Some(construct_id))?)),
RpcRequest::VboxApply { instance_id, construct_id, index } =>
Ok(RpcMessage::InstanceState(vbox_apply(&mut tx, account, instance_id, construct_id, index)?)),
@@ -249,7 +254,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)?)),
+7 -7
View File
@@ -99,8 +99,8 @@ impl Vbox {
self
}
pub fn accept(&mut self, i: usize, j: usize) -> Result<&mut Vbox, Error> {
if self.bound.len() >= 9 {
pub fn accept(&mut self, i: usize, j: usize, construct_id: Option<Uuid>) -> Result<&mut Vbox, Error> {
if self.bound.len() >= 9 && !construct_id.is_some() {
return Err(err_msg("too many items bound"));
}
@@ -130,7 +130,7 @@ impl Vbox {
pub fn bot_accept(&mut self, i: usize) -> Result<&mut Vbox, Error> {
let buy_index = self.free[i].iter().position(|item| item.is_some());
self.accept(i, buy_index.expect("no valid buys"))
self.accept(i, buy_index.expect("no valid buys"), None)
}
pub fn reclaim(&mut self, i: usize) -> Result<&mut Vbox, Error> {
@@ -181,9 +181,9 @@ pub fn vbox_discard(tx: &mut Transaction, account: &Account, instance_id: Uuid)
return instance_update(tx, instance);
}
pub fn vbox_accept(tx: &mut Transaction, account: &Account, instance_id: Uuid, group: usize, index: usize) -> Result<Instance, Error> {
pub fn vbox_accept(tx: &mut Transaction, account: &Account, instance_id: Uuid, group: usize, index: usize, construct_id: Option<Uuid>) -> Result<Instance, Error> {
let instance = instance_get(tx, instance_id)?
.vbox_accept(account.id, group, index)?;
.vbox_accept(account.id, group, index, construct_id)?;
return instance_update(tx, instance);
}
@@ -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);
}