equip items from vbox

This commit is contained in:
Mashy
2019-11-05 10:00:40 +10:00
parent d4169e86c3
commit c4e42457be
7 changed files with 38 additions and 18 deletions
@@ -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,
});
+5 -6
View File
@@ -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,