constructor(props) {
super(props);
this.notification = new Notification();
- this.handleVarlamov = function(tips) {
- console.log(tips);
- return tips;
- }
this.gameController = new GameController(this.notification);
this.state = {
tips: this.gameController.tips(),
componentDidMount() {
this.gameController.createGame(this.props.city).then(() => this.gameController.loadTips()).then(() => {
this.setState({
- tips: this.handleVarlamov(this.gameController.tips()),
+ tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
loading: false,
inProcess: false
});
this.gameController.getMoreTips().then(() => {
this.setState({
- tips: this.handleVarlamov(this.gameController.tips()),
+ tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
})
});
this.gameController.goNorth().then(() => {
this.setState({
- tips: this.handleVarlamov(this.gameController.tips()),
+ tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
})
});
this.gameController.goWest().then(() => {
this.setState({
- tips: this.handleVarlamov(this.gameController.tips()),
+ tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
})
});
this.gameController.goSouth().then(() => {
this.setState({
- tips: this.handleVarlamov(this.gameController.tips()),
+ tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
})
});
this.gameController.goEast().then(() => {
this.setState({
- tips: this.handleVarlamov(this.gameController.tips()),
+ tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
})
startNewGame = () => {
window.location = '/';
- }
+ };
onMapClick = (e, map) => {
<h2 className="Game-tips-header">What you see:</h2>
{this.state.tips.length > 0 && (
<ul className="Game-tips-list">
- {this.state.tips.map(tip => <li key={tip}>{tip}</li>)}
+ {this.state.tips.map((tip, i) => <li key={tip + i}>{tip}</li>)}
</ul>
)}
export class GameController {
constructor(notification) {
+ this.varlamov = true;
this.notification = notification;
}
if(!this._tips) {
return [];
}
+ if(this.varlamov) {
+ const match = this._tips[this._tips.length - 1].match(/высотой в (.) этажей/);
+ if(match && match[1]) {
+ const num = parseInt(match[1], 10);
+ if(num > 5) {
+ const el = document.querySelector('.Game-frame');
+ if(el) {
+ el.classList.add('varlamov-on');
+ setTimeout(() => {
+ el.classList.remove('varlamov-on');
+ }, 10000);
+ this.varlamov = false;
+ }
+ }
+ }
+ }
return this._tips;
}