Perl コーディング初心者質問コーナー Part26

このエントリーをはてなブックマークに追加
812あぼーん
あぼーん
813nobodyさん:03/08/10 16:31 ID:c9slSjrq
srand;
if($mode == 1){
$offense = \%you;
$defense = \%my;
}elsif($mode == 2){
$offense = \%my;
$defense = \%you;
}
if( int(rand(2)) ){
#punch
$damage =
$offense->{'$PAN1'} - $defense->{'$DF2'};
if(!$rand = int(rand(5))){
#half
$damage = int($damage / 999);
}elsif($rand < 3){
#miss
$damage = "";
}
}else{
#kick
$damage =
$offense->{'$KIK1'} - $defense->{'$DF2'};
}
814nobodyさん:03/08/10 16:32 ID:c9slSjrq
srand2;
if($mode == 1){
$offense = \%you;
$defense = \%my;
}elsif($mode == 2){
$offense = \%my;
$defense = \%you;
}
if( int(rand(2)) ){
#punch
$damage =
$offense->{'$PAN2'} - $defense->{'$DF1'};
if(!$rand = int(rand(5))){
#half
$damage = int($damage / 999);
}elsif($rand < 3){
#miss
$damage = "";
}
}else{
#kick
$damage =
$offense->{'$KIK2'} - $defense->{'$DF1'};
}

($damage < 0) and ($damage = 0);
$defense->{'HP1'} -= $damage;

($damage < 0) and ($damage = 0);
$defense->{'HP2'} -= $damage;
815nobodyさん:03/08/10 16:32 ID:c9slSjrq
# HTMLの出力
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n";
print "<html>\n";
print "<head><title>対戦バトル</title></head>\n";
print "<body>
<p>Player1:体力は$HP1です</p>
<p>Player2:体力は$HP2です</p>
<p>Player1は<big>$kougeki1</big>のダメージを与えた。</p>
<p>Player2は<big>>$kougeki2</big>のダメージを与えた。</p></body>\n";
print "</html>";
816あぼーん:あぼーん
あぼーん