Permalink
Browse files

adapted for generality

  • Loading branch information...
1 parent 1e18302 commit 8972fe5162dce4ab75cce0c9c68c9bb6080ccb05 @polettix committed Oct 1, 2012
Showing with 12 additions and 5 deletions.
  1. +10 −1 lib/Narsil/Frontend.pm
  2. +0 −2 views/games/battleship/play.tt
  3. +2 −0 views/match.tt
  4. +0 −2 views/mobile/index.tt
View
@@ -228,6 +228,8 @@ get '/match/:id' => sub {
warning Dumper($game);
my $gameid = $game->{id};
my $template = "games/$gameid";
+ my @movers = map { $_->[0] } @{$match->{movers}};
+ my @winners = map { $_->[0] } @{$match->{winners}};
try {
my $class = "Narsil::Frontend::$gameid";
(my $package = $class . '.pm') =~ s{(?: :: | ')}{/}gmxs;
@@ -237,7 +239,14 @@ get '/match/:id' => sub {
catch {
warning $_;
};
- template match => {string => to_json({ %$game, }), subtemplate => $template, %$match, game => $game};
+ template match => {
+ string => to_json({ %$game, }),
+ subtemplate => $template,
+ %$match,
+ game => $game,
+ movers => \@movers,
+ winners => \@winners,
+ };
};
post '/match' => sub {
@@ -1,5 +1,3 @@
-<p><% IF active_player %><strong><% active_player | html %></strong> to move<% ELSE %><strong><% match.winners.0.0 %></strong> won the match<% END %></p>
-
<div id="battleboat">
<div id="upper">
<table class="battleboat">
View
@@ -1,2 +1,4 @@
<h2 class="gametitle"><% game.name %></h2>
+<% IF movers.size > 0 && match.phase != 'terminated' %><p style="margin-bottom: 1em;"><strong><% movers.join(', ') %></strong> to move</p><% END %>
+<% IF winners.size > 0 %><p style="margin-bottom: 1em;"><strong><% winners.join(', ') %></strong> won the match</p><% END %>
<% INCLUDE $subtemplate %>
View
@@ -1,5 +1,3 @@
-<pre><% string %></pre>
-
<% IF session.user %>
<div class="matches">
<% IF matches.matches.size %>

0 comments on commit 8972fe5

Please sign in to comment.