diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 8c58ed0d..f9fb6cd5 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -50,6 +50,8 @@ export const setTeam = value => ({ type: 'SET_TEAM', value: Array.from(value) }) export const setTeamPage = value => ({ type: 'SET_TEAM_PAGE', value }); export const setTeamSelect = value => ({ type: 'SET_TEAM_SELECT', value: Array.from(value) }); +export const setTutorial = value => ({ type: 'SET_TUTORIAL', value }); + export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value }); export const setVboxSelected = value => ({ type: 'SET_VBOX_SELECTED', value }); diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 3aebbc14..bf1c8cd6 100644 --- a/client/src/components/info.component.jsx +++ b/client/src/components/info.component.jsx @@ -4,19 +4,23 @@ const reactStringReplace = require('react-string-replace'); const { INFO } = require('./../constants'); const { convertItem, removeTier } = require('../utils'); +const { tutorialStage } = require('../tutorial.utils'); const shapes = require('./shapes'); function InfoComponent(args) { const { + ws, itemInfo, player, + instance, info, + tutorial, + clearTutorial, } = args; - // args.info = 'Life'; - // const { info } = args; - function Info() { + if (tutorial) return tutorialStage(tutorial, ws, clearTutorial, instance); + if (!info) { return (
@@ -178,6 +182,7 @@ function InfoComponent(args) { function Combos() { if (!player) return false; if (!info) return false; + if (tutorial) return false; const vboxCombos = itemInfo.combos.filter(c => c.components.includes(info)); if (vboxCombos.length > 6) return false; diff --git a/client/src/components/info.container.jsx b/client/src/components/info.container.jsx index 5f8639b8..b19fff8e 100644 --- a/client/src/components/info.container.jsx +++ b/client/src/components/info.container.jsx @@ -13,6 +13,7 @@ const addState = connect( instance, player, account, + tutorial, } = state; return { @@ -23,8 +24,18 @@ const addState = connect( instance, player, account, + tutorial, }; }, + + function receiveDispatch(dispatch) { + function clearTutorial() { + dispatch(actions.setTutorial(null)); + } + return { clearTutorial }; + } + + ); module.exports = addState(Info); diff --git a/client/src/components/instance.constructs.jsx b/client/src/components/instance.constructs.jsx index bc7e005f..5d3ec130 100644 --- a/client/src/components/instance.constructs.jsx +++ b/client/src/components/instance.constructs.jsx @@ -20,6 +20,7 @@ const addState = connect( itemEquip, activeConstruct, navInstance, + tutorial, } = state; function sendVboxApply(constructId, i) { @@ -40,6 +41,7 @@ const addState = connect( navInstance, activeConstruct, sendUnequip, + tutorial, }; }, @@ -75,6 +77,7 @@ const addState = connect( function Construct(props) { const { + iter, itemEquip, construct, player, @@ -86,11 +89,22 @@ function Construct(props) { setInfo, sendUnequip, mobileVisible, + tutorial, } = props; + const { vbox } = player; + + const duplicateSkill = construct.skills.length !== 0 && construct.skills.every(sk => { + if (!itemEquip && itemEquip !== 0) return false; + if (!sk) return false; + return sk.skill === vbox.bound[itemEquip]; + }); + const tutorialDisableEquip = tutorial && tutorial === 6 && iter === 0 && construct.skills.length !== 0; + function onClick(e) { e.stopPropagation(); e.preventDefault(); + if (duplicateSkill || tutorialDisableEquip) return true; if (itemEquip !== null) sendVboxApply(construct.id, itemEquip); setItemEquip(null); return setActiveConstruct(construct); @@ -102,7 +116,6 @@ function Construct(props) { return setInfo(info); } - const { vbox } = player; const skillList = itemInfo.items.filter(v => v.skill).map(v => v.item); const specList = itemInfo.items.filter(v => v.spec).map(v => v.item); @@ -129,9 +142,9 @@ function Construct(props) { e.preventDefault(); return true; } - + // const action = skill ? '' : 'action'; - const equipping = skillList.includes(vbox.bound[itemEquip]) && !skill; + const equipping = skillList.includes(vbox.bound[itemEquip]) && !skill && !tutorialDisableEquip && !duplicateSkill; const border = () => { if (!skill) return ''; const borderFn = buttons[removeTier(skill.skill)]; @@ -246,30 +259,41 @@ function InstanceConstructs(props) { setItemEquip, sendUnequip, navInstance, + tutorial, } = props; if (!player) return false; if (instance.phase === 'Lobby') return false; - const constructs = player.constructs.map((c, i) => Construct({ - construct: c, - activeConstruct, - itemEquip, - setItemUnequip, - setItemEquip, - player, - sendVboxApply, - setInfo, - setActiveConstruct, - itemInfo, - setVboxHighlight, - sendUnequip, - mobileVisible: navInstance === i + 1, - })); + const constructs = range(0, 3).map(i => { + if (tutorial && tutorial < 6) { + if (tutorial <= 2 || (tutorial > 2 && i > 0)) { + const mobileVisible = navInstance === i + 1; + const classes = `instance-construct ${mobileVisible ? 'visible' : ''}`; + return (
); + } + } + return Construct({ + iter: i, + construct: player.constructs[i], + activeConstruct, + itemEquip, + setItemUnequip, + setItemEquip, + player, + sendVboxApply, + setInfo, + setActiveConstruct, + itemInfo, + setVboxHighlight, + sendUnequip, + tutorial, + mobileVisible: navInstance === i + 1, + }); + }); - const classes = `construct-list`; return ( -
setActiveConstruct(null)}> +
setActiveConstruct(null)}> {constructs}
); diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index 266ae0b2..ce9da0c3 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -21,6 +21,7 @@ const addState = connect( itemUnequip, navInstance, info, + tutorial, } = state; function sendVboxDiscard() { @@ -57,6 +58,7 @@ const addState = connect( itemUnequip, sendItemUnequip, navInstance, + tutorial, info, }; }, @@ -113,6 +115,7 @@ function Vbox(args) { setVboxSelected, setItemEquip, + tutorial, itemUnequip, sendItemUnequip, @@ -161,16 +164,7 @@ function Vbox(args) { function availableBtn(v, group, index) { if (!v) return ; - const tutorial = instance.time_control === 'Practice' - && instance.rounds.length === 1 - && group === 0 - && combiner.length === 0 - && vboxSelected.length === 0 - && vbox.bits > 10 - && vbox.free[0].filter(c => c).length > 4 - ? 'combo-border' : null; - - const selected = vboxSelected[0] === group && vboxSelected[1] === index; + const selected = vboxSelected[0] === group && vboxSelected[1] === index; // state not yet set in double click handler function onDblClick(e) { @@ -203,7 +197,7 @@ function Vbox(args) { } return false; }) ? 'combo-border' : ''; - const classes = `${v.toLowerCase()} ${selected ? 'highlight' : ''} ${comboHighlight} ${tutorial}`; + const classes = `${v.toLowerCase()} ${selected ? 'highlight' : ''} ${comboHighlight}`; if (shapes[v]) { return ( @@ -251,6 +245,7 @@ function Vbox(args) { ; } - const tutorial = instance.time_control === 'Practice' - && instance.rounds.length === 1 - && i === 0 - && combiner.length === 0 - && vboxSelected.length === 0 - && vbox.bits === 16 - && vbox.bound.length === 5 - && vbox.free[0].filter(c => c).length === 4 - ? 'combo-border' : null; - const combinerItems = combiner.map(j => vbox.bound[j]); const combinerCount = countBy(combinerItems, co => co); @@ -325,7 +310,7 @@ function Vbox(args) { const highlighted = combiner.indexOf(i) > -1; const border = buttons[removeTier(v)] ? buttons[removeTier(v)]() : ''; - const classes = `${highlighted ? 'highlight' : border} ${comboHighlight} ${tutorial}`; + const classes = `${highlighted ? 'highlight' : border} ${comboHighlight}`; if (shapes[v]) { return ( ; + + return ( +
+ {tutorialText()} + {exitTutorial} +
); +} + +module.exports = { + tutorialVbox, + tutorialStage, +};