|

樓主 |
發表於 2017-3-18 12:22:42
|
顯示全部樓層
我把整個程式搬過來了...
管理員你麻煩看看哪邊不一樣
# Sub Buy Yard #
sub yard_buy {
my $YardFile = new Nfile("$datadir/$yarddat",'read');
my @yardline = $YardFile->read;
&form_table('up','100%',1);
&reload;
print qq|造船所:購入 |;
&submit_button;
print qq|</td></tr><tr><td align=left>\n|;
print qq|<div align=left>船數:<input type=text name=quan size=3 value=1></div>|;
foreach (0 .. $#yardline) {
($goods,$kind,$goods_img,$sale_area,$sale_port,$volume,$ship_hp,$knot,$price)
= split(/<>/,$yardline[$_]);
if ($sale_area =~ /$area/ || $sale_port =~ /$port/) {
$checked = !$first ? ' checked' : '';
$first = 1;
&price_up;
print qq|<input type=radio name=goods value="$_"$checked>|;
print qq|<img src="$img/$goods_img" height=15>$goods:$price G<br>|;
if ($kind == 1) {
print qq|[積載:$volume 耐久:$ship_hp 速度:$knot]<br>\n|;
}
elsif ($kind == 2) {
print qq|戰鬥力+$volume<br>\n|;
}
elsif ($kind == 3) {
print qq|指揮力+$volume<br>\n|;
}
elsif ($kind == 4) {
print qq|航海力+$volume<br>\n|;
}
}
}
print qq|<input type=hidden name=yard value="1"><input type=hidden name=mode value="buy_ship">\n|;
&id_ps;
&form_table('down');
}
# Sub Price Up #
sub price_up {
if ($kind == 2 || $kind == 3 || $kind ==4) {
my $rate = $atk + $cmd + $nav;
$price = int($price * exp($rate * 0.03 - 3))
}
}
# Sub Buy Ship #
sub buy_ship {
&get_me($F{'id'});
if ($action ne $F{'reload'}) { &play; exit }
&get_port($area,$port);
&ship_data;
my $YardFile = new Nfile("$datadir/$yarddat",'read');
my @yardline = $YardFile->read;
($goods,$kind,$goods_img,$sale_area,$sale_port,$volume,$ship_hp,$knot,$price)
= split(/<>/, $yardline[$F{'goods'}] );
if($kind == 1 ){$price *= $F{'quan'};}
if ( $sale_area !~ /$area/ && $sale_port !~ /$port/ ) { &play("發生錯誤"); exit }
&price_up;
my $ship_number = $#ship_ind + $F{'quan'};
if ( $money < $price ) { &play("資金不足"); exit }
if ( $ship_number > 16 && $kind == 1 ) { &play("船艦數已滿,無法再購買"); exit}
if ( $kind == 1 && $ship_number <= 16 ) {
for ($i = 0; $i < $F{'quan'}; $i++) {
push(@ship_ind , "$goods_img,$volume,$ship_hp,$knot,$goods");
&msg("購入$goods");
&add_record("以$price G購入$goods")
}
}
elsif ( $kind == 2 ) {
if ($atk >= $atk_limit) { &play("已至極限,無法再強化"); exit }
$atk += $volume;
&msg("武裝強化");
&add_record("戰鬥力 + $volume")
}
elsif ( $kind == 3 ) {
if ($cmd >= $cmd_limit) { &play("已至極限,無法再強化"); exit }
$cmd += $volume;
&msg("指揮力提高了");
&add_record("指揮力 + $volume")
}
elsif ( $kind == 4 ) {
if ($nav >= $nav_limit) { &play("已至極限,無法再強化"); exit }
$nav += $volume;
&msg("航海力提高了");
&add_record("航海力 + $volume")
}
$action = '';
$money -= $price;
&play;
}
# Sub Yard Sell #
sub yard_sell {
if ( $#ship_ind < 0) { print qq|你已經沒有船了|; &return_button; return }
my $YardFile = new Nfile("$datadir/$yarddat",'read');
my @yardline = $YardFile->read;
&form_table('up','100%',1);
&reload;
print qq|造船所:售出 |;
&submit_button;
print qq|</td></tr><tr><td align=left>\n|;
for ($i = 0; $i <= $#ship_ind; $i++) {
($price) = map{ (split(/<>/))[8] } grep {$ship[$i][4] eq (split(/<>/,$_))[0]} @yardline;
$price = int($price / 2);
print qq|<input type=checkbox name=goods$i value="$i">|;
print qq|$ship[$i][4]:$price G<br>\n|;
print qq|[積載:$ship[$i][1] 耐久:$ship[$i][2] 速度:$ship[$i][3]]<br>|;
}
print qq||;
print qq|<input type=hidden name=yard value="2"><input type=hidden name=mode value="sell_ship">\n|;
&id_ps;
&form_table('down');
}
# Sub Sell Ship #
sub sell_ship {
&get_me($F{'id'});
if ($action ne $F{'reload'}) { &play; exit }
&ship_data;
&fleet;
&load_data;
@sell_ship_array = ($F{'goods0'},$F{'goods1'},$F{'goods2'},$F{'goods3'},$F{'goods4'},$F{'goods5'},$F{'goods6'},$F{'goods7'},$F{'goods8'},$F{'goods9'},
$F{'goods10'},$F{'goods11'},$F{'goods12'},$F{'goods13'},$F{'goods14'},$F{'goods15'},$F{'goods16'});
my $total_ship_capacity = 0;
my $sell_ship_count = 0;
my $total_ship_number = $#ship_ind;
for ($i = 0; $i <= $total_ship_number; $i++){
if(defined $sell_ship_array[$i]){$total_ship_capacity += $ship[$sell_ship_array[$i]][1];}
}
if ( ($total - $total_load - $food - $sailor - $total_ship_capacity) < 0 ) {
&play("剩餘的容量不足");
return
}
for ($i = 0; $i <= $total_ship_number; $i++){
if(defined $sell_ship_array[$i]){
$action = '';
my $YardFile = new Nfile("$datadir/$yarddat",'read');
my @yardline = $YardFile->read;
($price) = map{ (split(/<>/))[8] } grep {$ship[$sell_ship_array[$i]][4] eq (split(/<>/,$_))[0]} @yardline;
splice(@ship_ind , $sell_ship_array[$i] - $sell_ship_count ,1);
my $upmoney = int($price / 2);
$money += $upmoney;
&msg("售出$ship[$sell_ship_array[$i]][4]");
&add_record("以$upmoney G售出$ship[$sell_ship_array[$i] ][4]");
$sell_ship_count++;
}
}
&play;
}
|
|