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; } }