[# get command and maybe some parameters #] [- use Aymargeddon; $db = DataBase->new(); $aym = Aymargeddon->new($udat{-game},$udat{-id},$db); $db->set_language($udat{-lang}); -] [$ if $fdat{'cmd'} $] [# show form to enter the required parameters #] [- # my ($gname) = $db->read_game($udat{-game},'NAME'); # my $cname = $aym->charname($udat{-id}); # $out = "$gname $cname.

\n" $out = '

'; my $cmd = $udat{-cmd} = $fdat{'cmd'}; $udat{-cmd_loc} = $fdat{'loc'} if $fdat{'loc'}; if($cmd eq 'SEND_MSG' and exists $fdat{'other'}){ # anybody, always $udat{-cmd_args} = 'OTHER='.$fdat{'other'}; my $to = $aym->charname($fdat{'other'}); $out .= $db->loc('SEND_MESSAGE_TO',$to). '' }elsif($cmd eq 'CH_STATUS' and exists $fdat{'other'}){ # anybody, always $udat{-cmd_args} = 'OTHER='.$fdat{'other'}; $out .= $db->loc('CMD_CH_STATUS_MSG').' '.$aym->charname($fdat{'other'}).":

\n" .''.$db->loc('STAT_ALLIED')."

\n" .''.$db->loc('STAT_FRIEND')."

\n" .''.$db->loc('STAT_NEUTRAL')."

\n" .''.$db->loc('STAT_FOE')."

\n" .''.$db->loc('STAT_BETRAY')."

\n"; }elsif($cmd eq 'DIE_ORDER'){ # earthling, always $out .= $db->loc('CMD_DIE_ORDER_MSG').":

\n" .''.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_HERO_PL')."

\n" .''.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_WARRIOR_PL')."

\n" .''.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_HERO_PL')."

\n" .''.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_PRIEST_PL')."

\n" .''.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_PRIEST_PL').', '.$db->loc('MOBILE_WARRIOR_PL')."

\n" .''.$db->loc('MOBILE_HERO_PL').', '.$db->loc('MOBILE_WARRIOR_PL').', '.$db->loc('MOBILE_PRIEST_PL')."

\n" }elsif($cmd eq 'CH_LUCK'){ # god, always $out .= $db->loc('CMD_CH_LUCK_MSG').":

\n" . '

'."\n"; # TODO: inc/dec button }elsif($cmd eq 'MOVE' and exists $fdat{'mob'} and exists $fdat{'loc'}){ # any mobile $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'}; my ($type, $count, $adoring, $movewith) = $aym->get_mobile_info($fdat{'mob'}, 'TYPE, COUNT, ADORING, MOVE_WITH'); $out .= $db->loc('CMD_MOVE_MSG',$aym->mobile_extended_string($type,$count,$adoring)).":

\n" .''; $out .= $db->loc('CMD_COUNT').':'."max. $count" if $count > 1; $out .= "

\n"; # arks cant move with other units if($type ne 'ARK'){ # MOVE_WITH my $mob = $aym->mobiles_available($fdat{'loc'}); my $mobcount = $#{@$mob}+1; my $transporters = 0; if ($mobcount > 1){ foreach $i (0..$mobcount-1){ my ($oid,$otype,$oown,$oado,$ocnt,$ostat,$omove) = @{$mob->[$i]}; next if($oid == $fdat{'mob'} or $otype eq 'AVATAR' ); next if $omove; if(! $transporters){ $out .= $db->loc('MSG_MOVE_WITH').":

\n"; $transporters = 1; } if($movewith == $oid){ $out .= ''. $db->loc('MSG_DONT_MOVE_WITH')."

\n"; }else{ $out .= ''. $aym->mobile_extended_string($otype, $ocnt, $oado)."

\n"; } } } } #}elsif($cmd eq 'CH_ADORING' and exists $fdat{'mob'}){ # hero # $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'}; # $out .= $db->loc('CMD_CH_ADORING_MSG').":

\n"; # my @gods = $aym->gods(); # for my $god (@gods){ # $out .= ''.$aym->charname($god)."

\n"; # } }elsif($cmd eq 'CH_ACTION' and exists $fdat{'mob'}){ # avatar $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'}; $out .= $db->loc('CMD_CH_ACTION_MSG').":

\n" . ''.$db->loc('MOBILE_BLOCK')."

\n" . ''.$db->loc('MOBILE_HELP')."

\n" . ''.$db->loc('MOBILE_IGNORE')."

\n"; }elsif($cmd eq 'BLESS_PRIEST' and exists $fdat{'mob'}){ # warrior $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'}; $out .= $db->loc('CMD_BLESS_PRIEST_MSG').".

\n"; }elsif($cmd eq 'BLESS_HERO' and exists $fdat{'mob'}){ # warrior $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'}; $out .= $db->loc('CMD_BLESS_HERO_MSG').".

\n"; $out .= ':

'."\n"; }elsif($cmd eq 'BUILD_TEMPLE' and exists $fdat{'mob'}){ # priest or prophet at mountain (of the god they adore) or isle without temple $udat{-cmd_args} = 'MOBILE='.$fdat{'mob'}; # needed to change its type to priest if it was a prophet $out .= $db->loc('CMD_BUILD_TEMPLE_MSG').' '.$fdat{'loc'}.".

\n"; }elsif($cmd eq 'DESTROY'){ # avatar at mountain or isle with temple $out .= $db->loc('CMD_DESTROY_MSG').' '.$fdat{'loc'}.".

\n"; }elsif($cmd eq 'MOVE_MTN'){ # earthling at a mountain with more priests of one god than luck+5 $out .= $db->loc('FIELD_MOUNTAIN')." $loc ".$db->loc('CMD_MOVE_MTN_MSG').":

\n"; # TODO: list target locations (where prophets adoring same god are) }elsif($cmd eq 'INCARNATE'){ # god at his arrival temple (temple with most priests adoring him) $out .= $db->loc('CMD_INCARNATE_MSG').":

\n" .':

'."\n"; }elsif($cmd eq 'BUILD_ARK'){ # god at any coast field $out .= $db->loc('CMD_BUILD_ARK_MSG').' '.$fdat{'loc'}.".

\n"; }elsif($cmd eq 'PLAGUE'){ # god at any field $out .= $db->loc('CMD_PLAGUE_MSG').' '.$fdat{'loc'}.":

\n"; for my $plague (@{$::conf->{-PLAGUES}}){ $out .= ''."$plague

\n" } }elsif($cmd eq 'FLOOD'){ # god at any coast field (without city) $out .= $db->loc('CMD_FLOOD_MSG').' '.$fdat{'loc'}.".

\n"; }else{ delete $udat{-cmd}; delete $udat{-cmd_loc}; $out = $db->loc('CMD_ERROR_MSG')."

\n"; # unknown, illegal or incomplete command } if(exists $udat{-cmd}){ $out .= '

'; $udat{-back} = $ENV{'HTTP_REFERER'}; } $out .= '
' .'

'; print OUT $out; -] [$ elsif exists $udat{-cmd} $] [# complete the command with the given form-data #] [- my ($cmd) = $udat{-cmd}; delete $udat{-cmd}; my ($args) = $udat{-cmd_args}; delete $udat{-cmd_args} if exists $udat{-cmd_args}; my ($loc) = $udat{-cmd_loc}; delete $udat{-cmd_loc} if exists $udat{-cmd_loc}; my $failure = 0; # global if($cmd eq 'SEND_MSG'){ my $msg = $db->quote($fdat{'message'}); # uggly workaround necessary for Command::parse_args() $msg =~ s/,/__COMMA__/g; $msg =~ s/=/__EQUAL__/g; $args .= ", MESSAGE=$msg" }elsif($cmd eq 'CH_STATUS'){ $failure = 1 if not exists $fdat{'status'}; $args .= ', STATUS='.$fdat{'status'}; }elsif($cmd eq 'DIE_ORDER'){ $failure = 1 if not exists $fdat{'dying'}; $args = 'DYING='.$fdat{'dying'}; }elsif($cmd eq 'CH_LUCK'){ $failure = 1 if not exists $fdat{'bonus'}; $args = 'BONUS='.$fdat{'bonus'}; # mobile }elsif($cmd eq 'MOVE'){ $failure = 1 if (not exists $fdat{'dir'} and not exists $fdat{'movewith'}); my $count = (exists $fdat{'count'}) ? $fdat{'count'} : 1; if(exists $fdat{'movewith'}){ $cmd = 'MOVE_WITH'; $args .= ', COUNT='.$count.', TARGET='.$fdat{'movewith'}; }else{ $args .= ', COUNT='.$count.', DIR='.$fdat{'dir'}; } #}elsif($cmd eq 'CH_ADORING'){ #$failure = 1 if not exists $fdat{'god'}; #$args .= ', GOD='.$fdat{'god'}; }elsif($cmd eq 'CH_ACTION'){ $failure = 1 if not exists $fdat{'action'}; $args .= ', ACTION='.$fdat{'action'}; }elsif($cmd eq 'BLESS_HERO'){ my $count = exists $fdat{'count'} ? $fdat{'count'} : 1; $args .= ", COUNT=$count"; # local }elsif($cmd eq 'MOVE_MTN'){ $failure = 1 if not exists $fdat{'target'}; $args = 'TARGET='.$fdat{'target'}; }elsif($cmd eq 'INCARNATE'){ my $count = (exists $fdat{'count'}) ? $fdat{'count'} : 1; $args = 'COUNT='.$count; }elsif($cmd eq 'PLAGUE'){ $failure = 1 if not exists $fdat{'type'}; $args = 'TYPE='.$fdat{'type'}; }# elsif($cmd eq 'DESTROY'){ my $ub = $udat{-back}; delete $udat{-back}; if($failure) { $out = $db->loc('CMD_ERROR_MSG')."

\n"; # unknown, illegal or incomplete command $out .= '

' .'

'; print OUT $out; }else{ $args = '' if not $args; $aym->insert_command($cmd,$args,$loc) unless $failure; $db->commit(); # redirect to field $http_headers_out{'Location'} = $ub; } -] [$ else $] Hey, kein Befehl ?!?! [$ endif $]