This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Render UI start game | |
| */ | |
| renderStartGame() { | |
| const { | |
| state: {lvl, n1, n2, operator, message, errors, hits, countdown}, | |
| props: {showResult} | |
| } = this; | |
| const result = CALCULATE(n1, n2, operator); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setNextOperation() { | |
| let n1 = getRandomNumber(0, this.state.lvl.maxNumber); | |
| let n2 = getRandomNumber(0, this.state.lvl.maxNumber); | |
| let operator = this.getRandomOperator(); | |
| let result = CALCULATE(n1, n2, operator); | |
| // If isn't real number, set the next operation | |
| if (isNaN(result) || !isFinite(result)) { | |
| this.setNextOperation(); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Handle click to validate expression | |
| * @param {object} event | |
| */ | |
| _handleClickValidateExpression(event) { | |
| event.preventDefault(); | |
| if (event.target.result.value === '') return; | |
| let value = event.target.result.value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Render UI finish game | |
| */ | |
| renderFinishGame() { | |
| const {hits, errors} = this.state; | |
| return ( | |
| <Layout> | |
| <Layout.Header>{LANGUAGE.finishGame}</Layout.Header> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Component from 'metal-jsx'; | |
| import Mathematics from './components/Mathematics'; | |
| class App extends Component { | |
| render() { | |
| const {lvlDefault, lvls, showResult, countdown} = this.state; | |
| return ( | |
| <Mathematics | |
| countdown={30} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Button from './Button'; | |
| export { Button }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Component from 'metal-jsx'; | |
| class Button extends Component {} | |
| export default Button; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Component, {Config} from 'metal-jsx'; | |
| class Button extends Component {} | |
| export default Button; |