diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index e52249d0..260a36f7 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -174,3 +174,19 @@ section { } } + +.vbox { + .login { + display: flex; + flex-flow: column; + + label { + line-height: initial; + } + + .terms { + display: inline; + margin: 0 1em; + } + } +} diff --git a/client/assets/styles/styles.mobile.less b/client/assets/styles/styles.mobile.less index 27c8fa8a..40a8de5e 100644 --- a/client/assets/styles/styles.mobile.less +++ b/client/assets/styles/styles.mobile.less @@ -164,7 +164,7 @@ // portrait menu or small size vertical in landscape -@media (max-width: 550px) and (max-height: 800px) { +@media (max-width: 550px) and (max-height: 800px) and (orientation: portrait) { #mnml { grid-template-columns: 1fr; grid-template-rows: 1fr; diff --git a/client/src/components/welcome.login.jsx b/client/src/components/welcome.login.jsx index aa65f20d..5aff5441 100644 --- a/client/src/components/welcome.login.jsx +++ b/client/src/components/welcome.login.jsx @@ -4,6 +4,7 @@ const { Component } = require('preact') const { connect } = require('preact-redux'); const linkState = require('linkstate').default; +const actions = require('./../actions'); const { postData, errorToast } = require('../utils'); const addState = connect( @@ -26,18 +27,29 @@ const addState = connect( submitLogin, } }, + function receiveDispatch(dispatch) { + function clearInstance(user) { + dispatch(actions.setInstance(null)); + } + + return { + clearInstance, + } + } ); function Login(args) { const { submitLogin, + clearInstance, } = args; const { password, name } = this.state; const loginSubmit = (event) => { event.preventDefault(); + clearInstance(); submitLogin(name, password); this.setState({ name: '', password: '' }); }; diff --git a/client/src/events.jsx b/client/src/events.jsx index fa048f29..c0b935b1 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -27,7 +27,6 @@ function registerEvents(store) { function clearTutorial() { store.dispatch(actions.setTutorial(null)); - localStorage.setItem('tutorial-complete', true); } @@ -35,7 +34,6 @@ function registerEvents(store) { store.dispatch(actions.setTutorialGame(null)); } - function setPing(ping) { store.dispatch(actions.setPing(ping)); } @@ -179,18 +177,14 @@ 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 (v.phase === 'Finished') { ws.sendAccountInstances(); } - - // instance.mobile.less hides info at @media 1000 - if (localStorage.getItem('tutorial-complete') || window.innerWidth <= 1100) { - store.dispatch(actions.setTutorial(null)); - } else if (v.time_control === 'Practice' && v.rounds.length === 1 && tutorial) { - tutorialVbox(player, store, tutorial); - } } + return store.dispatch(actions.setInstance(v)); } @@ -214,6 +208,11 @@ function registerEvents(store) { return true; } + function startTutorial() { + store.dispatch(actions.setTutorial(1)); + } + + window.addEventListener('hashchange', urlHashChange, false); return { @@ -243,6 +242,8 @@ function registerEvents(store) { setSubscription, setWs, + startTutorial, + urlHashChange, notify, diff --git a/client/src/socket.jsx b/client/src/socket.jsx index bacf0870..0a17587d 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -299,6 +299,8 @@ function createSocket(events) { ChatWheel: wheel => events.setChatWheel(wheel), // Joining: () => events.notify('Searching for instance...'), + StartTutorial: () => events.startTutorial(), + Processing: () => true, Error: errHandler, }; diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index 740aa867..fa2f7abb 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -1,6 +1,8 @@ const preact = require('preact'); const actions = require('./actions'); +const Login = require('./components/welcome.login'); + function tutorialConstructDisplay(player, instance, tutorial, i) { if (instance.time_control === 'Practice' && instance.rounds.length === 1 && tutorial && tutorial < 6) { if (tutorial <= 2 || (tutorial > 2 && i > 0)) { @@ -27,6 +29,7 @@ function tutorialVbox(player, store, tutorial) { for (let i = 2; i < 6; i += 1) { delete vbox.store.Colours[i]; } + vbox.store.Colours = {}; vbox.store.Skills = {}; vbox.store.Specs = {}; delete vbox.stash[0]; @@ -112,6 +115,21 @@ function tutorialStage(tutorial, clearTutorial, instance) { const exit = () => clearTutorial(); const tutorialText = () => { + if (tutorial === 1) { + return ( +
MNML is a turn-based 1v1 strategy game in an abstract setting.
+
+ Build a unique team of 3 constructs from a range of skills and specialisations.
+ Outplay your opponent in multiple rounds by adapting to an always shifting meta.
+ Simple rules, complex interactions and unique mechanics.
+