Skip to content

Commit

Permalink
Trying to join a started game no more forward to 404 but displays a c…
Browse files Browse the repository at this point in the history
…omprehensive message
  • Loading branch information
ornicar committed Apr 21, 2010
1 parent 5248479 commit a6360c5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
11 changes: 8 additions & 3 deletions modules/dmChessGame/actions/actions.class.php
Expand Up @@ -152,9 +152,14 @@ public function executePlayWidget(dmWebRequest $request)
}
elseif($gameCode = $request->getParameter('g', $request->getParameter('game')))
{
$this->forward404Unless($player = dmDb::table('DmChessPlayer')->joinGameByCode($gameCode));

return $this->redirect($this->getHelper()->link($this->getPage())->param('p', $player->code)->getHref());
if($player = dmDb::table('DmChessPlayer')->joinGameByCode($gameCode))
{
return $this->redirect($this->getHelper()->link($this->getPage())->param('p', $player->code)->getHref());
}
else
{
$request->setParameter('dm_chess_full_game', 1);
}
}
else
{
Expand Down
6 changes: 5 additions & 1 deletion modules/dmChessGame/actions/components.class.php
Expand Up @@ -9,7 +9,11 @@ class dmChessGameComponents extends myFrontModuleComponents

public function executePlay(dmWebRequest $request)
{
if(!$this->getServiceContainer()->hasParameter('dm_chess.player'))
if($request->getParameter('dm_chess_full_game'))
{
$this->gameIsFull = true;
}
elseif(!$this->getServiceContainer()->hasParameter('dm_chess.player'))
{
$this->justInstalled = true;
}
Expand Down
13 changes: 13 additions & 0 deletions modules/dmChessGame/templates/_gameIsFull.php
@@ -0,0 +1,13 @@
<?php

echo _tag('div.dm_chess_game_is_full',

_tag('h1.title', 'This game has 2 players').

_media('/dmChessPlugin/images/piece/sprite.png').

_tag('p', 'You cannot join this chess game, because it is already started!').

_link($dm_page)->text(__('Start a new game'))->currentSpan(false)->title(false)

);
8 changes: 7 additions & 1 deletion modules/dmChessGame/templates/_play.php
@@ -1,6 +1,12 @@
<?php

if(isset($justInstalled))
if(isset($gameIsFull))
{
// Someone tries to join a game that already has 2 players
include_partial('dmChessGame/gameIsFull');
return;
}
elseif(isset($justInstalled))
{
// The widget has just been dropped, page needs to be reloaded
include_partial('dmChessGame/justInstalled');
Expand Down
2 changes: 1 addition & 1 deletion modules/dmChessGame/templates/_tableFinished.php
Expand Up @@ -19,6 +19,6 @@

_tag('div.dm_chess_separator').

_link($dm_page)->text(__('Start a new game'))->currentSpan(false)
_link($dm_page)->text(__('Start a new game'))->currentSpan(false)->title(false)

);

0 comments on commit a6360c5

Please sign in to comment.