From 5f65c14c13525dcda8d1b1f4255be252ee99d207 Mon Sep 17 00:00:00 2001 From: Igor Belikov Date: Mon, 14 Nov 2016 05:39:14 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D1=8F=20"=D0=BE?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=87=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=B3?= =?UTF-8?q?=D1=80=D1=8B".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Game.php | 9 +++++++++ handlers.php | 9 +++++++++ public/js/app.js | 3 +++ 3 files changed, 21 insertions(+) diff --git a/app/Game.php b/app/Game.php index 55ce2f9..cf1be02 100644 --- a/app/Game.php +++ b/app/Game.php @@ -60,6 +60,15 @@ public function markAsHeavy($index) return false; } + /** + * @return bool + */ + public function end() + { + $action = $this->log->createAction(GameLog::ACTION_END, $this->getId()); + return $action; + } + /** * @return int */ diff --git a/handlers.php b/handlers.php index 8e6b790..9434bd4 100644 --- a/handlers.php +++ b/handlers.php @@ -36,4 +36,13 @@ 'balls' => $game->ballManager->balls, 'actionLabel' => GameLog::getLabels(GameLog::ACTION_CHANGE_HEAVY_BALL) ], $game->markAsHeavy($_POST['index'])); +} + +if (isset($_POST['action'], $_POST['step']) && $_POST['action'] == 'nextStep') +{ + if ($_POST['step'] == 5) { + echo new Response([ + 'actionLabel' => GameLog::getLabels(GameLog::ACTION_END) + ], $game->end()); + } } \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js index 22dc57d..c03b0bf 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -206,6 +206,9 @@ case 5: $('#next').prop('disabled', true); + sendRequest('nextStep', {step: 5}, function (data) { + notify('Action "' + data.actionLabel + '" is saved.'); + }); break; } }