-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from deanblackborough/main
Improved initial UX and Refactoring
- Loading branch information
Showing
39 changed files
with
2,342 additions
and
1,881 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,30 @@ | |
|
||
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.04.0] - [2023-10-12] | ||
### Added | ||
- Added full account deletion. | ||
- Added a getting started section for new sign-ups, allows the user to create players and begin a game in one go. | ||
### Changed | ||
- Updated Yahtzee account deletion, uses the API to delete the account rather than brute force. | ||
- Switched to action and view controllers. | ||
- Automatically sign-in the user after password creation. | ||
- Switched to the [email protected] email and removed Twitter from footer. | ||
- Updated content throughout the app. | ||
- Updated to Laravel 10 | ||
- Updated to Boostrap 5.3 | ||
- Updated to PHP8.2 | ||
|
||
## [v1.03.0] - [2023-07-03] | ||
### Added | ||
- Added Budget Pro to the footer | ||
### Changed | ||
- Updated the example ENV file | ||
- Updated dependencies | ||
- Set version and release date | ||
### Fixed | ||
- Corrected a link | ||
|
||
## [1.02.0] - [2023-01-30] | ||
### Changed | ||
- Updated authentication to match recent changes to the Costs to Expect API. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Account; | ||
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* https://github.com/costs-to-expect/yatzy/blob/main/LICENSE | ||
*/ | ||
class DeleteAccount | ||
{ | ||
public function __invoke( | ||
string $bearer_token, | ||
string $user_id, | ||
string $email | ||
): bool | ||
{ | ||
\App\Jobs\DeleteAccount::dispatch( | ||
$bearer_token, | ||
$user_id, | ||
)->delay(now()->addSeconds(5)); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Actions\Game; | ||
|
||
use App\Actions\Action; | ||
use App\Api\Service; | ||
use App\Models\ShareToken; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Str; | ||
|
||
/** | ||
* @author Dean Blackborough <[email protected]> | ||
* @copyright Dean Blackborough (Costs to Expect) 2018-2022 | ||
* https://github.com/costs-to-expect/yatzy/blob/main/LICENSE | ||
*/ | ||
class Start extends Action | ||
{ | ||
private array $players = []; | ||
|
||
public function __invoke(Service $api, string $resource_type_id, string $resource_id, array $input): int | ||
{ | ||
if (array_key_exists('players', $input) === false || $input['players'] === null || $input['players'] === '') { | ||
$this->message = 'Missing players'; | ||
$this->validation_errors['players'] = ['errors' => ['Please enter the player names, one per line']]; | ||
return 422; | ||
} | ||
|
||
$players = explode(PHP_EOL, $input['players']); | ||
|
||
if ($players === []) { | ||
$this->message = 'Missing players'; | ||
$this->validation_errors['players'] = ['errors' => ['Please enter the player names, one per line']]; | ||
return 422; | ||
} | ||
|
||
foreach ($players as $player) { | ||
$result = $this->createPlayer($api, $resource_type_id, $player); | ||
if ($result === false && $this->validation_errors !== []) { | ||
$this->message = 'Failed to create player'; | ||
$this->validation_errors['players'] = ['errors' => ['Failed to create player named "' . $player . '", is the a name taken by another player?']]; | ||
return 422; | ||
} | ||
} | ||
|
||
$create_game_response = $api->createGame( | ||
$resource_type_id, | ||
$resource_id, | ||
'Yatzy game', | ||
'Yatzy game create via the Yatzy app' | ||
); | ||
|
||
if ($create_game_response['status'] === 201) { | ||
|
||
$config = Config::get('app.config'); | ||
|
||
$this->game_id = $create_game_response['content']['id']; | ||
|
||
foreach ($this->players as $player_id) { | ||
$response = $api->addPlayerToGame( | ||
$resource_type_id, | ||
$resource_id, | ||
$this->game_id, | ||
$player_id | ||
); | ||
|
||
try { | ||
$token = new ShareToken(); | ||
$token->token = Str::uuid(); | ||
$token->game_id = $this->game_id; | ||
$token->player_id = $player_id; | ||
$token->parameters = json_encode([ | ||
'resource_type_id' => $resource_type_id, | ||
'resource_id' => $resource_id, | ||
'game_id' => $this->game_id, | ||
'player_id' => $player_id, | ||
'player_name' => $response['content']['category']['name'], | ||
'owner_bearer' => request()->cookie($config['cookie_bearer']) | ||
], JSON_THROW_ON_ERROR); | ||
$token->save(); | ||
} catch (\Exception) { | ||
abort(500, 'Failed to create share token for player, create token manually'); | ||
} | ||
} | ||
|
||
return 201; | ||
} | ||
|
||
$this->message = $create_game_response['content']; | ||
|
||
if ($create_game_response['status'] === 422) { | ||
$this->validation_errors = $create_game_response['fields']; | ||
return $create_game_response['status']; | ||
} | ||
|
||
return $create_game_response['status']; | ||
} | ||
|
||
protected function createPlayer($api, $resource_type_id, $player): bool | ||
{ | ||
$create_player_response = $api->createPlayer( | ||
$resource_type_id, | ||
$player, | ||
'New player - Added via the Yatzy App - Start' | ||
); | ||
|
||
if ($create_player_response['status'] === 422) { | ||
$this->validation_errors = $create_player_response['fields']; | ||
return false; | ||
} | ||
|
||
if ($create_player_response['status'] === 201) { | ||
$this->players[] = $create_player_response['content']['id']; | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.