equip items from vbox
This commit is contained in:
parent
d4169e86c3
commit
c4e42457be
@ -36,7 +36,6 @@
|
||||
- Strike + SpeedRR -> StrikeSpeed (strike has Y% more speed)
|
||||
- Strike + LifeRR -> StrikeLife (Strike recharges X% of damage as red life)
|
||||
|
||||
* equip from shop (buy and equip without putting in your inventory) for bases
|
||||
* move item from one construct to another
|
||||
|
||||
* ACP
|
||||
@ -89,7 +88,6 @@ $$$
|
||||
* Highlight (dota) colour
|
||||
* fx colours + styles
|
||||
|
||||
* ??? (PROBS NOT) drag and drop buy / equip / unequip items ???
|
||||
* modules
|
||||
* troll life -> dmg
|
||||
* prince of peace
|
||||
|
||||
@ -20,9 +20,14 @@ const addState = connect(
|
||||
itemInfo,
|
||||
itemEquip,
|
||||
navInstance,
|
||||
vboxSelected,
|
||||
tutorial,
|
||||
} = state;
|
||||
|
||||
function sendVboxAcceptEquip(constructId) {
|
||||
return ws.sendVboxAcceptEquip(instance.id, vboxSelected[0], vboxSelected[1], constructId);
|
||||
}
|
||||
|
||||
function sendVboxApply(constructId, i) {
|
||||
return ws.sendVboxApply(instance.id, constructId, i);
|
||||
}
|
||||
@ -35,11 +40,13 @@ const addState = connect(
|
||||
instance,
|
||||
player,
|
||||
account,
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxApply,
|
||||
itemInfo,
|
||||
itemEquip,
|
||||
navInstance,
|
||||
sendUnequip,
|
||||
vboxSelected,
|
||||
tutorial,
|
||||
};
|
||||
},
|
||||
@ -79,11 +86,13 @@ function Construct(props) {
|
||||
instance,
|
||||
mobileVisible,
|
||||
player,
|
||||
vboxSelected,
|
||||
tutorial,
|
||||
// Static Info
|
||||
itemInfo,
|
||||
// Function Calls
|
||||
sendVboxApply,
|
||||
sendVboxAcceptEquip,
|
||||
sendUnequip,
|
||||
setActiveConstruct,
|
||||
setItemUnequip,
|
||||
@ -104,6 +113,7 @@ function Construct(props) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (duplicateSkill || tutorialDisableEquip) return true;
|
||||
if (vboxSelected[0]) sendVboxAcceptEquip(construct.id);
|
||||
if (itemEquip !== null) sendVboxApply(construct.id, itemEquip);
|
||||
setItemEquip(null);
|
||||
return setActiveConstruct(construct);
|
||||
@ -254,6 +264,7 @@ class InstanceConstructs extends preact.Component {
|
||||
// JSON or Array objects
|
||||
if (newProps.player !== this.props.player) return true;
|
||||
if (newProps.instance !== this.props.instance) return true;
|
||||
if (newProps.vboxSelected !== this.props.vboxSelected) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -265,12 +276,14 @@ class InstanceConstructs extends preact.Component {
|
||||
navInstance,
|
||||
player,
|
||||
tutorial,
|
||||
vboxSelected,
|
||||
// Static data
|
||||
itemInfo,
|
||||
// Function calls
|
||||
setInfo,
|
||||
setActiveConstruct,
|
||||
sendVboxApply,
|
||||
sendVboxAcceptEquip,
|
||||
setVboxHighlight,
|
||||
setItemUnequip,
|
||||
setItemEquip,
|
||||
@ -293,11 +306,13 @@ class InstanceConstructs extends preact.Component {
|
||||
setItemEquip,
|
||||
player,
|
||||
sendVboxApply,
|
||||
sendVboxAcceptEquip,
|
||||
setInfo,
|
||||
setActiveConstruct,
|
||||
itemInfo,
|
||||
setVboxHighlight,
|
||||
sendUnequip,
|
||||
vboxSelected,
|
||||
tutorial,
|
||||
mobileVisible: navInstance === i + 1,
|
||||
});
|
||||
|
||||
@ -79,32 +79,30 @@ function createSocket(events) {
|
||||
|
||||
function sendVboxAccept(instanceId, group, index) {
|
||||
send(['VboxAccept', { instance_id: instanceId, group, index }]);
|
||||
events.clearInstance();
|
||||
}
|
||||
|
||||
function sendVboxAcceptEquip(instanceId, group, index, constructId) {
|
||||
send(['VboxAcceptEquip', { instance_id: instanceId, group, index, construct_id: constructId }]);
|
||||
}
|
||||
|
||||
function sendVboxApply(instanceId, constructId, index) {
|
||||
send(['VboxApply', { instance_id: instanceId, construct_id: constructId, index }]);
|
||||
events.clearInstance();
|
||||
}
|
||||
|
||||
function sendVboxUnequip(instanceId, constructId, target) {
|
||||
send(['VboxUnequip', { instance_id: instanceId, construct_id: constructId, target }]);
|
||||
events.clearInstance();
|
||||
}
|
||||
|
||||
function sendVboxDiscard(instanceId) {
|
||||
send(['VboxDiscard', { instance_id: instanceId }]);
|
||||
events.clearInstance();
|
||||
}
|
||||
|
||||
function sendVboxCombine(instanceId, indices) {
|
||||
send(['VboxCombine', { instance_id: instanceId, indices }]);
|
||||
events.clearCombiner();
|
||||
}
|
||||
|
||||
function sendVboxReclaim(instanceId, index) {
|
||||
send(['VboxReclaim', { instance_id: instanceId, index }]);
|
||||
events.clearInstance();
|
||||
}
|
||||
|
||||
function sendItemInfo() {
|
||||
@ -382,6 +380,7 @@ function createSocket(events) {
|
||||
sendInstanceChat,
|
||||
|
||||
sendVboxAccept,
|
||||
sendVboxAcceptEquip,
|
||||
sendVboxApply,
|
||||
sendVboxReclaim,
|
||||
sendVboxCombine,
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -113,6 +113,7 @@ 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 },
|
||||
@ -235,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)?)),
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user