This repository has been archived by the owner on Apr 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
[RFR] Setup the multiplayer game #15
Open
Luwangel
wants to merge
19
commits into
master
Choose a base branch
from
multiplayer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a054b2d
Setup multiplayer
Luwangel 27d2464
Display the list of open multiplayer games in the main page
Luwangel 1fd93a4
Write the tests
Luwangel 8478f5e
Fix the tests
Luwangel 081b6f4
Define new routes for the api
Luwangel 67ce6cc
Create a new controller for api routes
Luwangel 2dc038f
Change route methods according to the review
Luwangel ec49226
Make player and game entities serializable
Luwangel 82ae317
Change the context resolvers to accept the authorization's header
Luwangel 3755991
Merge pull request #16 from marmelab/expose_api
djhi c84b3ec
Apply the reviews
Luwangel b43fee9
Fix the api controller
Luwangel 404e630
Fix the api
Luwangel 51711db
Add a cors module
Luwangel 7d9859f
Allow preflight requests
Luwangel b299f5c
Let the cors service manage the preflight requests
Luwangel 9559be5
Apply the reviews
Luwangel ea751d8
Fix join a game
Luwangel 71f3380
Merge pull request #17 from marmelab/fix_api
fzaninotto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Authentication; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use App\Entity\Game; | ||
use App\Entity\Player; | ||
|
||
class TokenAuthManager { | ||
public static function isPlayer(Request $request, Game $game, string $token) : bool { | ||
$player1 = $game->getPlayer1(); | ||
$player2 = $game->getPlayer2(); | ||
return $player1->getToken() == $token || !$game->isFull() && $player2->getToken() == $token; | ||
} | ||
|
||
public static function getPlayer(Request $request, Game $game, string $token) { | ||
if ($game->getIsMultiplayer() && $game->getPlayer2() && $game->getPlayer2()->getToken() == $token) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. === |
||
return $game->getPlayer2(); | ||
} | ||
return $game->getPlayer1(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for === (checks type too)