Permalink
Browse files

[Druid::Webapp] allowed game restart

  • Loading branch information...
1 parent 012f3d4 commit f6fb37017c7d298334095f3c6b15a85dfbf2bae1 @masak committed Oct 12, 2009
Showing with 10 additions and 3 deletions.
  1. +10 −3 lib/Druid/Webapp.pm
View
@@ -15,7 +15,7 @@ class Druid::Webapp does Callable {
my $board-size = 8;
my Druid::Game $game .= new(:size($board-size));
my Druid::View $view = Druid::View::Text.new(:$game);
- if $GAME_STATE_FILE ~~ :e {
+ if $GAME_STATE_FILE ~~ :e && !$req.GET.<restart> {
$game.melt(slurp($GAME_STATE_FILE));
}
@@ -34,8 +34,15 @@ class Druid::Webapp does Callable {
$view,
'</pre>',
'<p>';
- $res.write("<a href='?move=$_'>$_</a> ") for $game.possible-moves();
- $res.write('</p>');
+
+ if $game.finished {
+ $res.write('<a href="?restart=1">restart</a>');
+ }
+ else {
+ $res.write("<a href='?move=$_'>$_</a> ")
+ for $game.possible-moves();
+ $res.write('</p>');
+ }
$res.finish();
}
}

0 comments on commit f6fb370

Please sign in to comment.