diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index 2891e060..2f1770da 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -23,8 +23,8 @@ const addState = connect( itemInfo, } = state; - function clearTutorial() { - return ws.clearTutorial(instance.id); + function sendInstance() { + return ws.sendInstanceState(instance.id); } function sendVboxRefill() { @@ -58,7 +58,7 @@ const addState = connect( itemInfo, - clearTutorial, + sendInstance, sendItemUnequip, sendVboxBuy, sendVboxCombine, @@ -72,6 +72,10 @@ const addState = connect( return dispatch(actions.setInfo(item)); } + function setTutorial(stage) { + return dispatch(actions.setTutorial(stage)); + } + function dispatchVboxSelect(v, state) { setVboxState(dispatch, v, state); dispatch(actions.setItemUnequip([])); @@ -81,6 +85,7 @@ const addState = connect( return { dispatchVboxSelect, setInfo, + setTutorial, }; } ); @@ -106,14 +111,15 @@ class Vbox extends preact.Component { // Static itemInfo, // Function Calls - clearTutorial, dispatchVboxSelect, sendItemUnequip, + sendInstance, sendVboxBuy, sendVboxCombine, sendVboxRefill, sendVboxRefund, setInfo, + setTutorial, } = args; if (!player) return false; @@ -123,7 +129,10 @@ class Vbox extends preact.Component { const setVboxSelected = v => dispatchVboxSelect(v, { itemInfo, itemUnequip, vbox }); const clearVboxSelected = () => setVboxSelected({ storeSelect: [], stashSelect: [] }); const vboxBuySelected = () => sendVboxBuy(storeSelect[0][0], storeSelect[0][1]); - + const clearTutorial = () => { + setTutorial(null); + sendInstance(); + }; function vboxHover(e, v) { if (v) { e.stopPropagation(); diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index 0760a13c..2df85c6b 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -24,21 +24,26 @@ function tutorialVbox(player, store, tutorial) { if (vbox.bits < 29) { stage += 1; } else { - vbox.store[0] = vbox.store[0].slice(0, 2); - vbox.store[1] = []; - vbox.store[2] = []; - vbox.stash.fill(null, 0, 3); + for (let i = 2; i < 6; i += 1) { + delete vbox.store.Colours[i]; + } + vbox.store.Skills = {}; + vbox.store.Specs = {}; + delete vbox.stash[0]; + delete vbox.stash[1]; + delete vbox.stash[2]; } } if (stage === 2) { - if (!(vbox.stash.slice(0, 3).every(i => i === 'Attack') && vbox.stash.length >= 3)) { + if (!(vbox.stash[0] === 'Attack' && vbox.stash[1] === 'Attack' && vbox.stash[2] === 'Attack')) { stage += 1; } else { - vbox.store[0] = vbox.store[0].slice(0, 2); - vbox.store[1] = []; - vbox.store[2] = []; - vbox.stash.fill(null, 1, 3); + vbox.store.Colours = {}; + vbox.store.Skills = {}; + vbox.store.Specs = {}; + delete vbox.stash[0]; + delete vbox.stash[1]; } } @@ -46,21 +51,24 @@ function tutorialVbox(player, store, tutorial) { if (player.constructs[0].skills.length !== 0) { stage += 1; } else { - vbox.store[0] = vbox.store[0].slice(0, 2); - vbox.store[1] = []; - vbox.store[2] = []; - vbox.stash.fill(null, 0, 2); + vbox.store.Colours = {}; + vbox.store.Skills = {}; + vbox.store.Specs = {}; + delete vbox.stash[0]; + delete vbox.stash[1]; } } if (stage === 4) { - if (!vbox.store[2][0] || vbox.bits < 24) { + if (!vbox.store.Specs[0] || vbox.bits < 24) { stage += 1; } else { - vbox.store[0] = []; - vbox.store[1] = []; - vbox.store[2] = vbox.store[2].slice(0, 1); - vbox.stash.fill(null, 0, 2); + vbox.store.Colours = {}; + vbox.store.Skills = {}; + delete vbox.store.Specs[1]; + delete vbox.store.Specs[2]; + delete vbox.stash[0]; + delete vbox.stash[1]; } } @@ -68,10 +76,11 @@ function tutorialVbox(player, store, tutorial) { if (player.constructs[0].specs.length !== 0) { stage += 1; } else { - vbox.store[0] = []; - vbox.store[1] = []; - vbox.store[2] = vbox.store[2].slice(0, 1); - vbox.stash.fill(null, 0, 2); + vbox.store.Colours = {}; + vbox.store.Skills = {}; + vbox.store.Specs = {}; + delete vbox.stash[0]; + delete vbox.stash[1]; } } @@ -79,9 +88,9 @@ function tutorialVbox(player, store, tutorial) { if (player.constructs.every(c => c.skills.length !== 0)) { stage += 1; } else { - vbox.store[0] = []; - vbox.store[1] = []; - vbox.store[2] = []; + vbox.store.Colours = {}; + vbox.store.Skills = {}; + vbox.store.Specs = {}; } } @@ -89,9 +98,9 @@ function tutorialVbox(player, store, tutorial) { if (vbox.bits < 25) { stage += 1; } else { - vbox.store[0] = []; - vbox.store[1] = []; - vbox.store[2] = []; + vbox.store.Colours = {}; + vbox.store.Skills = {}; + vbox.store.Specs = {}; } } store.dispatch(actions.setTutorial(stage));