hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
};
+
+ this.noKeys = true;
+
+ document.onkeyup = e => {
+ if(this.noKeys) {
+ return;
+ }
+ if (e.code === 'ArrowUp') {
+ return this.moveNorth();
+ }
+ if (e.code === 'ArrowRight') {
+ return this.moveEast();
+ }
+ if (e.code === 'ArrowLeft') {
+ return this.moveWest();
+ }
+ if (e.code === 'ArrowDown') {
+ return this.moveSouth();
+ }
+ if (e.code === 'Enter') {
+ return this.askTip();
+ }
+ if (e.code === 'Space') {
+ return this.askTip();
+ }
+ if (e.code === 'KeyK') {
+ return this.moveNorth();
+ }
+ if (e.code === 'KeyL') {
+ return this.moveEast();
+ }
+ if (e.code === 'KeyH') {
+ return this.moveWest();
+ }
+ if (e.code === 'KeyJ') {
+ return this.moveSouth();
+ }
+ };
}
componentDidMount() {
+ this.noKeys = true;
this.gameController.createGame(this.props.city).then(() => this.gameController.loadTips()).then(() => {
this.setState({
tips: this.gameController.tips(),
inProcess: false
}, () => {
createMap('map', this.onMapClick, this.gameController.getBoundaries());
+ this.noKeys = false;
})
}).catch(error => {
this.notification.show(
}
askTip = () => {
+ this.noKeys = true;
this.setState({
inProcess: true
});
tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
+ }, () => {
+ this.noKeys = false;
})
}).catch(error => {
this.setState({
};
moveNorth = () => {
+ this.noKeys = true;
this.setState({
inProcess: true
});
tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
+ }, () => {
+ this.noKeys = false;
})
}).catch(error => {
this.notification.show(
};
moveWest = () => {
+ this.noKeys = true;
this.setState({
inProcess: true
});
tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
+ }, () => {
+ this.noKeys = false;
})
}).catch(error => {
this.notification.show(
};
moveSouth = () => {
+ this.noKeys = true;
this.setState({
inProcess: true
});
tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
+ }, () => {
+ this.noKeys = false;
})
}).catch(error => {
this.notification.show(
};
moveEast = () => {
+ this.noKeys = true;
this.setState({
inProcess: true
});
tips: this.gameController.tips(),
hasMoreTips: this.gameController.hasMoreTips(),
inProcess: false
+ }, () => {
+ this.noKeys = false;
})
}).catch(error => {
this.notification.show(