Skip to content

Commit

Permalink
Merge pull request #40 from deanblackborough/bugs
Browse files Browse the repository at this point in the history
Bugs
  • Loading branch information
deanblackborough authored Aug 25, 2022
2 parents 07c14cd + 9a51125 commit 192258f
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 307 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

The complete changelog for the Costs to Expect REST API, our changelog follows the format defined at https://keepachangelog.com/en/1.0.0/

## [1.05.0] - [2020-08-13]
## [1.05.1] - [2022-08-25]
### Changed
- Minor change to the width of the authentication forms.
- Corrected a method name in the base controller.
### Fixed
- Validation errors on create password removed token from URI stopping the creation of the password.
- Offcanvas unable to be invoked on closed games.
- Removed default values in `App\Api\Service class`, should be using the values from the .env file.
- Corrected a bonus message if you score 63 with fewer than 5 dice.

## [1.05.0] - [2022-08-13]
### Added
- Added logging, scoring actions are logged in the API, the data will be used later for multiple features.
### Changed
Expand Down
8 changes: 6 additions & 2 deletions app/Api/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace App\Api;

use Illuminate\Support\Facades\Config;
use JetBrains\PhpStorm\ArrayShape;

/**
Expand All @@ -14,12 +15,15 @@ class Service
{
private Http $http;

private string $item_type_id = '2AP1axw6L7';
private string $item_subtype_id = '3JgkeMkB4q';
private string $item_type_id;
private string $item_subtype_id;

public function __construct(string $bearer = null)
{
$this->http = new Http($bearer);

$this->item_type_id = Config::get('app.config.item_type_id');
$this->item_subtype_id = Config::get('app.config.item_subtype_id');
}

#[ArrayShape(['status' => "integer", 'content' => "array", 'fields' => "array"])]
Expand Down
14 changes: 12 additions & 2 deletions app/Http/Controllers/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,22 @@ public function createPasswordProcess(Request $request)
}

if ($response['status'] === 422) {
return redirect()->route('create-password.view')
return redirect()->route(
'create-password.view',
[
'email' => $request->input('token'),
'token' => $request->input('email')
])
->withInput()
->with('authentication.errors', $response['fields']);
}

return redirect()->route('create-password.view')
return redirect()->route(
'create-password.view',
[
'email' => $request->input('token'),
'token' => $request->input('email')
])
->with('authentication.failed', $response['content']);
}

Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct()
$this->item_subtype_id = $this->config['item_subtype_id'];
}

protected function boostrap(Request $request)
protected function bootstrap(Request $request)
{
$this->api = new Service($request->cookie($this->config['cookie_bearer']));

Expand Down Expand Up @@ -191,7 +191,7 @@ protected function playerBonusMessage(string $game_id, string $player_id, array
}
}

if ($total > 63 && (count($dice_scored) + count($dice_scratched)) < 6) {
if ($total >= 63 && count($dice_scored) < 6) {
$message = 'OK, OK, you have the bonus without even finishing!';
return $this->playerBonusView($game_id, $player_id, $message);
}
Expand Down Expand Up @@ -226,7 +226,7 @@ protected function playerBonusMessage(string $game_id, string $player_id, array
return $this->playerBonusView($game_id, $player_id, $message);
}

if ($total > 63 && count($dice_scratched) > 0) {
if ($total >= 63 && count($dice_scratched) > 0) {
$message = 'WOW, nothing like scoring the bonus whilst also scratching!';
return $this->playerBonusView($game_id, $player_id, $message);
}
Expand Down
30 changes: 15 additions & 15 deletions app/Http/Controllers/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Game extends Controller
{
public function index(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$offset = (int) $request->query('offset', 0);
$limit = (int) $request->query('limit', 10);
Expand Down Expand Up @@ -61,7 +61,7 @@ public function index(Request $request)

public function show(Request $request, $game_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$game = $this->api->getGame(
$this->resource_type_id,
Expand Down Expand Up @@ -100,7 +100,7 @@ public function show(Request $request, $game_id)

public function newGame(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$players_response = $this->api->getPlayers($this->resource_type_id, ['collection' => true]);

Expand Down Expand Up @@ -129,7 +129,7 @@ public function newGame(Request $request)

public function newGameProcess(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$action = new Create();
$result = $action(
Expand All @@ -154,7 +154,7 @@ public function newGameProcess(Request $request)

public function addPlayersToGame(Request $request, string $game_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$game_response = $this->api->getGame(
$this->resource_type_id,
Expand Down Expand Up @@ -220,7 +220,7 @@ public function addPlayersToGame(Request $request, string $game_id)

public function addPlayersToGameProcess(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$game_id = $request->route('game_id');

Expand Down Expand Up @@ -248,7 +248,7 @@ public function addPlayersToGameProcess(Request $request)

public function complete(Request $request, string $game_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$action = new Complete();
try {
Expand All @@ -271,7 +271,7 @@ public function complete(Request $request, string $game_id)

public function completeAndPlayAgain(Request $request, string $game_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$action = new Complete();
try {
Expand Down Expand Up @@ -329,7 +329,7 @@ public function completeAndPlayAgain(Request $request, string $game_id)

public function deleteGame(Request $request, string $game_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$action = new Delete();
try {
Expand All @@ -352,7 +352,7 @@ public function deleteGame(Request $request, string $game_id)

public function deleteGamePlayer(Request $request, string $game_id, string $player_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$action = new DeletePlayer();
try {
Expand All @@ -376,7 +376,7 @@ public function deleteGamePlayer(Request $request, string $game_id, string $play

public function playerBonus(Request $request, string $game_id, string $player_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$game_response = $this->api->getGame(
$this->resource_type_id,
Expand Down Expand Up @@ -406,7 +406,7 @@ public function playerBonus(Request $request, string $game_id, string $player_id

public function playerScores(Request $request, string $game_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$players_response = $this->api->getAssignedGamePlayers(
$this->resource_type_id,
Expand Down Expand Up @@ -440,7 +440,7 @@ public function playerScores(Request $request, string $game_id)

public function scoreSheet(Request $request, string $game_id, string $player_id)
{
$this->boostrap($request);
$this->bootstrap($request);

$game_response = $this->api->getGame(
$this->resource_type_id,
Expand Down Expand Up @@ -508,7 +508,7 @@ public function scoreSheet(Request $request, string $game_id, string $player_id)

public function scoreUpper(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$score_sheet = $this->api->getPlayerScoreSheet(
$this->resource_type_id,
Expand Down Expand Up @@ -568,7 +568,7 @@ public function scoreUpper(Request $request)

public function scoreLower(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$score_sheet = $this->api->getPlayerScoreSheet(
$this->resource_type_id,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Index extends Controller
{
public function home(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$open_games_response = $this->api->getGames(
$this->resource_type_id,
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Player extends Controller
{
public function index(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$players_response = $this->api->getPlayers($this->resource_type_id, ['collection' => true]);

Expand All @@ -39,7 +39,7 @@ public function index(Request $request)

public function newPlayer(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

return view(
'new-player',
Expand All @@ -54,7 +54,7 @@ public function newPlayer(Request $request)

public function newPlayerProcess(Request $request)
{
$this->boostrap($request);
$this->bootstrap($request);

$action = new Create();
$result = $action($this->api, $this->resource_type_id, $request->only(['name', 'description']));
Expand Down
Loading

0 comments on commit 192258f

Please sign in to comment.