refactor, all tutorial code checks for practice mode and first round
This commit is contained in:
parent
f188362006
commit
4ddbd4576b
@ -12,7 +12,9 @@ const shapes = require('./shapes');
|
|||||||
class InfoComponent extends Component {
|
class InfoComponent extends Component {
|
||||||
shouldComponentUpdate(newProps) {
|
shouldComponentUpdate(newProps) {
|
||||||
if (newProps.tutorial !== this.props.tutorial) return true;
|
if (newProps.tutorial !== this.props.tutorial) return true;
|
||||||
if (newProps.tutorial) return false; // We don't care about info during tutorial
|
// We don't care about info during tutorial
|
||||||
|
if (newProps.tutorial && this.props.instance.time_control === 'Practice'
|
||||||
|
&& this.props.instance.rounds.length === 1) return false;
|
||||||
if (newProps.info !== this.props.info) return true;
|
if (newProps.info !== this.props.info) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -29,7 +31,10 @@ class InfoComponent extends Component {
|
|||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
function Info() {
|
function Info() {
|
||||||
if (tutorial) return tutorialStage(tutorial, ws, clearTutorial, instance);
|
if (tutorial) {
|
||||||
|
const tutorialStageInfo = tutorialStage(tutorial, ws, clearTutorial, instance);
|
||||||
|
if (tutorialStageInfo) return tutorialStageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -8,6 +8,7 @@ const { STATS } = require('../utils');
|
|||||||
const { ConstructAvatar } = require('./construct');
|
const { ConstructAvatar } = require('./construct');
|
||||||
const actions = require('../actions');
|
const actions = require('../actions');
|
||||||
const { removeTier } = require('../utils');
|
const { removeTier } = require('../utils');
|
||||||
|
const { tutorialConstructDisplay, tutorialShouldDisableEquip } = require('../tutorial.utils.jsx');
|
||||||
|
|
||||||
const addState = connect(
|
const addState = connect(
|
||||||
function receiveState(state) {
|
function receiveState(state) {
|
||||||
@ -79,6 +80,7 @@ function Construct(props) {
|
|||||||
const {
|
const {
|
||||||
iter,
|
iter,
|
||||||
itemEquip,
|
itemEquip,
|
||||||
|
instance,
|
||||||
construct,
|
construct,
|
||||||
player,
|
player,
|
||||||
sendVboxApply,
|
sendVboxApply,
|
||||||
@ -99,7 +101,7 @@ function Construct(props) {
|
|||||||
if (!sk) return false;
|
if (!sk) return false;
|
||||||
return sk.skill === vbox.bound[itemEquip];
|
return sk.skill === vbox.bound[itemEquip];
|
||||||
});
|
});
|
||||||
const tutorialDisableEquip = tutorial && tutorial === 6 && iter === 0 && construct.skills.length !== 0;
|
const tutorialDisableEquip = tutorialShouldDisableEquip(tutorial, iter, instance, construct);
|
||||||
|
|
||||||
function onClick(e) {
|
function onClick(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -143,8 +145,8 @@ function Construct(props) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const action = skill ? '' : 'action';
|
const equipping = skillList.includes(vbox.bound[itemEquip]) && !skill
|
||||||
const equipping = skillList.includes(vbox.bound[itemEquip]) && !skill && !tutorialDisableEquip && !duplicateSkill;
|
&& !tutorialDisableEquip && !duplicateSkill;
|
||||||
const border = () => {
|
const border = () => {
|
||||||
if (!skill) return '';
|
if (!skill) return '';
|
||||||
const borderFn = buttons[removeTier(skill.skill)];
|
const borderFn = buttons[removeTier(skill.skill)];
|
||||||
@ -179,8 +181,6 @@ function Construct(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const specInfo = itemInfo.items.find(i => i.item === s);
|
|
||||||
|
|
||||||
function specClick(e) {
|
function specClick(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setItemUnequip([construct.id, s]);
|
setItemUnequip([construct.id, s]);
|
||||||
@ -266,17 +266,13 @@ function InstanceConstructs(props) {
|
|||||||
if (instance.phase === 'Lobby') return false;
|
if (instance.phase === 'Lobby') return false;
|
||||||
|
|
||||||
const constructs = range(0, 3).map(i => {
|
const constructs = range(0, 3).map(i => {
|
||||||
if (tutorial && tutorial < 6) {
|
const tutorialConstruct = tutorialConstructDisplay(player, instance, tutorial, navInstance, i);
|
||||||
if (tutorial <= 2 || (tutorial > 2 && i > 0)) {
|
if (tutorialConstruct) return (tutorialConstruct);
|
||||||
const mobileVisible = navInstance === i + 1;
|
|
||||||
const classes = `instance-construct ${mobileVisible ? 'visible' : ''}`;
|
|
||||||
return (<div key={player.constructs[i].id} class={classes}></div>);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Construct({
|
return Construct({
|
||||||
iter: i,
|
iter: i,
|
||||||
construct: player.constructs[i],
|
construct: player.constructs[i],
|
||||||
activeConstruct,
|
activeConstruct,
|
||||||
|
instance,
|
||||||
itemEquip,
|
itemEquip,
|
||||||
setItemUnequip,
|
setItemUnequip,
|
||||||
setItemEquip,
|
setItemEquip,
|
||||||
|
|||||||
@ -1,6 +1,23 @@
|
|||||||
const preact = require('preact');
|
const preact = require('preact');
|
||||||
const actions = require('./actions');
|
const actions = require('./actions');
|
||||||
|
|
||||||
|
function tutorialConstructDisplay(player, instance, tutorial, navInstance, i) {
|
||||||
|
if (instance.time_control === 'Practice' && instance.rounds.length === 1 && tutorial && tutorial < 6) {
|
||||||
|
if (tutorial <= 2 || (tutorial > 2 && i > 0)) {
|
||||||
|
const mobileVisible = navInstance === i + 1;
|
||||||
|
const classes = `instance-construct ${mobileVisible ? 'visible' : ''}`;
|
||||||
|
return (<div key={player.constructs[i].id} class={classes}></div>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tutorialShouldDisableEquip(tutorial, iter, instance, construct) {
|
||||||
|
return tutorial && tutorial === 6 && iter === 0 && construct.skills.length !== 0
|
||||||
|
&& instance.time_control === 'Practice' && instance.rounds.length === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function tutorialVbox(player, store, tutorial) {
|
function tutorialVbox(player, store, tutorial) {
|
||||||
let stage = tutorial;
|
let stage = tutorial;
|
||||||
const { vbox } = player;
|
const { vbox } = player;
|
||||||
@ -82,6 +99,7 @@ function tutorialVbox(player, store, tutorial) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tutorialStage(tutorial, ws, clearTutorial, instance) {
|
function tutorialStage(tutorial, ws, clearTutorial, instance) {
|
||||||
|
if (!(instance.time_control === 'Practice' && instance.rounds.length === 1)) return false;
|
||||||
const exit = () => {
|
const exit = () => {
|
||||||
clearTutorial();
|
clearTutorial();
|
||||||
ws.sendInstanceState(instance.id);
|
ws.sendInstanceState(instance.id);
|
||||||
@ -200,6 +218,8 @@ function tutorialStage(tutorial, ws, clearTutorial, instance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
tutorialConstructDisplay,
|
||||||
tutorialVbox,
|
tutorialVbox,
|
||||||
tutorialStage,
|
tutorialStage,
|
||||||
|
tutorialShouldDisableEquip
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user