jug7.com
[ home / cgi / juggler / column / diary / bbs / link / welcome ]
source : テーブルタグ吐き出し(ジャグ用)
#!/usr/bin/perl
# データ取りした時の table タグを吐き出し(ジャグ用)
$cginame = 'table_for_data_j.cgi';
$title = 'データを取った時のテーブルタグ吐き出し(ジャグ用)';
print "Content-Type: text/html\n\n";
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
}
foreach $str (split(/&/,$input)) {
($name,$value) = split(/=/, $str);
$value =~ s/%0D%0A/\n/g;
$value =~ s/\+/ /g;
$value =~ s/%2C/,/g;
push(@input, $value);
}
($sub, $rate, $color, $data) = @input;
$rate = 5 if !$rate;
$color = 1 if !$color;
$clr[$color] = 'checked';
$txtclr = ($color == 1) ? '#000000' : '#ffffff';
$bgclr = ($color == 1) ? '#ffffff' : '#000000';
$tbclr = ($color == 1) ? '#ffffcc' : '#555555';
@sub = ('GOGOジャグラーSP','HYPERジャグラーV','GOGOジャグラーV','ジャグラーガール','ジャグラー','ジャグラーV');
$sub2 = $sub[$sub-1];
# ヘッダとフォームの表示
print <<"__ HTML __";
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html lang='ja'>
<head>
<meta http-equiv='Content-Type' content="text/html; charset=shift_jis">
<title>jug7.com - cgi $title</title>
<style type="text/css"> <!--
A:hover {color:#ff0000;}
--></style>
</head>
<body text='$txtclr' bgcolor='$bgclr' link='#0000ff' alink='#ff0000' vlink='#0000cc'>
<div align='right'>[ <a href='table_for_data_j_memo.html'>memo</a> / <a href='table_for_data_j.html'>source</a> / <a href='../index.html'>home</a> ]</div>
<br><br>
<div align='center'><h2>$title</h2></div>
<hr width='70%'><center>
<form action='$cginame' method='POST'>
<table border=1 align='center' cellspacing=0 rules='none'><caption><font size=2>機種</font></caption>
<tr><td><input type='radio' name='sub' value=1 checked><font size=2>GOGOジャグラーSP</font></td>
<td><input type='radio' name='sub' value=2><font size=2>HYPERジャグラーV</font></td>
<td><input type='radio' name='sub' value=3><font size=2>GOGOジャグラーV</font></td>
</tr>
<tr><td><input type='radio' name='sub' value=4><font size=2>ジャグラーガール</font></td>
<td><input type='radio' name='sub' value=5><font size=2>ジャグラー</font></td>
<td><input type='radio' name='sub' value=6><font size=2>ジャグラーV</font></td>
</tr></table>
<br>
換金率 <input type='text' size=4 name='rate' value='$rate'> 枚 = 100円
<br><br>
背景色 <input type='radio' name='color' value=1 $clr[1]>白の方 <input type='radio' name='color' value=2 $clr[2]>黒の方
<br><br>
入力<br><textarea name='data' rows=8 cols=30></textarea><br>
<input type='submit' value="送信">
</form>
<table border=0 width='80%'>
<caption><b>入力の仕方</b></caption>
<tr><td>
入力は全て<font color='red'>半角文字</font>で記入。<br>
BIGの場合 → <font color='red'>プレイ数 半角スペース 獲得枚数</font>。(プレイ数のみでも可)<br>
REGの場合 → <font color='red'>プレイ数 半角スペース r</font>。<br>
ヤメ時 → <font color='red'>プレイ数 半角スペース end</font>。<br>
初期投資、追加投資があった場合は、上記のあとに <font color='red'>半角スペース *k</font> と記入。<br>
end のすぐ後に <font color='red'>(コンマ)総獲得枚数</font> を記入すれば、収支とPAYOUTを計算する。<br><br>
<table border=0 align='center'><tr valign='top'><td>
<table border=1 cellspacing=0>
<tr><td><font size=2>入力の例</font></td><td><font size=2>意味</font></td></tr>
<tr><td><font size=2>150 386 4k<br>248 r<br>48 400<br>35 end,420</font></td>
<td><font size=2>150P BIG ( 4k 投資 )<br>248P REG<br>48P BIG(400枚獲得)<br>35P ヤメ( 総獲得420枚 )</font>
</td></tr></table>
</td><td>
<table border=1 cellspacing=0>
<tr><td><font size=2>入力の例</font></td><td><font size=2>意味</font></td></tr>
<tr><td><font size=2>17 r 1k<br>200 r 6k<br>690 end,0 16k</font></td>
<td><font size=2>17P REG ( 1k 投資 )<br>200P REG ( 6k 追い金 )<br>690P ヤメ( 16k 追い金、総獲得0枚 )</font>
</td></tr></table>
</td></tr></table>
</center>
</td></tr></table>
</center><br><br>
__ HTML __
# エラーチェックとGET 送信
if (!$data) { $error = 1; $er_msg = '記入漏れがあります。'; }
if ($data =~ /[^ \d+endrk\n,]/) { $error = 1; $er_msg = '不適切な文字が入力されています。'; }
if (( @list = $data=~ /\n/g) >= 200) { $error = 1; $er_msg = '200行以上のデータは受けつけないようにしています。'; }
if ($ENV{'REQUEST_METHOD'} ne 'POST') { $error = 1; $er_msg = 0; }
if ($er_msg) {
print q{<center><b><font color='red' size=4>*** ERROR !! ***</font><br><br>},"\n";
print "$er_msg</b></center>\n";
}
if ($error) {
print '<br><br><br><br><br>';
print q{<div align='right'>[ <a href='table_for_data_j_memo.html'>memo</a> / <a href='table_for_data_j.html'>source</a> / <a href='../index.html'>home</a> ]</div>};
exit;
}
# データの表示
@data = split(/\n/, $data);
$data =~ s/\n/<br>/g;
print <<"__ HTML __";
<hr width='88%'><br>
<table border=1 align='center' cellspacing=0><caption><font size=2>入力データ</font></caption>
<tr><td>$data</td></tr></table><br><br><br>
<table border=1 align='center' cellpadding=2 cellspacing=0><caption><font size=2>$sub2</font></caption>
<tr bgcolor='$tbclr'><td><font size=2>投資</font></td><td><font size=2>プレイ数</font></td>
<td><font size=2>当選</font></td><td><font size=2>獲得枚数</font></td><td><font size=2>BIG回数<br>(BIG確率)</font></td>
<td><font size=2>REG回数<br>(REG確率)</font></td><td><font size=2>総プレイ数</font></td>
<td><font size=2>コメント</td></tr>
__ HTML __
# 実戦データの分割と表示
$ren = $flag = $bigcount = $regcount = $t_bigget = 0;
for (@data) {
if (/end/) { # ヤメ
$bonus = 'ヤメ'; $bigget = ' '; $flag = 1;
$coin = $1 if /.+,(\d+)/;
} elsif (/r/) { # REG
$bonus = '<b>REG</b>'; $regcount++; $bigget = ' '; $flag = 0;
} else { # BIG
$bonus = '<font color=\'red\'><b>777</b></font>';
$bigcount++; $flag = 1;
if (/^\d+ (\d+)( +|$| \d+k)/) { $bigget = $1; $t_bigget += $bigget; } else { $bigget=' '; } # BIG 獲得枚数
}
if (/(\d+)k/) { $toushi = $1; $t_toushi += $toushi; } else { $toushi = ' '; } # 投資
if (/^(\d+)/) { $game = $1; $t_game += $game; } # プレイ数
$clr = ($color == 1) ? 'black' : 'white';
$clr = ($game <= 100) ? 'blue' : ($game >= 400) ? 'red' : $clr; # プレイ数の色
if ($bigcount) { $bigp = int($t_game/$bigcount+0.5); $big = "$bigcount (1/$bigp)"; } else { $big = 0; }
if ($regcount) { $regp = int($t_game/$regcount+0.5); $reg = "$regcount (1/$regp)"; } else { $reg = 0; }
if ($toushi =~ /\d+/) { $toushi .='k'; }
$count += $game; # $count : 最大BIG間プレイ数を調べるためのフラグ
$ren++ if $count<=100 && $bonus=~ /777/ && $bigcount>=2; # 100P以内のBIGなら $ren++ とする
if ($flag) { # BIG の時に $flag が真
$s2nd = $count; $count=0;
$max = $s2nd if $max < $s2nd; # $max : 最大BIG間プレイ数
}
print $display ="<tr align='center'><td>$toushi</td><td><font color='$clr'>$game</font></td><td>$bonus</td><td>$bigget</td><td>$big</td><td>$reg</td><td>$t_game</td><td> </td></tr>\n";
$display =~s/</</g;
$display =~s/>/>/g;
$display =~ s/\n/<br>/g;
push(@print, $display);
}
# 上で表示したテーブルタグのHTMLソースの表示
print <<"__ HTML __";
</table><br><br>
<table border=1 align='center' cellspacing=0 width='80%'><caption><font size=2>↑ テーブルのソ\ース</caption><tr><td>
<table border=1 align='center' cellpadding=2 cellspacing=0><br><caption><font size=2>$sub2</font></caption><br>
<tr bgcolor='$tbclr'><td><font size=2>投資</font></td><td><font size=2>プレイ数</font></td>
<td><font size=2>当選</font></td><td><font size=2>獲得枚数</font></td><br>
<td><font size=2>BIG回数<br>(BIG確率)</font></td><td><font size=2>REG回数<br>(REG確率)</font></td>
<td><font size=2>総プレイ数</font></td><td><font size=2>コメント</td></tr><br>
__ HTML __
foreach (@print) { print; }
print '</table></td></tr></table><br><br><br><br>',"\n";
$brcount = $bigcount + $regcount;
$bigprob = &point(($t_game/$bigcount),2) if $bigcount;
$regprob = &point(($t_game/$regcount),2) if $regcount;
$brprob = &point(($t_game/ $brcount),2) if $brcount;
$shushi = int($coin*100/$rate - $t_toushi*1000) if $rate;
$s_clr = ($shushi>=0) ? 'blue' : 'red';
$wari = ($coin-$t_toushi*50)/($t_game*3) *100+100 if $coin ne '';
$wari = &point($wari, 2);
$bigget_ave = ($bigcount) ? &point(($t_bigget/$bigcount),2) : '<center>-</center>'; # BIG平均獲得枚数
$bunbo = ($bigcount > 1) ? $bigcount - 1 : 0;
$ren_rate = ($bunbo > 0) ? int($ren/$bunbo *100) : 0; # 100P以内のBIG連荘率
# 実戦データまとめ を表示
$data2 = "<table border=1 align='center' cellspacing=0>
<tr><td colspan=7 align='center' bgcolor='$tbclr'>$sub2</td></tr>
<tr><td bgcolor='$tbclr'>プレイ数</td><td align='right'>$t_game</td><td> </td><td bgcolor='$tbclr'>投資</td><td align='right'>$t_toushi k</td>
<td bgcolor='$tbclr'>期待収支</td><td align='center'>-</td></tr>
<tr><td bgcolor='$tbclr'>BIG</td><td align='right'>$bigcount</td><td align='right'>1/$bigprob</td>
<td bgcolor='$tbclr'>回収</td><td align='right'>$coin 枚</td><td bgcolor='$tbclr'>連荘率(BIG)</td>
<td align='right'>$ren/$bunbo = $ren_rate %</td></tr>
<tr><td bgcolor='$tbclr'>REG</td><td align='right'>$regcount</td><td align='right'>1/$regprob</td>
<td bgcolor='$tbclr'>収支</td><td align='right'><b><font color='$s_clr'>$shushi 円</font></b></td><td bgcolor='$tbclr'>最大BIG間</td><td align='right'>$max</td></tr>
<tr><td bgcolor='$tbclr'>合成</td><td align='right'>$brcount</td><td align='right'>1/$brprob</td>
<td bgcolor='$tbclr'>PAYOUT</td><td align='right'>$wari %</td><td bgcolor='$tbclr'>平均BIG枚数</td><td align='right'>$bigget_ave</td></tr>
</table>";
print $data2;
# HTML ソースを表示
$data2 =~ s/</</g;
$data2 =~ s/>/>/g;
$data2 =~ s/\n/<br>/g;
print q{<br><br><table border=1 align='center' cellspacing=0 width='80%'><caption>};
print q{<font size=2>↑ テーブルのソース</font></caption><tr><td>};
print $data2;
print '</td></tr></table>',"\n";
$per = $t_bigget + $regcount*111.043 + $t_toushi*50 - $coin;
$per = &point(($t_game*50/$per), 3) if $per;
# その他のデータ表示とフッタ
print <<"__ HTML __";
<br><br>
<table border=1 align='center' cellspacing=0><caption><font size=2>その他のデータ</font></caption>
<tr><td align='center'><font size=2>1k 当たりの<br>プレイ数</font></td><td align='right'>$per P</td></tr>
<tr><td align='center'><font size=2>BIG 総獲得枚数</font></td><td align='right'>$t_bigget 枚</td></tr></table>
<br><br><br><br>
<div align='right'>[ <a href='table_for_data_j_memo.html'>memo</a> / <a href='table_for_data_j.html'>source</a> / <a href='../index.html'>home</a> ]</div>
</body></html>
__ HTML __
exit;
# 少数を四捨五入して指定の桁にする
sub point {
my($value, $fig, $x);
($value, $fig) = @_;
$value = int($value * (10 ** $fig) + 0.5) / (10 ** $fig);
if ($value =~ /(\d+)\.(\d+)/) { $x = $2; }
elsif ($value !~ /\./) { $x =''; $value .= '.'; }
$value = $value.'0' x ( $fig - length($x) );
return $value;
}
[ home / cgi / juggler / column / diary / bbs / link / welcome ]