<% $t->{title}{showtag} = 0; $t->set( 'log' => { pre => '
', post => "
\n", } ); $t->set( 'entry' => { pre => '
', post => '
', } ); %> perlwar - <%~ /perlwar/configuration/title %>

<%= apply_templates( '/perlwar/configuration/title' ) %>

PerlWar
<% my $iteration = findvalue( '/perlwar/iteration/@nbr' ) || 0 %> iteration <%= $iteration %>

<% my %players = ( '' => { color => 'lightgrey' } ); if ( $iteration > 0 ) { for( findnodes( '/perlwar/iteration/summary/player' ) ) { my $name = $_->findvalue('@name'); $players{ $name } = { color => $_->getAttribute( 'color' ) }; $players{ $name }{status} = $_->getAttribute( 'status' ); $players{ $name }{score} = $_->getAttribute( 'agents' ); } } else { if ( findvalue( '/perlwar/configuration/players/@list' ) eq 'predefined' ) { for( findnodes( '/perlwar/configuration/players/player' ) ) { my $name = $_->findvalue('@name'); $players{ $name } = { color => $_->getAttribute( 'color' ) }; $players{ $name }{status} = 'OK'; $players{ $names }{score} = 0; } } else { my( $file ) = findvalue( '/perlwar/configuration/players/@community' ); @player_nodes = grep { -e 'mobil/'.$_->findvalue( '@name' ) } XML::LibXML->new ->parse_file( $file ) ->findnodes( '//player' ); for( @player_nodes ) { my $name = $_->findvalue('@name'); $players{ $name } = { color => $_->getAttribute( 'color' ) }; $players{ $name }{status} = 'OK'; $players{ $names }{score} = 0; } } } sub get_players { } %> <% my %subm; for( grep $_, keys %players ) { my $t = -M "mobil/$_" or next; $subm{ $_ } = $^T - $t*24*60*60; } my @order = sort { $subm{$a} <=> $subm{$b} } keys %subm; for( 1..@order ) { my $x = $order[$_-1]; $subm{$x} = "$_"; } %> <% for( sort { $players{$b}{score} <=> $players{$a}{score} } keys %players ) { next unless $_; %>
> <%= $_ %> <%= $subm{$_} %> <%= $players{$_}{score} || "0" %>
<% } %>
<% my $fill = length findvalue( '/perlwar/configuration/theArraySize/text()' ); for( 0..findvalue( '/perlwar/configuration/theArraySize/text()' ) -1 ) { %>
' onclick="showSlot(<%= $_ %>)"> <% my $owner = findvalue( "/perlwar/round/theArray/slot[\@id = $_]/owner/text()" ); my $facade = findvalue( "/perlwar/round/theArray/slot[\@id = $_]/facade/text()" ); $facade_color = $players{ $facade }{ color }; $has_facade = $facade and $facade ne $owner; %> <%# $owner.":".$facade.":".$has_facade.":".$facade_color %> <%= "" x !!$has_facade %> <%= sprintf "%0${fill}d", $_ %> <%= '' x !!$has_facade %>
<% } %>
<%= apply_templates( '/perlwar/iteration/log' ) %> <% $t->set( 'agent' => { testcode => \&tc_slot, } ); sub tc_slot { my( $n, $t ) = @_; my $id = $n->findvalue( '@position' ); my $code = $n->findvalue( 'text()' ); $t->set({ pre => "
$code
\n" }); return DO_SELF_ONLY; } %> <% for my $i ( 0..findvalue( '//gameLength/text()' )-1 ) { my( $agent ) = findnodes( "//theArray/agent[\@position = $i ]" ); my $code = $agent ? $agent->findvalue( 'text()' ) : 'empty cell'; %>
<%= $code %>
<% } %>