remove auth from tutorial triggers, game.construct highlight based on time_control

This commit is contained in:
Mashy 2020-01-20 12:28:32 +10:00
parent f51c28a713
commit ed5575eee8
6 changed files with 18 additions and 12 deletions

View File

@ -15,7 +15,7 @@ const addState = connect(
ws, ws,
game, game,
authenticated, instance,
activeSkill, activeSkill,
animFocus, animFocus,
resolution, resolution,
@ -30,7 +30,7 @@ const addState = connect(
return { return {
game, game,
authenticated, instance,
activeSkill, activeSkill,
animFocus, animFocus,
resolution, resolution,
@ -54,7 +54,7 @@ class GameConstruct extends preact.Component {
render() { render() {
const { const {
// Changing state variables // Changing state variables
authenticated, instance,
game, game,
activeSkill, activeSkill,
animFocus, animFocus,
@ -81,7 +81,9 @@ class GameConstruct extends preact.Component {
const unfocus = animFocus && !animFocus.includes(construct.id) ? 'unfocus' : ''; const unfocus = animFocus && !animFocus.includes(construct.id) ? 'unfocus' : '';
const targeted = game.stack.find(c => c.target === construct.id); const targeted = game.stack.find(c => c.target === construct.id);
const highlight = !authenticated && !targeted && activeSkill ? 'highlight' : '';
const firstRoundTutorial = instance && instance.time_control === 'Practice' && !game.resolutions.length;
const highlight = firstRoundTutorial && !targeted && activeSkill ? 'highlight' : '';
const crypSkills = player const crypSkills = player
? <div class="skills"> {range(0, 3).map(j => <SkillBtn key={j} construct={construct} i={j} />)} </div> ? <div class="skills"> {range(0, 3).map(j => <SkillBtn key={j} construct={construct} i={j} />)} </div>

View File

@ -10,6 +10,7 @@ const addState = connect(
game, game,
account, account,
authenticated, authenticated,
instance,
chatShow, chatShow,
animating, animating,
} = state; } = state;
@ -35,6 +36,7 @@ const addState = connect(
game, game,
account, account,
authenticated, authenticated,
instance,
chatShow, chatShow,
sendAbandon, sendAbandon,
sendGameSkillClear, sendGameSkillClear,
@ -68,6 +70,7 @@ function GameCtrlBtns(args) {
account, account,
chatShow, chatShow,
authenticated, authenticated,
instance,
getInstanceState, getInstanceState,
sendGameSkillClear, sendGameSkillClear,
@ -86,7 +89,8 @@ function GameCtrlBtns(args) {
quit(); quit();
} }
const noTargets = !authenticated && game.stack.length === 0; const firstRoundTutorial = instance && instance.time_control === 'Practice' && !game.resolutions.length;
const noTargets = firstRoundTutorial && game.stack.length === 0;
const readyBtn = <button disabled={animating || noTargets} class="ready" onClick={() => sendReady()}>Ready</button>; const readyBtn = <button disabled={animating || noTargets} class="ready" onClick={() => sendReady()}>Ready</button>;
const quitBtn = <button disabled={animating} class="quit" onClick={quitClick}>Back</button>; const quitBtn = <button disabled={animating} class="quit" onClick={quitClick}>Back</button>;

View File

@ -50,7 +50,7 @@ function InstanceCtrlBtns(args) {
} = args; } = args;
const finished = instance && instance.phase === 'Finished'; const finished = instance && instance.phase === 'Finished';
const tutorialDisable = instance.time_control === 'Practice' && tutorial; const tutorialDisable = instance.time_control === 'Practice' && tutorial && tutorial < 8;
return ( return (
<div class="instance-ctrl-btns"> <div class="instance-ctrl-btns">
<button disabled={!account.subscribed} onClick={() => setChatShow(!chatShow)}>Chat</button> <button disabled={!account.subscribed} onClick={() => setChatShow(!chatShow)}>Chat</button>

View File

@ -44,15 +44,14 @@ class TargetSvg extends Component {
animating, animating,
game, game,
gameEffectInfo, gameEffectInfo,
authenticated,
} = props; } = props;
const { width, height } = state; const { width, height } = state;
if (!game) return false; // game will be null when battle ends if (!game) return false; // game will be null when battle ends
if (game.phase === 'Finished') return false; // Clear everything if its over (in case of abandon) if (game.phase === 'Finished') return false; // Clear everything if its over (in case of abandon)
// First time joining game phase // First round of a game
if (!authenticated && game.stack.length === 0) { if (!game.resolutions.length && game.stack.length === 0) {
return ( return (
<div class="resolving-skill"> <div class="resolving-skill">
<h2><b>Select a skill</b> from each construct, <b>click a target</b> for that skill and then click <b>READY</b>.</h2> <h2><b>Select a skill</b> from each construct, <b>click a target</b> for that skill and then click <b>READY</b>.</h2>

View File

@ -14,7 +14,7 @@ const addState = connect(
} = state; } = state;
return { return {
promptRegister: tutorial === 99, // see events promptRegister: !tutorial,
}; };
}, },
); );

View File

@ -180,7 +180,8 @@ function registerEvents(store) {
setPvp(false); setPvp(false);
const player = v.players.find(p => p.id === account.id); const player = v.players.find(p => p.id === account.id);
store.dispatch(actions.setPlayer(player)); store.dispatch(actions.setPlayer(player));
if (tutorial && v.time_control === 'Practice') tutorialVbox(player, store, tutorial);
if (tutorial && v.rounds.length === 1 && v.time_control === 'Practice') tutorialVbox(player, store, tutorial);
if (v.phase === 'Finished') { if (v.phase === 'Finished') {
ws.sendAccountInstances(); ws.sendAccountInstances();
@ -211,7 +212,7 @@ function registerEvents(store) {
} }
function promptRegister() { function promptRegister() {
store.dispatch(actions.setTutorial(99)); store.dispatch(actions.setTutorial(null));
store.dispatch(actions.setInstance(null)); store.dispatch(actions.setInstance(null));
} }