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