1 [# get command and maybe some parameters #]
6 $aym = Aymargeddon->new($udat{-game},$udat{-id},$db);
7 $db->set_language($udat{-lang});
10 [$ if $fdat{'cmd'} $] [# show form to enter the required parameters #]
13 # my ($gname) = $db->read_game($udat{-game},'NAME');
14 # my $cname = $aym->charname($udat{-id});
16 # $out = "<strong>$gname</strong> $cname.<p>\n"
17 $out = '<form method="get" action="command.epl">';
19 my $cmd = $udat{-cmd} = $fdat{'cmd'};
20 $udat{-cmd_loc} = $fdat{'loc'} if $fdat{'loc'};
22 if($cmd eq 'SEND_MSG' and exists $fdat{'other'}){ # anybody, always
23 $udat{-cmd_args} = 'OTHER='.$fdat{'other'};
24 my $to = $aym->charname($fdat{'other'});
25 $out .= $db->loc('SEND_MESSAGE_TO',$to).
26 '<textarea name="message" cols="20" rows="20"></textarea>'
27 }elsif($cmd eq 'CH_STATUS' and exists $fdat{'other'}){ # anybody, always
28 $udat{-cmd_args} = 'OTHER='.$fdat{'other'};
29 $out .= $db->loc('CMD_CH_STATUS_MSG').' '.$aym->charname($fdat{'other'}).":<p>\n"
30 .'<input type="radio" name="status" value="ALLIED">'.$db->loc('STAT_ALLIED')."<p>\n"
31 .'<input type="radio" name="status" value="FRIEND">'.$db->loc('STAT_FRIEND')."<p>\n"
32 .'<input type="radio" name="status" value="NEUTRAL">'.$db->loc('STAT_NEUTRAL')."<p>\n"
33 .'<input type="radio" name="status" value="FOE">'.$db->loc('STAT_FOE')."<p>\n"
34 .'<input type="radio" name="status" value="BETRAY">'.$db->loc('STAT_BETRAY')."<p>\n";
35 }elsif($cmd eq 'DIE_ORDER'){ # earthling, always
36 $out .= $db->loc('CMD_DIE_ORDER_MSG').":<p>\n"
37 .'<input type="radio" name="dying" value="PKH">'.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_HERO_PL')."<p>\n"
38 .'<input type="radio" name="dying" value="PHK">'.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_WARRIOR_PL')."<p>\n"
39 .'<input type="radio" name="dying" value="KPH">'.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_HERO_PL')."<p>\n"
40 .'<input type="radio" name="dying" value="KHP">'.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_PRIEST_PL')."<p>\n"
41 .'<input type="radio" name="dying" value="HPK">'.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_WARRIOR_PL')."<p>\n"
42 .'<input type="radio" name="dying" value="HKP">'.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_PRIEST_PL')."<p>\n"
43 }elsif($cmd eq 'CH_LUCK'){ # god, always
44 $out .= $db->loc('CMD_CH_LUCK_MSG').":<p>\n"
45 . '<input type="text" name="bonus"><p>'."\n";
46 # TODO: inc/dec button
47 }elsif($cmd eq 'MOVE' and exists $fdat{'mob'} and exists $fdat{'loc'}){ # any mobile
48 $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'};
49 my ($type, $count, $adoring, $movewith) =
50 $aym->get_mobile_info($fdat{'mob'}, 'TYPE, COUNT, ADORING, MOVE_WITH');
51 $out .= $db->loc('CMD_MOVE_MSG',$aym->mobile_extended_string($type,$count,$adoring)).":<p>\n"
52 .'<input type="text" name="dir">';
53 $out .= $db->loc('CMD_COUNT').':<input type="text" name="count">'."max. $count" if $count > 1;
56 # arks cant move with other units
59 my $mob = $aym->mobiles_available($fdat{'loc'});
60 my $mobcount = $#{@$mob}+1;
63 foreach $i (0..$mobcount-1){
64 my ($oid,$otype,$oown,$oado,$ocnt,$ostat,$omove) = @{$mob->[$i]};
65 next if($oid == $fdat{'mob'} or $otype eq 'AVATAR' );
68 $out .= $db->loc('MSG_MOVE_WITH').":<p>\n";
71 if($movewith == $oid){
72 $out .= '<input type="radio" name="movewith" value="0">'.
73 $db->loc('MSG_DONT_MOVE_WITH')."<p>\n";
75 $out .= '<input type="radio" name="movewith" value="'.$oid.'">'.
76 $aym->mobile_extended_string($otype, $ocnt, $oado)."<p>\n";
81 #}elsif($cmd eq 'CH_ADORING' and exists $fdat{'mob'}){ # hero
82 # $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'};
83 # $out .= $db->loc('CMD_CH_ADORING_MSG').":<p>\n";
84 # my @gods = $aym->gods();
85 # for my $god (@gods){
86 # $out .= '<input type="radio" name="god" value="'.$god.'">'.$aym->charname($god)."<p>\n";
88 }elsif($cmd eq 'CH_ACTION' and exists $fdat{'mob'}){ # avatar
89 $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'};
90 $out .= $db->loc('CMD_CH_ACTION_MSG').":<p>\n"
91 . '<input type="radio" name="action" value="BLOCK">'.$db->loc('MOBILE_BLOCK')."<p>\n"
92 . '<input type="radio" name="action" value="HELP">'.$db->loc('MOBILE_HELP')."<p>\n"
93 . '<input type="radio" name="action" value="IGNORE">'.$db->loc('MOBILE_IGNORE')."<p>\n";
94 }elsif($cmd eq 'BLESS_PRIEST' and exists $fdat{'mob'}){ # warrior
95 $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'};
96 $out .= $db->loc('CMD_BLESS_PRIEST_MSG').".<p>\n";
97 }elsif($cmd eq 'BLESS_HERO' and exists $fdat{'mob'}){ # warrior
98 $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'};
99 $out .= $db->loc('CMD_BLESS_HERO_MSG').".<p>\n";
100 $out .= ':<input type="text" name="count"><p>'."\n";
101 }elsif($cmd eq 'BUILD_TEMPLE' and exists $fdat{'mob'}){
102 # priest or prophet at mountain (of the god they adore) or isle without temple
103 $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'}; # needed to change its type to priest if it was a prophet
104 $out .= $db->loc('CMD_BUILD_TEMPLE_MSG').' '.$fdat{'loc'}.".<p>\n";
105 }elsif($cmd eq 'DESTROY'){ # avatar at mountain or isle with temple
106 $out .= $db->loc('CMD_DESTROY_MSG').' '.$fdat{'loc'}.".<p>\n";
107 }elsif($cmd eq 'MOVE_MTN'){ # earthling at a mountain with more priests of one god than luck+5
108 $out .= $db->loc('FIELD_MOUNTAIN')." $loc ".$db->loc('CMD_MOVE_MTN_MSG').":<p>\n";
109 # TODO: list target locations (where prophets adoring same god are)
110 }elsif($cmd eq 'INCARNATE'){ # god at his arrival temple (temple with most priests adoring him)
111 $out .= $db->loc('CMD_INCARNATE_MSG').":<p>\n"
112 .':<input type="text" name="count"><p>'."\n";
113 }elsif($cmd eq 'BUILD_ARK'){ # god at any coast field
114 $out .= $db->loc('CMD_BUILD_ARK_MSG').' '.$fdat{'loc'}.".<p>\n";
115 }elsif($cmd eq 'PLAGUE'){ # god at any field
116 $out .= $db->loc('CMD_PLAGUE_MSG').' '.$fdat{'loc'}.":<p>\n";
117 for my $plague (@{$::conf->{-PLAGUES}}){
118 $out .= '<input type="radio" name="type" value="'.$plague.'">'."$plague<p>\n"
120 }elsif($cmd eq 'FLOOD'){ # god at any coast field (without city)
121 $out .= $db->loc('CMD_FLOOD_MSG').' '.$fdat{'loc'}.".<p>\n";
125 delete $udat{-cmd_loc};
126 $out = $db->loc('CMD_ERROR_MSG')."<p>\n"; # unknown, illegal or incomplete command
129 if(exists $udat{-cmd}){
130 $out .= '<input type="submit" value="'.$db->loc('FORM_OK_BUTTON').'"></form>';
131 $udat{-back} = $ENV{'HTTP_REFERER'};
133 $out .= '<form method="get" action="'.$ENV{'HTTP_REFERER'}.'">'
134 .'<input type="submit" value="'.$db->loc('FORM_BACK_BUTTON').'"></form><p>';
139 [$ elsif exists $udat{-cmd} $] [# complete the command with the given form-data #]
142 my ($cmd) = $udat{-cmd}; delete $udat{-cmd};
143 my ($args) = $udat{-cmd_args}; delete $udat{-cmd_args} if exists $udat{-cmd_args};
144 my ($loc) = $udat{-cmd_loc}; delete $udat{-cmd_loc} if exists $udat{-cmd_loc};
148 if($cmd eq 'SEND_MSG'){
149 my $msg = $db->quote($fdat{'message'});
151 # uggly workaround necessary for Command::parse_args()
152 $msg =~ s/,/__COMMA__/g;
153 $msg =~ s/=/__EQUAL__/g;
155 $args .= ", MESSAGE=$msg"
156 }elsif($cmd eq 'CH_STATUS'){
157 $failure = 1 if not exists $fdat{'status'};
158 $args .= ', STATUS='.$fdat{'status'};
159 }elsif($cmd eq 'DIE_ORDER'){
160 $failure = 1 if not exists $fdat{'dying'};
161 $args = 'DYING='.$fdat{'dying'};
162 }elsif($cmd eq 'CH_LUCK'){
163 $failure = 1 if not exists $fdat{'bonus'};
164 $args = 'BONUS='.$fdat{'bonus'};
167 }elsif($cmd eq 'MOVE'){
168 $failure = 1 if (not exists $fdat{'dir'} and not exists $fdat{'movewith'});
169 my $count = (exists $fdat{'count'}) ? $fdat{'count'} : 1;
170 if(exists $fdat{'movewith'}){
172 $args .= ', COUNT='.$count.', TARGET='.$fdat{'movewith'};
174 $args .= ', COUNT='.$count.', DIR='.$fdat{'dir'};
176 #}elsif($cmd eq 'CH_ADORING'){
177 #$failure = 1 if not exists $fdat{'god'};
178 #$args .= ', GOD='.$fdat{'god'};
179 }elsif($cmd eq 'CH_ACTION'){
180 $failure = 1 if not exists $fdat{'action'};
181 $args .= ', ACTION='.$fdat{'action'};
182 }elsif($cmd eq 'BLESS_HERO'){
183 my $count = exists $fdat{'count'} ? $fdat{'count'} : 1;
184 $args .= ", COUNT=$count";
186 }elsif($cmd eq 'MOVE_MTN'){
187 $failure = 1 if not exists $fdat{'target'};
188 $args = 'TARGET='.$fdat{'target'};
189 }elsif($cmd eq 'INCARNATE'){
190 my $count = (exists $fdat{'count'}) ? $fdat{'count'} : 1;
191 $args = 'COUNT='.$count;
192 }elsif($cmd eq 'PLAGUE'){
193 $failure = 1 if not exists $fdat{'type'};
194 $args = 'TYPE='.$fdat{'type'};
195 }# elsif($cmd eq 'DESTROY'){
198 my $ub = $udat{-back};
203 $out = $db->loc('CMD_ERROR_MSG')."<p>\n"; # unknown, illegal or incomplete command
204 $out .= '<form method="get" action="'.$ub.'">'
205 .'<input type="submit" value="'.$db->loc('FORM_BACK_BUTTON').'"></form><p>';
208 $args = '' if not $args;
209 $aym->insert_command($cmd,$args,$loc) unless $failure;
213 $http_headers_out{'Location'} = $ub;
219 Hey, kein Befehl ?!?!