});
};
- move = () => {
- this.gameController.goForward().then(() => {
+ moveNorth = () => {
+ this.gameController.goNorth().then(() => {
+ this.setState({
+ tips: this.handleVarlamov(this.gameController.tips())
+ })
+ }).catch(error => {
+ this.notification.show(
+ 'Что-то сломалось, зовите разраба',
+ error && JSON.stringify(error)
+ );
+ });
+ };
+
+ moveWest = () => {
+ this.gameController.goWest().then(() => {
+ this.setState({
+ tips: this.handleVarlamov(this.gameController.tips())
+ })
+ }).catch(error => {
+ this.notification.show(
+ 'Что-то сломалось, зовите разраба',
+ error && JSON.stringify(error)
+ );
+ });
+ };
+
+ moveSouth = () => {
+ this.gameController.goSouth().then(() => {
+ this.setState({
+ tips: this.handleVarlamov(this.gameController.tips())
+ })
+ }).catch(error => {
+ this.notification.show(
+ 'Что-то сломалось, зовите разраба',
+ error && JSON.stringify(error)
+ );
+ });
+ };
+
+ moveEast = () => {
+ this.gameController.goEast().then(() => {
this.setState({
tips: this.handleVarlamov(this.gameController.tips())
})
</Button>
</div>
<div className="Get-button">
- <Button onClick={this.move} size="medium">
- Пройти дальше
+ <Button onClick={this.moveWest} size="medium">
+ Пройти к западу
+ </Button>
+ </div>
+ <div className="Get-button">
+ <Button onClick={this.moveNorth} size="medium">
+ Пройти к северу
+ </Button>
+ </div>
+ <div className="Get-button">
+ <Button onClick={this.moveSouth} size="medium">
+ Пройти к югу
+ </Button>
+ </div>
+ <div className="Get-button">
+ <Button onClick={this.moveEast} size="medium">
+ Пройти к востоку
</Button>
</div>
</div>
});
}
- goForward() {
+ goNorth() {
+ return api.post(`/games/${this.gameId}/move/north`).then(json => {
+ this._tips = json.data.tips;
+ })
+ }
+
+ goWest() {
+ return api.post(`/games/${this.gameId}/move/west`).then(json => {
+ this._tips = json.data.tips;
+ })
+ }
+
+ goSouth() {
return api.post(`/games/${this.gameId}/move/south`).then(json => {
this._tips = json.data.tips;
})
}
+ goEast() {
+ return api.post(`/games/${this.gameId}/move/east`).then(json => {
+ this._tips = json.data.tips;
+ })
+ }
+
tips() {
if(!this._tips) {
return [];