fixed bug: missing $escmode in field.epl
[aymargeddon/current.git] / html / player.epl
1 [- use FROGS::Config qw($conf); -]
2 <html>
3 <head><link rel="stylesheet" type="text/css" href="aymargeddon.css">
4 <title>Aymargeddon</title></head>
5 [-
6  $| = 1;
7   $udat{-current} = 'player.epl';
8         
9   use Aymargeddon;
10  use Data::Dumper;
11   $db = DataBase->new();
12   $id = 0;
13   if($udat{-id}){
14     $id = $udat{-id};
15   }else{
16     $id = $db->authenticate($fdat{'login'},$fdat{'passwd'},
17                             $fdat{'passwd2'},$fdat{'passwd3'});
18   }
19  if($udat{-lang}){
20    $db->set_language($udat{-lang});
21    #set language in Database in PLAYER.LANGUAGE
22    $db->update_hash('PLAYER',"PLAYER=$id",{'LANGUAGE' => $udat{-lang}});
23    $db->commit();
24  }else{
25   # set language according to PLAYER.LANGUAGE
26   # read_player() returns the first DB line in ARRAY format
27   ($udat{-lang}) = $db->read_player($id,'LANGUAGE');
28  }
29
30   $escmode = 0;
31
32  # TODO: klappt nich :-(
33  # $out = '<body style="font-size:10pt" bgcolor="'.$conf->{-COLOR}->{-EMPTY}.'">';
34  $out = '<body style="line-height:12pt;font-size:10pt">';
35 -]
36 [+$out+]
37
38 [$ if $id $] [# logged in - show game list, messages, etc. pp. #]
39
40   [-
41     $udat{-id} = $id;
42
43     # switch game-id
44     $udat{-game} = $fdat{'game'} if exists $fdat{'game'};
45     $aym = Aymargeddon->new($udat{-game},$id,$db) if exists $udat{-game};
46
47     if(exists $fdat{'game'}){
48       $udat{-loc} = $aym->startfield();
49       $udat{-loc} =~ /^(\d+)\_(\d+)$/;
50       my ($x,$y) = ($1, $2);
51       my $size = $aym->get_size();
52       $udat{-xoff} = $x -$size;
53       $udat{-yoff} = $y;
54     }
55
56
57
58     # register for selected role in game
59     if($fdat{'role'} and $fdat{'charname'}){
60       my $return = $aym->new_role($fdat{'role'},
61                                   $fdat{'charname'},
62                                   $fdat{'gender'});
63       #      $fdat{'description'});
64       unless($return){
65         print OUT "<strong>Error: cant register role.</strong><p>";
66       }
67     }
68
69    # delete all messages if wanted.
70    # TODO: write timestamp in link and delete only to this time
71    if($fdat{delete_all_messages} == 1){
72      $aym->delete_all_messages($fdat{time});
73      $db->commit();
74    }
75
76     Execute("menu.epl");
77
78     $own_games = $db->games_of_player($id);
79     $open_games = $db->open_games("HOME=-1");
80
81     %such = ();
82     for my $og (@$own_games){
83       $such{$og->[0]} = 1;
84     }
85
86     @real_open_games = ();
87     for $og (@$open_games){
88       push @real_open_games, $og unless exists $such{$og->[0]};
89     }
90     Util::log("real open games: ". Dumper(\@real_open_games), 2);
91     ($rn) = $db->read_player($id, 'REALNAME') unless exists $udat{-game};
92   -]
93
94   [$ if not exists $udat{-game} $]
95   <hr>
96   [+ $db->loc('PLAYER_WELCOME').' Aymargeddon '.$rn +]!<p>
97   [$ endif $]
98
99   <hr>
100   <table width=100% border=0><colgroup><col width="200"><col></colgroup>
101   <tr><td valign="top" bgcolor="#b8a266">
102   <p>[+ $db->loc('PLAYER_OWN_GAMES') +]<p>
103   [$ foreach $og (@$own_games) $]
104     [- $og = $og->[0]; ($og_name) = $db->read_game($og,'NAME'); -]
105     <a href="player.epl?game=[+$og+]">[+$og_name+]</a><p>
106   [$ endforeach $]
107   [$ if $#{@$own_games} < 0 $]
108     [+ $db->loc('PLAYER_GAMES_NONE') +]<p>
109   [$ endif $]
110   <hr>
111   <p>[+ $db->loc('PLAYER_OPENGAMES') +]:<p>
112   [$ foreach $og (@real_open_games) $]
113     [- ($og_name) = $db->read_game($og,'NAME'); -]
114     <a href="player.epl?game=[+$og+]">[+$og_name+]</a><p>
115   [$ endforeach $]
116   [$ if $#{@real_open_games} < 0 $]
117     [+ $db->loc('PLAYER_GAMES_NONE') +]<p>
118   [$ endif $]
119   <hr></td>
120   <td valign="top" bgcolor="#fcffd9">
121   [$ if not exists $udat{-game} $]
122
123     [+ $db->loc('PLAYER_CHOOSE_GAME') +]
124
125   [$ elsif exists $fdat{'cmd'} $]
126    [- Execute('command_frames.epl') -]
127   [$ elsif $such{$udat{-game}} $]
128    <center>
129
130     [# [-
131       ($gn) = $db->read_game($udat{-game},'NAME');
132       my @list = $aym->charname($udat{-id});
133       $cn = $list[0];
134     -]
135     [+ $db->loc('PLAYER_WELCOME') +] <strong>[+ $gn +]</strong>, [+ $cn +].<p>
136     <hr> #]
137
138
139     [-
140       $messages = $aym->read_messages();
141      $now = $db->now();
142      -]
143    <strong>[+ $db->loc('PLAYER_MESSAGES_HEADING') +]</strong><p>
144     <a href="player.epl?delete_all_messages=1&time=[+$now+]">
145    [+ $db->loc('PLAYER_DELETE_MESSAGES')+]</a><p>
146     [$ foreach $msg (@$messages) $]
147       [+ $aym->show_message($msg->[0]) +]<br>
148     [$ endforeach $]
149     [$ if $#{@$messages} < 0 $]
150       [+ $db->loc('PLAYER_NO_MESSAGE') +]
151     [$ endif $]
152      <p>
153 [# we dont show events in a global list any more
154      <strong>[+ $db->loc('PLAYER_EVENTS') +]</strong><p>
155     [-
156       $events = $aym->role_events();
157      -]
158     [$ foreach $e (@$events) $]
159       [+ $aym->show_event($e->{'ID'}) +]<p>
160     [$ endforeach $]
161     [$ if $#{@$events} < 0 $]
162       [+ $db->loc('PLAYER_NO_EVENTS') +]<p>
163     [$ endif $]
164 #]
165      <strong>[+ $db->loc('PLAYER_STATISTIC') +]</strong><p>
166      [+ $aym->show_statistic() +]
167     <p><a href="mapframe.epl">[+ $db->loc('PLAYER_TO_MAP') +]</a>
168    </center>
169   [$ else $]
170     [- Execute('role_select.epl'); -]
171   [$ endif $]
172   </td></tr></table>
173 [$ else $] [# wrong login #]
174
175   [- Execute("menu.epl"); -]
176   <p><p>[+ $db->loc('LOGIN_FAILED') +]<p>
177   [- print OUT $db->loc('ERROR_NO_LOGIN'); -]
178
179 [$ endif $]
180 </body></html>
181
182