fix change locked stage on mobile

This commit is contained in:
Antti Pilto 2017-03-27 19:53:57 +03:00
parent 8e38824170
commit 7e67ed48c7
3 changed files with 12 additions and 7 deletions

View file

@ -14,6 +14,7 @@ class Footer extends Component {
<h4>Updates</h4> <h4>Updates</h4>
<p> <p>
<strong>27 March 2017</strong> &middot; Bufix: Allow mobile browsers to change a locked stage number.<br />
<strong>24 March 2017</strong> &middot; Enhancement: Improved mobile browser usability with reduced margins.<br /> <strong>24 March 2017</strong> &middot; Enhancement: Improved mobile browser usability with reduced margins.<br />
<strong>18 March 2017</strong> &middot; Bugfix: Fixed unintended behavior when same group was selected from both hiragana &amp; katakana. Thanks for the bug report! <strong>18 March 2017</strong> &middot; Bugfix: Fixed unintended behavior when same group was selected from both hiragana &amp; katakana. Thanks for the bug report!
</p> </p>

View file

@ -21,17 +21,17 @@ class ShowStage extends Component {
showStage() { showStage() {
let stageDescription; let stageDescription;
let stageSecondaryDescription = false; let stageSecondaryDescription = false;
if(this.props.stage===1) stageDescription = 'Choose one'; if(this.props.stage==1) stageDescription = 'Choose one';
if(this.props.stage===2) { stageDescription = 'Choose one'; stageSecondaryDescription = 'Reverse'; } if(this.props.stage==2) { stageDescription = 'Choose one'; stageSecondaryDescription = 'Reverse'; }
if(this.props.stage===3) stageDescription = 'Write the answer'; if(this.props.stage==3) stageDescription = 'Write the answer';
if(this.props.stage===4) { stageDescription = 'Write the answer'; stageSecondaryDescription = 'Three at once'; } if(this.props.stage==4) { stageDescription = 'Write the answer'; stageSecondaryDescription = 'Three at once'; }
let stageContent = (<div className="text-center show-stage"> let stageContent = (<div className="text-center show-stage">
<h1>Stage {this.props.stage}</h1> <h1>Stage {this.props.stage}</h1>
<h3>{stageDescription}</h3> <h3>{stageDescription}</h3>
{stageSecondaryDescription?<h4>{stageSecondaryDescription}</h4>:''} {stageSecondaryDescription?<h4>{stageSecondaryDescription}</h4>:''}
</div>); </div>);
if(this.props.stage===5) { if(this.props.stage==5) {
stageContent = (<div className="text-center show-end"> stageContent = (<div className="text-center show-end">
<h1>Congratulations!</h1> <h1>Congratulations!</h1>
<h3>You have passed all 4 stages.</h3> <h3>You have passed all 4 stages.</h3>

View file

@ -17,6 +17,11 @@ class GameContainer extends Component {
} }
startGame(decidedGroups) { startGame(decidedGroups) {
if(parseInt(this.state.stage)<1 || isNaN(parseInt(this.state.stage)))
this.setState({stage: 1});
else if(parseInt(this.state.stage)>4)
this.setState({stage: 4});
this.setState({decidedGroups: decidedGroups}); this.setState({decidedGroups: decidedGroups});
this.props.handleStartGame(); this.props.handleStartGame();
} }
@ -26,8 +31,7 @@ class GameContainer extends Component {
} }
lockStage(stage, forceLock) { lockStage(stage, forceLock) {
stage = parseInt(stage) || 1; // if(stage<1 || stage>4) stage=1; // don't use this to allow backspace
if(stage<1 || stage>4) stage=1;
if(forceLock) if(forceLock)
this.setState({stage: stage, isLocked: true}); this.setState({stage: stage, isLocked: true});
else else