From 4cf378f644016d8951731ebba3909bd535a09208 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 28 Oct 2019 08:44:37 +1000 Subject: [PATCH] game phase targeting tutorial, clear arrows on game finish --- client/src/actions.jsx | 1 + client/src/components/game.construct.jsx | 20 +++++++++++++------- client/src/components/targeting.arrows.jsx | 16 +++++++++++++--- client/src/reducers.jsx | 3 ++- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/client/src/actions.jsx b/client/src/actions.jsx index f9fb6cd5..4b9d11ac 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -51,6 +51,7 @@ 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 setTutorialGame = value => ({ type: 'SET_TUTORIAL_GAME', 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/game.construct.jsx b/client/src/components/game.construct.jsx index 186a55ef..79f2a8bc 100644 --- a/client/src/components/game.construct.jsx +++ b/client/src/components/game.construct.jsx @@ -24,6 +24,7 @@ const addState = connect( animText, gameSkillInfo, itemInfo, + tutorialGame, } = state; function selectSkillTarget(targetConstructId) { @@ -33,10 +34,6 @@ const addState = connect( return false; } - // intercept self casting skills - if (activeSkill && activeSkill.skill.self_targeting) { - ws.sendGameSkill(game.id, activeSkill.constructId, null, activeSkill.skill.skill); - } return { game, account, @@ -47,6 +44,7 @@ const addState = connect( selectSkillTarget, gameSkillInfo, itemInfo, + tutorialGame, }; }, @@ -55,7 +53,11 @@ const addState = connect( dispatch(actions.setGameEffectInfo(info)); } - return { setGameEffectInfo }; + function setTutorialGameClear(activeSkill, tutorialGame) { + if (activeSkill && tutorialGame) dispatch(actions.setTutorialGame(null)); + } + + return { setGameEffectInfo, setTutorialGameClear }; } ); @@ -93,7 +95,8 @@ class GameConstruct extends Component { selectSkillTarget, animFocus, animText, - + tutorialGame, + setTutorialGameClear, setGameEffectInfo, gameSkillInfo, itemInfo, @@ -146,7 +149,10 @@ class GameConstruct extends Component { return (
selectSkillTarget(construct.id)} + onClick={() => { + selectSkillTarget(construct.id); + setTutorialGameClear(activeSkill, tutorialGame); + }} style={ activeSkill ? { cursor: 'pointer' } : {}} class={`game-construct ${ko} ${classes}`} >
diff --git a/client/src/components/targeting.arrows.jsx b/client/src/components/targeting.arrows.jsx index c9e0f57c..ebbb8eed 100644 --- a/client/src/components/targeting.arrows.jsx +++ b/client/src/components/targeting.arrows.jsx @@ -9,8 +9,8 @@ const shapes = require('./shapes'); const { effectInfo, removeTier } = require('../utils'); const addState = connect( - ({ game, account, animSkill, animating, itemInfo, gameEffectInfo }) => - ({ game, account, animSkill, animating, itemInfo, gameEffectInfo }) + ({ game, account, animSkill, animating, itemInfo, gameEffectInfo, tutorialGame }) => + ({ game, account, animSkill, animating, itemInfo, gameEffectInfo, tutorialGame }) ); class TargetSvg extends Component { @@ -28,9 +28,19 @@ class TargetSvg extends Component { } render(props, state) { - const { game, account, animating, animSkill, itemInfo, gameEffectInfo } = props; + const { game, account, animating, animSkill, itemInfo, gameEffectInfo, tutorialGame } = props; const { width, height } = state; if (!game) return false; // game will be null when battle ends + if (game.phase === 'Finish') return false; // Clear everything if its over (in case of abandon) + + // First time joining game phase + if (tutorialGame) { + return ( +
+

Select your skills, click on targets and then hit ready.

+
+ ); + } // Whenever someones looking at effects throw it up here if (gameEffectInfo) { diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index e50e5bfe..d2d06f43 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -59,7 +59,8 @@ module.exports = { teamPage: createReducer(0, 'SET_TEAM_PAGE'), teamSelect: createReducer([null, null, null], 'SET_TEAM_SELECT'), - tutorial: createReducer(1, 'SET_TUTORIAL'), + tutorial: createReducer(1, 'SET_TUTORIAL'), + tutorialGame: createReducer(1, 'SET_TUTORIAL_GAME'), vboxSelected: createReducer([], 'SET_VBOX_SELECTED'),