From: Vladislav Skukov Date: Sun, 19 May 2019 04:31:22 +0000 (+0500) Subject: buttons with all directions X-Git-Url: https://git.xn--bdkaa.com/?a=commitdiff_plain;h=6ff816c8a1b2f82bb30fe002a711827d0b938c78;p=where-are-you.py.git buttons with all directions --- diff --git a/src/Game.js b/src/Game.js index c4d46e2..5ddf95e 100644 --- a/src/Game.js +++ b/src/Game.js @@ -52,8 +52,47 @@ export class Game extends Component { }); }; - 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()) }) @@ -111,8 +150,23 @@ export class Game extends Component {
- +
+
+ +
+
+ +
+
+
diff --git a/src/GameController.js b/src/GameController.js index 7ad696e..0546f29 100644 --- a/src/GameController.js +++ b/src/GameController.js @@ -18,12 +18,30 @@ export class GameController { }); } - 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 [];