tutorial client fixes

This commit is contained in:
Mashy 2020-01-17 17:20:22 +10:00
parent 8bf6f714fd
commit d11b7dcdb3
4 changed files with 14 additions and 7 deletions

View File

@ -5,8 +5,8 @@ const { tutorialStage } = require('../tutorial.utils');
const { genItemInfo } = require('./vbox.utils');
const addState = connect(
({ info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview }) => ({
info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview,
({ info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, authenticated }) => ({
info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, authenticated
}));
@ -35,12 +35,13 @@ class Info extends preact.Component {
itemInfo,
instance,
comboPreview,
authenticated,
} = props;
// dispaly priority
// tutorial -> comboPreview -> vboxInfo -> info
if (tutorial) {
const tutorialStageInfo = tutorialStage(tutorial, clearTutorial, instance);
const tutorialStageInfo = tutorialStage(authenticated, tutorial, clearTutorial, instance);
if (tutorialStageInfo) return tutorialStageInfo;
}
if (comboPreview) return genItemInfo(comboPreview, itemInfo, player);

View File

@ -185,7 +185,7 @@ function registerEvents(store) {
const player = v.players.find(p => p.id === account.id);
store.dispatch(actions.setPlayer(player));
if (tutorial) tutorialVbox(player, store, tutorial);
if (tutorial && process.env.NODE_ENV !== 'development') tutorialVbox(player, store, tutorial);
if (v.phase === 'Finished') {
ws.sendAccountInstances();

View File

@ -53,7 +53,7 @@ module.exports = {
teamPage: createReducer(0, 'SET_TEAM_PAGE'),
teamSelect: createReducer([null, null, null], 'SET_TEAM_SELECT'),
tutorial: createReducer(localStorage.getItem('tutorial-complete') ? null : 1, 'SET_TUTORIAL'),
tutorial: createReducer(1, 'SET_TUTORIAL'),
vboxSelected: createReducer({ storeSelect: [], stashSelect: [] }, 'SET_VBOX_SELECTED'),
vboxCombiner: createReducer(null, 'SET_VBOX_COMBINER'),

View File

@ -106,7 +106,7 @@ function tutorialVbox(player, store, tutorial) {
store.dispatch(actions.setTutorial(stage));
}
function tutorialStage(tutorial, clearTutorial, instance) {
function tutorialStage(authenticated, tutorial, clearTutorial, instance) {
if (!(instance.time_control === 'Practice' && instance.rounds.length === 1)) return false;
const exit = () => clearTutorial();
@ -197,7 +197,6 @@ function tutorialStage(tutorial, clearTutorial, instance) {
}
if (tutorial === 8) {
localStorage.setItem('tutorial-complete', true);
if (window.innerWidth < 1000) {
return exit();
}
@ -221,11 +220,18 @@ function tutorialStage(tutorial, clearTutorial, instance) {
onMouseDown={exit}> Continue </button>
: null;
const skipTutorial = authenticated && !exitTutorial ?
<button
onClick={e => e.stopPropagation()}
onMouseDown={exit}> Skip </button>
: null;
return (
<div class='tutorial'>
{tutorialText()}
<figure>
{exitTutorial}
{skipTutorial}
</figure>
</div>);
}