<!--#include file="Class_PetStatus.asp"-->

<head>
<meta http-equiv="Content-Language" content="zh-cn">
</head>

<%
Session.Timeout=72
Response.Expires = 0 
Response.Expiresabsolute = date() - 1
Response.AddHeader "pragma","no-cache" 
Response.AddHeader "cache-control","private" 
Response.CacheControl = "no-cache"
Response.charset = "gb2312" 

UserMoney=conn.execute("select UserMoney from [BBSXP_Users] where UserName='"&CookieUserName&"'")(0)

Private OwnerPetLevel,OwnerPetExp,OwnerPetHp,OwnerPetAtk,OwnerPetDef,OwnerOpenPK,OwnerPKTime,OwnerPetDead
Private OpponentPetLevel,OpponentPetExp,OpponentPetHp,OpponentPetAtk,OpponentPetDef,OpponentPetDead,OpponentPetOpenPK,OpponentPetMaxHp,jinqian
Private AtkName,Atk1,Atk2,Exp1,Exp2,AtkTemp1,DefTemp1,DefTemp2,AtkTemp2

Class PetPKClass

Public Sub FormatPetPKData
Set ShowPetStatus=New PetStatus

with ShowPetStatus
.LetUserName=CookieUserName
.FormatPetData
OwnerPetLevel=.OwnerPetLevel
OwnerPetExp=  .OwnerPetExp
OwnerPetHp=   .OwnerPetHp
OwnerPetAtk=  .OwnerPetAtk
OwnerPetDef=  .OwnerPetDef
OwnerOpenPK=  .OwnerOpenPK
OwnerPKTime=  .OwnerPKTime
OwnerPetDead= .OwnerPetDead

end with
set ShowPetStatus=nothing
Atkname = request("gname")
pk=request("pk")


'###################################################怪物等
if pk=200 then               		 '怪物等 ???1
OpponentPetLevel=OwnerPetLevel                '怪物等
OpponentPetAtk=200   '攻击力
OpponentPetDef=150   '防御力
if OwnerPetAtk-200>1 then jinqian=2000  '掉的钱
end if



if pk=1 then               		 '怪物等 1-5
OpponentPetLevel=1                '怪物等
Randomize
jinqian=Int((25 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+4)   '攻击力
Randomize
OpponentPetDef=Int((5 * Rnd))   '防御力
end if

if pk=2 then               		 '怪物等 6-10
OpponentPetLevel=5                '怪物等
Randomize
jinqian=Int((55 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+5)   '攻击力
Randomize
OpponentPetDef=Int((5 * Rnd)+2)   '防御力
end if

if pk=3 then               		 '怪物等 10-15
OpponentPetLevel=10                '怪物等
Randomize
jinqian=Int((80 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+6)   '攻击力
Randomize
OpponentPetDef=Int((5 * Rnd)+5)   '防御力
end if

if pk=4 then               		 '怪物等 15-20
OpponentPetLevel=15                '怪物等
Randomize
jinqian=Int((95 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+7)   '攻击力
Randomize
OpponentPetDef=Int((10 * Rnd)+3)   '防御力
end if

if pk=5 then               		 '怪物等 21-25
OpponentPetLevel=20                '怪物等
Randomize
jinqian=Int((120 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+25)   '攻击力
Randomize
OpponentPetDef=Int((10 * Rnd)+5)   '防御力
end if

if pk=6 then               		 '怪物等 26-30
OpponentPetLevel=25                '怪物等
Randomize
jinqian=Int((160 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+30)   '攻击力
if OwnerPetDef>50 then OpponentPetAtk=Int((60 * Rnd)+25)
Randomize
OpponentPetDef=Int((10 * Rnd)+8)   '防御力
end if

if pk=7 then               		 '怪物等 31-35
OpponentPetLevel=30                '怪物等
Randomize
jinqian=Int((200 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+35)   '攻击力
if OwnerPetDef>50 then OpponentPetAtk=Int((70 * Rnd)+35)
Randomize
OpponentPetDef=Int((10 * Rnd)+10)   '防御力
end if

if pk=8 then               		 '怪物等 36-40
OpponentPetLevel=35                '怪物等
Randomize
jinqian=Int((260 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+40)   '攻击力
if OwnerPetDef>50 then OpponentPetAtk=Int((70 * Rnd)+65)
Randomize
OpponentPetDef=Int((10 * Rnd)+20)   '防御力
end if

if pk=9 then               		 '怪物等 41-45
OpponentPetLevel=45                '怪物等
Randomize
jinqian=Int((260 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((10 * Rnd)+60)   '攻击力
if OwnerPetDef>50 then OpponentPetAtk=Int((70 * Rnd)+75)
Randomize
OpponentPetDef=Int((15 * Rnd)+20)   '防御力
end if

if pk=10 then               		 '怪物等 46-50
OpponentPetLevel=50                '怪物等
Randomize
jinqian=Int((260 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((15 * Rnd)+68)   '攻击力
if OwnerPetDef>50 then OpponentPetAtk=Int((70 * Rnd)+100)
Randomize
OpponentPetDef=Int((15 * Rnd)+20)   '防御力
if OwnerPetatk>50 then OpponentPetdef=Int((50 * Rnd)+30)
end if

if pk=11 then               		 '怪物等 51-55
OpponentPetLevel=55                '怪物等
Randomize
jinqian=Int((300 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((25 * Rnd)+70)   '攻击力
if OwnerPetDef>50 then OpponentPetAtk=Int((70 * Rnd)+130)
Randomize
OpponentPetDef=Int((15 * Rnd)+25)   '防御力]
if OwnerPetatk>50 then OpponentPetdef=Int((50 * Rnd)+35)
end if

if pk=12 then               		 '怪物等 56-60
OpponentPetLevel=60                '怪物等
Randomize
jinqian=Int((300 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((25 * Rnd)+76)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+180)
Randomize
OpponentPetDef=Int((15 * Rnd)+45)   '防御力]
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+40)
end if

if pk=13 then               		 '怪物等 61-65
OpponentPetLevel=65                '怪物等
Randomize
jinqian=Int((300 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((25 * Rnd)+90)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+200)
Randomize
OpponentPetDef=Int((15 * Rnd)+60)   '防御力]
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+40)
end if

if pk=14 then               		 '怪物等 66-70
OpponentPetLevel=70                '怪物等
Randomize
jinqian=Int((350 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((35 * Rnd)+97)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+200)
Randomize
OpponentPetDef=Int((25 * Rnd)+60)   '防御力]
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+50)
end if

if pk=15 then               		 '怪物等 71-75
OpponentPetLevel=75                '怪物等
Randomize
jinqian=Int((400 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((35 * Rnd)+110)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+200)
Randomize
OpponentPetDef=Int((25 * Rnd)+65)   '防御力
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+60)
end if

if pk=16 then               		 '怪物等 76-80
OpponentPetLevel=80                '怪物等
Randomize
jinqian=Int((450 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((35 * Rnd)+120)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+250)
Randomize
OpponentPetDef=Int((25 * Rnd)+65)   '防御力
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+80)
end if

if pk=17 then               		 '怪物等 81-85
OpponentPetLevel=85                '怪物等
Randomize
jinqian=Int((450 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((35 * Rnd)+130)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+250)
Randomize
OpponentPetDef=Int((25 * Rnd)+70)   '防御力
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+90)
end if

if pk=18 then               		 '怪物等 86-90
OpponentPetLevel=90                '怪物等
Randomize
jinqian=Int((450 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((35 * Rnd)+140)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+250)
Randomize
OpponentPetDef=Int((25 * Rnd)+75)   '防御力
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+95)
end if

if pk=19 then               		 '怪物等 90-95
OpponentPetLevel=95                '怪物等
Randomize
jinqian=Int((450 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((35 * Rnd)+150)   '攻击力
if OwnerPetDef>80 then OpponentPetAtk=Int((70 * Rnd)+250)
Randomize
OpponentPetDef=Int((25 * Rnd)+80)   '防御力
if OwnerPetatk>80 then OpponentPetdef=Int((50 * Rnd)+100)
end if

if pk=20 then               		 '怪物等 96-100
OpponentPetLevel=100                '怪物等
Randomize
jinqian=Int((500 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((50 * Rnd)+200)   '攻击力

Randomize
OpponentPetDef=Int((50 * Rnd)+100)   '防御力

end if

if pk=21 then               		 '怪物等 100-???
OpponentPetLevel=105                '怪物等
Randomize
jinqian=Int((1000 * Rnd)+1)         '掉的钱
Randomize
OpponentPetAtk=Int((50 * Rnd)+300)   '攻击力

Randomize
OpponentPetDef=Int((50 * Rnd)+150)   '防御力

end if
'##################################################

End Sub

Public Sub GoPK

if OwnerPetDead = 1 then
   error("你的宝宝好象已经挂了， 救活它再PK吧。")
end if
     
                
		
		
	 '开始计算PK数据
		
level1=int(OwnerPetlevel/2)
level2=int(OpponentPetlevel/2)
                
                
'宝宝攻击力1				
AtkTemp1=OwnerPetAtk
'宝宝防御力1
DefTemp1=OwnerPetDef

'怪攻击力2
AtkTemp2=OpponentPetAtk
'怪防御力2
DefTemp2=OpponentPetDef

Atk1=AtkTemp1-DefTemp2        '宝攻击 - 怪防 如果小于0则经验１
if Atk1<0 then
Randomize
Atk1=1 'Int((8 * Rnd)+1)
End if

Atk2=AtkTemp2-DefTemp1        '怪攻击 - 宝防 如果小于0则减血１
if Atk2<0 then
Atk2=1
End if


Exp1=Atk1                     '经验等于 宝击怪 如果经验大于20则在20数中承随机得

if Exp1>20 then
Randomize                     '初始化随机数生成器。
Exp1=Int((20 * Rnd) + 1)
end if 


test=0
if test=1 then
response.write "攻击力1："&Atktemp1&"<br>"
response.write "防御力1："&Deftemp1&"<br>"
response.write "攻击力2："&Atktemp2&"<br>"
response.write "防御力2："&Deftemp2&"<br>"
response.write "得到力2："&atk2&"<br>"
response.Write "HP1："&OwnerPetHp&"<br>"
response.Write "OwnerPetDead:"&OwnerPetDead&"<br>"
end if

ttt="<li><b>你的宝宝打死了 "&Atkname&" 怪 ；</b>"    '提示



LevelGap=OwnerPetLevel-OpponentPetLevel                    '高级宠 打 低级怪
if(LevelGap>5) then                                        '等级不得大于5级如果大于则经验得0 血减1 钱得1
Exp1=0
OwnerPetHp=OwnerPetHp-1 
jinqian=1                                            '掉的钱
ttt="<li><b>你要打更高级的怪才能得到经验了！</b>"    '提示

else                                                       '如果不小于5级则宠减血得于 怪攻 - 宝防

OwnerPetHp=OwnerPetHp-Atk2

If OwnerPetHp<1 Then                                       '如果宠血小于了1 则宠血＝0死了
OwnerPetHp=0
OwnerPetDead=1
End if	

end if



LevelGap1=OpponentPetLevel-OwnerPetLevel               '低级宠 打 高级怪   大于5级则
if LevelGap1>5 then
jinqian=0                                              '不得钱
Exp1=1
ttt="<li><b>怪物很强大没有打死它！</b>"
end if                                                 '经验等于2不得钱 减血为 怪攻 - 宝防

				
Set PetSql=New SQLString
With PetSql

.TableName="PetData"                    '写入数据库
.SQLType=1
.where="UserName='"&CookieUserName&"'"  
.AddField "PetExp",OwnerPetExp+Exp1     '获得经
.AddField "PetHp",OwnerPetHp            '减的HP
.AddField "PetDead",OwnerPetDead        '是否死
.AddField "PkTime",Now()
ConnPet.Execute(.ReturnSQL)

'###########################################3
'获得金钱

.clear()
.TableName="BBSXP_Users"       '数据库
.SQLType=1
.where="UserName='"&CookieUserName&"'"  
.AddField "UserMoney",UserMoney+jinqian
Conn.Execute(.ReturnSQL)

'###############################################

message="<font color=#FF0000>"&ttt&"</font><br>你增加了 "&Exp1&" 点经验值，他（她）宝宝进行了反击，<br>使你受到 "&Atk2&" 点攻击；<br>"&Atkname&" 掉下了 "&jinqian&" 伊币！"

mx=request("mx")
mxx="<meta http-equiv=refresh content=3;url='Petmx.asp?mx="&mx&"'>"

succeed(message&mxx)

End With
Set PetSql=Nothing

'end if
End Sub

End class 
%>