diff --git a/client/assets/styles/vbox.less b/client/assets/styles/vbox.less index 209f31de..aab8da8e 100644 --- a/client/assets/styles/vbox.less +++ b/client/assets/styles/vbox.less @@ -116,7 +116,7 @@ }; } - .reclaiming { + .Refunding { button:not([disabled]) { &, &:hover, &:active { background: @red; diff --git a/client/src/components/instance.constructs.jsx b/client/src/components/instance.constructs.jsx index 3ed752b7..5a752394 100644 --- a/client/src/components/instance.constructs.jsx +++ b/client/src/components/instance.constructs.jsx @@ -24,8 +24,8 @@ const addState = connect( tutorial, } = state; - function sendVboxAcceptEquip(constructId) { - return ws.sendVboxAcceptEquip(instance.id, vboxSelected.storeSelect[0][0], vboxSelected.storeSelect[0][1], constructId); + function sendVboxBuyEquip(constructId) { + return ws.sendVboxBuyEquip(instance.id, vboxSelected.storeSelect[0][0], vboxSelected.storeSelect[0][1], constructId); } function sendVboxApply(constructId, i) { @@ -40,7 +40,7 @@ const addState = connect( instance, player, account, - sendVboxAcceptEquip, + sendVboxBuyEquip, sendVboxUnequipApply, sendVboxApply, itemInfo, @@ -83,7 +83,7 @@ function Construct(props) { itemInfo, // Function Calls sendVboxApply, - sendVboxAcceptEquip, + sendVboxBuyEquip, sendVboxUnequipApply, setItemUnequip, setInfo, @@ -106,7 +106,7 @@ function Construct(props) { e.preventDefault(); if (duplicateSkill || tutorialDisableEquip) return true; if (itemEquip !== -1) return sendVboxApply(construct.id, itemEquip); - if (vboxSelected.storeSelect.length === 1) return sendVboxAcceptEquip(construct.id); + if (vboxSelected.storeSelect.length === 1) return sendVboxBuyEquip(construct.id); if (itemUnequip.length && itemUnequip[0] !== construct.id) return sendVboxUnequipApply(construct.id); setItemUnequip([]); return true; @@ -261,7 +261,7 @@ class InstanceConstructs extends preact.Component { // Function calls setInfo, sendVboxApply, - sendVboxAcceptEquip, + sendVboxBuyEquip, sendVboxUnequipApply, setItemUnequip, } = props; @@ -281,7 +281,7 @@ class InstanceConstructs extends preact.Component { setItemUnequip, player, sendVboxApply, - sendVboxAcceptEquip, + sendVboxBuyEquip, sendVboxUnequipApply, setInfo, itemInfo, diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index 9d192b9c..2891e060 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -27,22 +27,22 @@ const addState = connect( return ws.clearTutorial(instance.id); } - function sendVboxDiscard() { - return ws.sendVboxDiscard(instance.id); + function sendVboxRefill() { + return ws.sendVboxRefill(instance.id); } - function sendVboxAccept(group, index) { + function sendVboxBuy(group, index) { if (!(vboxSelected.storeSelect.length === 1 && vboxSelected.stashSelect.length === 0)) return false; document.activeElement.blur(); - return ws.sendVboxAccept(instance.id, group, index); + return ws.sendVboxBuy(instance.id, group, index); } function sendVboxCombine() { return ws.sendVboxCombine(instance.id, vboxSelected.stashSelect, vboxSelected.storeSelect); } - function sendVboxReclaim(i) { - return ws.sendVboxReclaim(instance.id, i); + function sendVboxRefund(i) { + return ws.sendVboxRefund(instance.id, i); } function sendItemUnequip([constructId, item]) { @@ -60,10 +60,10 @@ const addState = connect( clearTutorial, sendItemUnequip, - sendVboxAccept, + sendVboxBuy, sendVboxCombine, - sendVboxDiscard, - sendVboxReclaim, + sendVboxRefill, + sendVboxRefund, }; }, @@ -109,10 +109,10 @@ class Vbox extends preact.Component { clearTutorial, dispatchVboxSelect, sendItemUnequip, - sendVboxAccept, + sendVboxBuy, sendVboxCombine, - sendVboxDiscard, - sendVboxReclaim, + sendVboxRefill, + sendVboxRefund, setInfo, } = args; @@ -122,7 +122,7 @@ class Vbox extends preact.Component { const setVboxSelected = v => dispatchVboxSelect(v, { itemInfo, itemUnequip, vbox }); const clearVboxSelected = () => setVboxSelected({ storeSelect: [], stashSelect: [] }); - const vboxBuySelected = () => sendVboxAccept(storeSelect[0][0], storeSelect[0][1]); + const vboxBuySelected = () => sendVboxBuy(storeSelect[0][0], storeSelect[0][1]); function vboxHover(e, v) { if (v) { @@ -151,7 +151,7 @@ class Vbox extends preact.Component { && instance.time_control === 'Practice' && instance.rounds.length === 1) } onClick={e => e.stopPropagation()} - onMouseDown={() => sendVboxDiscard()}> + onMouseDown={() => sendVboxRefill()}> refill
2b @@ -172,7 +172,7 @@ class Vbox extends preact.Component { onClick={e => e.stopPropagation()} onMouseDown={e => { e.stopPropagation(); - sendVboxReclaim(vboxSelected.stashSelect[0]); + sendVboxRefund(vboxSelected.stashSelect[0]); }}> refund
{refund}b diff --git a/client/src/constants.jsx b/client/src/constants.jsx index f16b7f3b..989e689f 100644 --- a/client/src/constants.jsx +++ b/client/src/constants.jsx @@ -45,10 +45,10 @@ module.exports = { item: 'READY', description: 'Ready for the game to begin. When all players are ready the first VBOX PHASE begins.', }, - reclaim: { - item: 'RECLAIM', - description:

Reclaim items refunding the listed cost of the item.
- Click to enable and then click the item to reclaim.

, + Refund: { + item: 'Refund', + description:

Refund items refunding the listed cost of the item.
+ Click to enable and then click the item to Refund.

, }, refill: { item: 'REFILL', diff --git a/client/src/socket.jsx b/client/src/socket.jsx index c97c4fb2..ffe00b7d 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -2,6 +2,7 @@ const toast = require('izitoast'); const cbor = require('borc'); const throttle = require('lodash/throttle'); +const groupBy = require('lodash/groupBy'); const SOCKET_URL = `${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}/api/ws`; @@ -77,13 +78,13 @@ function createSocket(events) { send(['InstanceChat', { instance_id: instanceId, index }]); } - function sendVboxAccept(instanceId, group, index) { - send(['VboxAccept', { instance_id: instanceId, group, index }]); + function sendVboxBuy(instanceId, group, index) { + send(['VboxBuy', { instance_id: instanceId, group, index }]); events.clearInstance(); } - function sendVboxAcceptEquip(instanceId, group, index, constructId) { - send(['VboxAcceptEquip', { instance_id: instanceId, group, index, construct_id: constructId }]); + function sendVboxBuyEquip(instanceId, group, index, constructId) { + send(['VboxBuyEquip', { instance_id: instanceId, group, index, construct_id: constructId }]); events.clearInstance(); } @@ -102,18 +103,20 @@ function createSocket(events) { events.clearInstance(); } - function sendVboxDiscard(instanceId) { - send(['VboxDiscard', { instance_id: instanceId }]); + function sendVboxRefill(instanceId) { + send(['VboxRefill', { instance_id: instanceId }]); events.clearInstance(); } function sendVboxCombine(instanceId, invIndicies, vboxIndicies) { - send(['VboxCombine', { instance_id: instanceId, inv_indices: invIndicies, vbox_indices: vboxIndicies }]); + const formatted = {}; + vboxIndicies.forEach(p => formatted[p[0]] ? formatted[p[0]].push(p[1]) : formatted[p[0]] = [p[1]]); + send(['VboxCombine', { instance_id: instanceId, inv_indices: invIndicies, vbox_indices: formatted }]); events.clearInstance(); } - function sendVboxReclaim(instanceId, index) { - send(['VboxReclaim', { instance_id: instanceId, index }]); + function sendVboxRefund(instanceId, index) { + send(['VboxRefund', { instance_id: instanceId, index }]); events.clearInstance(); } @@ -204,12 +207,6 @@ function createSocket(events) { send(['SubscriptionState', {}]); } - function clearTutorial(instanceId) { - events.clearTutorial(); - events.clearInstance(); - sendInstanceState(instanceId); - } - // ------------- // Incoming // ------------- @@ -416,12 +413,12 @@ function createSocket(events) { sendInstanceChat, sendInstanceLeave, - sendVboxAccept, - sendVboxAcceptEquip, + sendVboxBuy, + sendVboxBuyEquip, sendVboxApply, - sendVboxReclaim, + sendVboxRefund, sendVboxCombine, - sendVboxDiscard, + sendVboxRefill, sendVboxUnequip, sendVboxUnequipApply, @@ -436,8 +433,6 @@ function createSocket(events) { sendMtxBuy, sendMtxConstructSpawn, - clearTutorial, - connect, }; } diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index e60974f4..0760a13c 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -204,7 +204,7 @@ function tutorialStage(tutorial, clearTutorial, instance) {

Press READY to progress to the GAME PHASE
or continue creating new items to strengthen your constructs further

You can unequip skills and specs back into the inventory by double clicking.
- Reclaim can be used to refund the cost of items in your inventory.

+ Refund can be used to refund the cost of items in your inventory.

); } diff --git a/client/src/utils.jsx b/client/src/utils.jsx index a14c684e..550c69e6 100644 --- a/client/src/utils.jsx +++ b/client/src/utils.jsx @@ -197,7 +197,7 @@ function postData(url = '/', data = {}) { cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached credentials: 'include', // include, same-origin, *omit headers: { - Accept: 'application/json', + Buy: 'application/json', 'content-type': 'application/json', }, redirect: 'error', // manual, *follow, error diff --git a/server/src/vbox.rs b/server/src/vbox.rs index e2507c74..fdfd1d3d 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -130,7 +130,7 @@ impl Vbox { // check item exists let selection = self.store .get_mut(&item).ok_or(format_err!("no item group {:?}", item))? - .remove(i).ok_or(format_err!("no item at index {:?} {:}", item, i))?; + .remove(i).ok_or(format_err!("no item at index {:?} {:}", self, i))?; self.balance_sub(selection.cost())?;