fixed bug in player.epl, looks like now we can choose games and see a
[aymargeddon/current.git] / html / field.epl
1 <html>
2 <head><link rel="stylesheet" type="text/css" href="aymargeddon.css">
3 </head>
4 <body>
5 [$ if exists $fdat{'x'} and exists $fdat{'y'} $]
6   [- $udat{-loc} = $fdat{'x'}.'_'.$fdat{'y'}; -]
7 [$ endif $]
8
9 [$ if exists $udat{-id} and exists $udat{-game} and $udat{-loc} $]
10
11 [-
12  use FROGS::HexTorus;
13  use Aymargeddon;
14
15  my $game = $udat{-game};
16  my $user = $udat{-id};
17  my $loc = $udat{-loc};
18
19  my $db = DataBase->new();
20  my $aym = Aymargeddon->new($game,$user,$db);
21  $db->set_language($udat{-lang});
22
23  # maybe you cant see this field (for hackers, which try to look direct
24  # in the field via url)
25  unless ($aym->sight_of_field($loc)){
26    print OUT "Mogeln gildet nich!\n";
27  } else {
28
29    my ($ter,$own,$occ,$temple,$plague) =
30      $aym->read_field('TERRAIN,HOME,OCCUPANT,TEMPLE,PLAGUE',$loc);
31
32    #####################
33    # general field info
34    #####################
35
36    $out .= $db->loc('FIELD_'.$ter).' '.Location::pretty($loc).' '.
37      $db->loc('PREP_IS_SG').' ';
38    if ($occ) {
39      $out .= $db->loc('OCCUPIED').' ';
40      if ($occ==$user) {
41        # it is our own field
42        $out .= $db->loc( ($aym->gender($occ) eq 'PLURAL') ? 
43                          'PPRO_DAT3_PL' : 'PPRO_DAT3_SG' );
44      } else {
45        # the field belongs to someone else
46        $out .= $db->loc('ART_DAT_PL').' ' if $aym->gender($occ) eq 'PLURAL';
47        $out .= $aym->charname($occ).' (<a href="command.epl?cmd=CH_STATUS&other='.
48          $occ.'">'.$aym->relation_string($occ).
49            '</a>, <a href="command.epl?cmd=SEND_MSG&other='.$occ.'">'.
50               $db->loc('SEND_MESSAGE').'</a>)';
51      }
52    } else {
53      $out .= $db->loc('NOT_OCCUPIED');
54    }
55    $out .= ".\n";
56
57    if ($own > 0) {
58      # some fields have some specials
59      if ($ter eq 'CITY') {
60        $out .= $db->loc('HOMECITY');
61      } elsif ($temple eq 'Y') {
62        $out .= $db->loc('TEMPLE');
63      } elsif ($ter eq 'MOUNTAIN') {
64        $out .= $db->loc('HOMEHOLY');
65      }
66      if($ter ne 'ISLE' or $temple eq 'Y'){
67        $out .= ' '.$db->loc('PREP_OWN_SG').' ';
68        if ($own==$user) {
69          $out .= $db->loc( ($aym->gender($own) eq 'PLURAL') ? 
70                            'PPRO_DAT3_PL' : 'PPRO_DAT3_SG' );
71        } elsif ($occ == $own) {
72          my $gen = $aym->gender($own);
73          $out .= $db->loc( ($gen eq 'PLURAL') ? 'PPRO_DAT_PL' : 
74                          (($gen eq 'MALE') ? 'PPRO_DAT_M' : 'PPRO_DAT_F') );
75        } else {
76          $out .= $db->loc('ART_DAT_PL').' ' if $aym->gender($own) eq 'PLURAL';
77          $out .= $aym->charname($own).' (<a href="command.epl?cmd=CH_STATUS&other='.
78            $own.'">'.$aym->relation_string($own).
79            '</a>, <a href="command.epl?cmd=SEND_MSG&other='.$own.'">'.
80              $db->loc('SEND_MESSAGE').'</a>)';
81        }
82        $out .= '.';
83      }
84    }
85    $out .= $db->loc('PLAGUE_IN_FIELD',lc($plague)) if $plague;
86    $out .= "<p>\n";
87
88    ###################
89    # show the mobiles
90    ###################
91
92    $mob = $aym->mobiles_available($loc);
93    $mobcount = $#{@$mob}+1;
94
95    if ($mobcount) {
96      $out .= $db->loc('ADJ_HERE').' ';
97      $out .= $db->loc( ($mobcount == 1 and @{$mob->[0]}[4] == 1) ?
98                        'PREP_IS_SG' : 'PREP_IS_PL' );
99
100      $out .= ($mobcount > 1) ? ":\n<p>" : ' ';
101      foreach $i (0..$mobcount-1) {
102        my ($oid,$otype,$oown,$oado,$ocnt,$ostat,$omove) = @{$mob->[$i]};
103        # check for MOVE_WITH
104        next if $omove;
105        $out .= $aym->mobile_to_html( $loc,$own,$occ,$temple,$ter, @{$mob->[$i]});
106         
107        my $transports = 0;
108        foreach $j (0..$mobcount-1) {
109          ($xid,$xtype,$xown,$xado,$xcnt,$xstat,$xmove) = @{$mob->[$j]};
110          if ($xmove == $oid) {
111            if (!$transports) {
112              $out .= ', '.$db->loc('MSG_TRANSPORTS').":<ul>\n";
113              $transports = 1;
114            }
115            $out .= '<li>'.
116              $aym->mobile_to_html( $loc,$own,$occ,$temple,$ter, @{$mob->[$j]})."</li>\n";
117          }
118        }
119        if ($transports) {
120          $out .= '</ul>';
121        } else {
122          $out .= ($i < $mobcount-1) ? ',' : '.';
123          $out .= "\n<p>";
124        }
125      } # end foreach $mobcount
126    }
127
128    ##################################
129    # general commands for this field:
130    ##################################
131
132    if ($aym->is_earthling($user)) {
133      $out .= "\n<p><a href=\"command.epl?cmd=DIE_ORDER\">".
134        $db->loc('CMD_DIE_ORDER').'</a>';
135    }
136    if ($aym->is_god($user)) {
137      if ($aym->is_arrival($loc)) {
138        $out .= "\n<p><a href=\"command.epl?cmd=INCARNATE&loc=$loc\">".
139          $db->loc('CMD_INCARNATE').'</a>';
140      }
141      if($aym->is_coast($loc)){
142        $out .= "\n<p><a href=\"command.epl?cmd=BUILD_ARK&loc=$loc\">".
143          $db->loc('CMD_BUILD_ARK').'</a>';
144        if($ter ne 'CITY'){
145          $out .= "\n<p><a href=\"command.epl?cmd=FLOOD&loc=$loc\">".
146            $db->loc('CMD_FLOOD').'</a>';
147        }
148      }
149      $out .= "\n<p><a href=\"command.epl?cmd=PLAGUE&loc=$loc\">".
150        $db->loc('CMD_PLAGUE').'</a>';
151      $out .= "\n<p><a href=\"command.epl?cmd=CH_LUCK\">".$db->loc('CMD_CH_LUCK').'</a>';
152    }
153
154    #############################
155    # show events for this field
156    #############################
157
158    $events = $aym->field_events($loc);
159    #use Data::Dumper;
160    #print OUT Dumper $events;
161    $out .= "\n<p><strong>".$db->loc('PLAYER_EVENTS')."</strong><p>\n" if %$events;
162    for my $ev ( keys %$events) {
163      $out .= $aym->show_event($ev, 0) .'<p>';
164    }
165
166    ############################
167    # show unavailable units
168    ############################
169
170    # mobile info:
171    #$mob = $aym->mobiles_available($loc,-1);
172    #$mobcount = $#{@$mob}+1;
173
174    #if ($mobcount) {
175    #  $out .= '<p>';            
176    #  $out .= '<strong> '.$db->loc('UNAVAILABLE_UNITS').":</strong><p>";
177    #  foreach $i (0..$mobcount-1) {
178    #    ($oid,$otype,$oown,$oado,$ocnt,$ostat) = @{$mob->[$i]};
179    #    $out .= $ocnt.' ';
180    #    if ($oown == $user) {
181    #     $out .= $db->loc('PREP_OWN_PL').' '.$aym->mobile_string($otype,2);
182    #     if ($otype eq 'PRIEST' or $otype eq 'PROPHET') {
183    #       $out .= $db->loc('ADJ_ADORING').' '.$aym->charname($oado);
184    #     } elsif ($otype eq 'HERO') {
185    #       $out .= $db->loc('ADJ_ADORING');
186    #       $out .= $aym->charname($oado).'</a>';
187    #     } elsif ($otype eq 'AVATAR') {
188    #       $out .= $aym->mobile_string($ostat,1);
189    #     }
190    #    } else {
191    #     $out .= $aym->mobile_string($otype, $ocnt);
192    #     if ($otype ne 'ARK') {
193    #       $out .= ' '.$db->loc('PREP_OWN_SG').' ';
194    #       $out .= $db->loc('ART_DAT_PL').' ' if $aym->gender($oown) eq 'PLURAL';
195    #       $out .= $aym->charname($oown);
196    #     }
197    #     if ($otype eq 'PRIEST' or $otype eq 'PROPHET'or $otype eq 'HERO') {
198    #       $out .= $db->loc('ADJ_ADORING').' ';
199    #       if ($oado == $user) {
200    #         $out .= $db->loc( ($aym->gender($user) eq 'PLURAL') ?
201    #                           'PPRO_DAT3_PL' : 'PPRO_DAT3_SG');
202    #       } else {
203    #         $out .= $aym->charname($oado);
204    #       }
205    #     }
206    #    }
207    #    $out .= ($i < $mobcount-1) ? ',' : '.';
208    #    $out .= "\n<p>";
209    #  } # end foreach $mobcount
210    #}
211
212    print OUT $out;
213  } # unless sight
214  -]
215
216 [$ else $]
217
218   To view an Aymargeddon field, you must first <a href="login.epl" target="_top">login</a>,
219   because we need to know which game to display and for whom.
220
221 [$ endif $]
222 </body></html>