Skip to content

Commit

Permalink
Добавлена обработка события "окончания игры".
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbelikov committed Nov 14, 2016
1 parent 8596430 commit 5f65c14
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
9 changes: 9 additions & 0 deletions handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
3 changes: 3 additions & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@

case 5:
$('#next').prop('disabled', true);
sendRequest('nextStep', {step: 5}, function (data) {
notify('Action "' + data.actionLabel + '" is saved.');
});
break;
}
}
Expand Down

0 comments on commit 5f65c14

Please sign in to comment.