|

- 帖子
- 269
- 在線時間
- 202 小時
|
主體程式 simplewebgame.pl
#!/usr/bin/perl
print "Content-type: text/html;charset=UTF-8;\n\n";
require "debug_simple_sub.pl";#載入公用函式庫
($parm1,$parm2,$parm3)=GetParmFormValue();
$UserName=$FORM{'UserName'};
$Password=$FORM{'Password'};
#若收到傳遞的參數是"HOME"就進入遊戲的首頁
if ($parm1 eq "HOME")
{
print << "---HTNLTAG----";
<html>
<form method=" OST" action="$MAIN_SCRIPT?ENTRY" name="LOGIN">
<font size="7">亂鬥 ONLINE</font>
<p> </p>
<p>登入</p>
<p>
ID<input type="text" value="$UserName" name="UserName">
Password<input type="password" value="$Password" name=" assword">
<input type="submit" value="OK">
</p>
<p><a href="http://www.7era.com/cgi-bin/simplewebgame_cgi/register.pl?registerstart">新人註冊</a></form>
<a href="http://www.frwonline.com/discuz/forum-49-1.html">想學 CGI WEB GAME 嗎? 線上教學即將開始</a>
</p>
</html>
---HTNLTAG----
}
#若收到傳遞的參數是 "entry" 或者 "ENTRY" 就進入遊戲的主體程式
if (($parm1 eq "entry") or ($parm1 eq "ENTRY"))
{
%P=ProcessDBM("getdata",$UserDataFileDBM);#呼叫資料庫
@SelfValue=split (/\s/,$P{"$UserName"});#取出自己的資料
CheckPassword($Password,@SelfValue[1]);#比對密碼
#取出資料庫中的每一筆排序後的資料
foreach $Key (sort (keys %P))
{
#取出每筆資料後進行資料細部分離然後以陣列型態放入@GetValue
@GetValue=split (/\s/,$P{$Key});
#如果找到非自己的ID就取出資料(其它玩家列表用)
if ($UserName ne $Key)
{
@EngVlu=split(/∥_∥/,@GetValue[35]); #取得生命/能量值/MP
$niName=@GetValue[29]; #取得遊戲中名
$listAll.='<input type="radio" value="'.$Key.'" name="EnemyID">'.$niName." (LV GetValue[15], HP EngVlu[0]/@EngVlu[1]) ";
}
}
&getBaseValue;#取得基本資訊(debug_simple_sub.pl)
if ($SelfHP1 < 1 ) {&checkSelfHP;&getBaseValue;} #如果自己的生命力不足 就 呼叫 生命力的處理函示並再一次取得基本資訊
#===秀出遊戲主畫面內容
print << "---HTNLTAG----";
<p align="center">
<table border="1" width="760" bgcolor="#E3977D">
<tr>
<td width="100%">
<p align="center">歡迎 $SelfName ($UserName) 登入 $Title <BR>
</td>
</tr>
</table>
<table border="1" width="760" bgcolor="#EDD883">
<tr>
<td width="7%">
<p align="center">
<IMG SRC="$FaceImageDir/$SelfImg.gif">
$SelfName</p>
<p align="left"> </td>
<td width="93%"> <table border="1" width="100%">
<tr>
<td width="20%">HP SelfEngVlu[0]/@SelfEngVlu[1]</td>
<td width="20%">EN:@SelfEngVlu[2]/@SelfEngVlu[3]</td>
<td width="20%">MP:@SelfEngVlu[4]/@SelfEngVlu[5]</td>
<td width="20%"> 等級 SelfLV</td>
<td width="20%"> 經驗 SelfExp/$nextLvNeedExp </td>
</tr>
<tr>
<td width="20%"> 金錢 SelfMoney</td>
<td width="20%">原發力:@SelfData36[0] </td>
<td width="20%"> 攻擊力:@SelfData36[1] </td>
<td width="20%"> 防護力:@SelfData36[2] </td>
<td width="20%"> 移動力:@SelfData36[3] </td>
</tr>
<tr>
<td width="20%"> 命中力:@SelfData36[4] </td>
<td width="20%"> 意志力:@SelfData36[5] </td>
<td width="20%"> 學習力:@SelfData36[6] </td>
<td width="20%"> 回復力:@SelfData36[7]</td>
<td width="20%"> 時運力:@SelfData36[8]</td>
</tr>
</table>
</td>
</tr>
</table>
<form method=" OST" action="weaponlist.pl?sell" name="ITEMMAG">
<input type="hidden" value="$UserName" name="UserName">
<input type="hidden" value="$Password" name="Password">
裝備欄1 @SelfitemInfo1[0] @SelfitemInfo1[7] (目前已裝備上)<BR>
<input type="submit" value="賣掉(90%)">
</form>
<form method="POST" action="weaponlist.pl?process" name="ITEMMAG">
<input type="hidden" value="$UserName" name="UserName">
<input type="hidden" value="$Password" name="Password">
<table border="1" width="760" bgcolor="#EDD883">
<tr>
<td width="437" rowspan="2">
<input type="radio" value="1" name="ITEMIDN" checked>裝備欄2 @SelfitemInfo2[0] @SelfitemInfo2[7] (未裝備上)<BR>
<input type="radio" value="2" name="ITEMIDN">裝備欄3 @SelfitemInfo3[0] @SelfitemInfo3[7] (未裝備上)<BR>
<input type="radio" value="3" name="ITEMIDN">裝備欄4 @SelfitemInfo4[0] @SelfitemInfo4[7] (未裝備上)<BR>
<input type="radio" value="4" name="ITEMIDN">裝備欄5 @SelfitemInfo5[0] @SelfitemInfo5[7] (未裝備上)<BR>
<input type="radio" value="5" name="ITEMIDN">裝備欄6 @SelfitemInfo6[0] @SelfitemInfo6[7] (未裝備上)<BR>
<input type="radio" value="6" name="ITEMIDN">裝備欄7 @SelfitemInfo7[0] @SelfitemInfo7[7] (未裝備上)<BR>
<input type="radio" value="7" name="ITEMIDN">裝備欄8 @SelfitemInfo8[0] @SelfitemInfo8[7] (未裝備上)<BR>
<input type="submit" value="裝備上">
</form>
</td>
<td width="307">
<form method="POST" action="weaponlist.pl" name="LFIGHT">
<input type="hidden" value="$UserName" name="UserName">
<input type="hidden" value="$Password" name="Password">
<input type="submit" value="目前可訂契約人物與裝備列表">
</form>
</td>
</tr>
<tr>
<td width="307"><form method="POST" action="$MAIN_SCRIPT?fight" name="LFIGHT">
<input type="hidden" value="$UserName" name="UserName">
<input type="hidden" value="$Password" name="Password">
<br>
向 $listAll
<input type="submit" value="挑戰">
<BR>
</form></td>
</tr>
</table>
<p> </p>
</form>
---HTNLTAG----
&rank();#呼叫排行榜
}
#若收到傳遞的參數是 "fight" 就進入遊戲的戰鬥程式
if ($parm1 eq "fight")
{
require 'fight.pl'; # 呼叫戰鬥程式
$Status=OneByOneFight(); #呼叫一對一戰鬥模式
}
#密碼編碼用
if ($parm1 eq "makecrypt")
{
require 'register.pl';
MakeCrypt($parm2);
print "<br>OK";
}
#排行榜
sub rank
{
#================= 排行榜 Start =========================
$RankRange=10;
$RankRangeIndex=0;
$Counter=0;
while (($Key,$Value) = each %P)
{
@UserValue = split(/\s/,$Value);
@UserEngVlu=split(/∥_∥/,@UserValue[35]);#取得生命/能量值/MP
@UserData36=split(/∥_∥/,@UserValue[36]);#取得屬性資訊
$UserAttack=@SelfData36[0]+@SelfData36[3]+int (@SelfData36[3]*0.01*@SelfData36[4]*rand(@SelfData36[8]))+ @SelfitemInfo1[1];
$niName=@UserValue[29]; #取得遊戲中名
$RankOrder{"$niName"}=$UserAttack;
$Counter++;
}
print "
<center>
<table border=\"1\" width=\"330\" cellspacing=\"0\" cellpadding=\"0\" class=\"field\" bgcolor=\"#EDD883\">
<tr>
<td width=\"30\" align=\"center\">名次</td>
<td width=\"200\" align=\"center\">ID</td>
<td width=\"100\" align=\"center\">總攻擊</td>
</tr>
";
sort keys %RankOrder;
foreach $Key (sort ValueDescendingNum (keys(%RankOrder)))
{
if ($RankRangeIndex >= $RankRange) {last;}
$RankRangeIndex++;
print "<tr>
<td width=\"30\">$RankRangeIndex</td>
<td width=\"200\">$Key</td>
<td width=\"100\">$RankOrder{$Key}</td>";
}
print "</tr></table></center>";
#================= 排行榜 End =========================
}
1; |
|