<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="YD_pet_conn.asp"-->
<!--#include file="inc/plus_check.asp"-->

<%
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr
chentitle="宠物竞技场"
Dv_plus.name="petcenter"
'Dv_plus.checklogin()
Dvbbs.LoadTemplates("")
Dvbbs.Stats="宠物竞技场"
Dvbbs.Nav()
Dvbbs.Head_var 0,"","宠物中心","YD_petcenter.asp"

if DvBBS.UserId = 0 then
	AlarmErrmsg
else
	'宠物插件状态
	if DEF_PET_close>1 then
		'暂时关掉开始
		if not dvbbs.master then
			call showmessage("调试中,请以后再来~","index.asp")
		end if
		'暂时关掉结束
	end if
	dim money,smoney,saveday,allmoney,time1,time2,time3,daikuang,dkdu,daiday,sucmsg,hpmaxskill,maxhp,hpmaxskill2,maxhp2
	dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
	Dim Rs,SQL
	set rs=Dvbbs.execute("select userWealth from [DV_user] where UserID="&DvBBS.UserId)
	money=rs("userWealth")
	rs.close
	sql = "SELECT * FROM mypetdata WHERE username='"&DvBBS.MemberName&"' "
	rs.open sql,connpet,1,3

	if rs.eof then
		call showmessage("你还没有宠物啊，快攒钱去买吧~","YD_petshop.asp")
	else
		'注册用户物品
		Dim Rs1,SQL1,hpitem,spitem,expitem,liveitem
		sql1 = "SELECT * FROM useritem WHERE username='"&Dvbbs.MemberName&"' "
		set rs1=connpet.ExeCute(sql1)
		hpitem=rs1("hpitem")
		spitem=rs1("spitem")
		expitem=rs1("expitem")
		liveitem=rs1("liveitem")	
		rs1.close
		dim petdiff,pett,petlevel,petep,petshowlevel,levelpic,intval,level1,petpic,pethp,petmaxhp
		dim petatk,petdef,updat,newpettoday,petsp,petsex,petpk
		dim hpf,spf,mypetdead,petdead,mypetsex,openpk1
		dim item1,item2,item3,item4,item5,mypet,mypetsx,imgset,msg1,msg2,msg3,msg4,msg5
		dim str,ski,def,vit,speed

		'用很无聊的循环使用变量得到每种道具的名字……
		dim rs3,swordname,necklacename,headname,bodyname,footname
		set rs3 = connpet.execute("select * from petitemshop where itemclass='sword' and itemnum="&rs("item1"))
		swordname = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='necklace' and itemnum="&rs("item2"))
		necklacename = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='head' and itemnum="&rs("item3"))
		headname = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='body' and itemnum="&rs("item4"))
		bodyname = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='foot' and itemnum="&rs("item5"))
		footname = rs3("itemname")
		rs3.close

		petlevel = sqr((Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)))
		petep = int (100 * (petlevel - int (petlevel)))
		petshowlevel = int (petlevel + 1)
		levelpic=int(petshowlevel/10)
		if levelpic>10 then levelpic=11 end if
		level1=int(petshowlevel)
		petpic=rs("mypetname")
		pethp=rs("mypethp")
		str=rs("str")
		ski=rs("ski")
		def=rs("def")
		vit=rs("vit")
		speed=rs("speed")+def+5
		petatk=rs("mypetatk")+rs("item1Num")+rs("item2Num")+int(str/2)
		petdef=rs("mypetdef")+rs("item3Num")+rs("item4Num")+rs("item5Num")+int(ski/2)
		imgset = rs("imgset")

		'获取生命上限
		hpmaxskill=1
		if rs("hpmaxskill")>0 then
			hpmaxskill=1+rs("hpmaxskill")/100
		end if
		if rs("hpmaxskill")>30 then
			hpmaxskill=1.2+rs("hpmaxskill")/100
		end if
		if rs("hpmaxskill")>100 then
			hpmaxskill=1.5+rs("hpmaxskill")/100
		end if

		petmaxhp = int((rs("mypetmaxhp")+vit)*hpmaxskill)
		hpf= int (100 * (pethp / petmaxhp)) - 1
		openpk1 = rs("openpk")
		if (rs("openpk")<2) then
			petpk="等待挑战"
		else
			petpk="拒绝挑战"
		end if
		if ( hpf >= 98 ) then hpf = hpf - 2 end if

		if pethp<1 or rs("mypetsp")<1 then
			petdead="死亡"
		else
			petdead="生存"
		end if

		if(request("action") = "atkpet") then
			dim rs2,atkname
			dim userpetlevel,leveltmp,level2,atkrand1,defrand1,atkrand2,defrand2,atktemp1,atktemp2,deftemp1,deftemp2,exp1,exp2,userpetshowlevel,userhp
			dim atktmp,atk,atktmp2,atk2,atkskill1,atkskill2,defskill1,defskill2,luck1,luck2,life1,life2,learn1,learn2,str2,ski2,def2,vit2,speed2
			atkname = checkstr(request("atkname"))
			set rs2=connpet.execute("SELECT * FROM mypetdata WHERE username='"& atkname &"'")

			if rs2.eof then
				call showmessage("他（她）没有宠物，不能PK啊~","YD_petbattle.asp")
			else
				userpetlevel=rs2("mypetlevel")
				str2=rs2("str")
				ski2=rs2("ski")
				def2=rs2("def")
				vit2=rs2("vit")
				speed2=rs2("speed")+def2
				time1=now()
				time2=DateDiff("s", rs("pktime"), time1)

				if(DvBBS.MemberName = atkname) then
					call showmessage("干吗啊，自己打自己！小心宠物中心之神给你惩罚！","YD_petbattle.asp")
				elseif (rs2("mypethp")<DEF_PET_petpkhp or rs2("mypetdead") = 1) then
					call showmessage("他（她）的宠物已经不行了，不能PK啊~你就行行好，放过他（她）吧！～","YD_petbattle.asp")
				elseif (rs2("openpk")>1) then
					call showmessage("他（她）不接受PK~你可以下战书给他（她）；约好时间再行pk！！","YD_petbattle.asp")
				elseif (openpk1>1) then
					call showmessage("你自己关闭了PK系统，所以不能PK~下次再这样，让你永远都不能关闭PK!","YD_petother.asp")
				elseif(time2<DEF_PET_petpktime) then
					time3=DEF_PET_petpktime-time2
					call showmessage("不能连续攻击，请"& time3 &"秒后再攻击;如果你再连续攻击，将没收你的宠物！","YD_petbattle.asp")
				else
					if (rs("mypetdead") = 1) then
						call showmessage("你的宝宝好象已经挂了， 救活它再PK吧。你可以到宠物道具商行购买复活药水！","YD_petbattle.asp")
					end if
					leveltmp=abs(petshowlevel-userpetlevel)
					if not Dvbbs.master and (leveltmp>DEF_PET_petpklv) then
						call showmessage("你们两个级别相差太大，不能PK；因为你的宝贝不能被别人欺负或者让你欺负别人的宝宝！","YD_petbattle.asp")
					end if
					level1=int(rs("mypetlevel"))
					level2=int(rs2("mypetlevel"))
					'获取生命上限
					hpmaxskill2=1
					if rs2("hpmaxskill")>0 then
						hpmaxskill2=1+rs("hpmaxskill")/100
					end if
					if rs2("hpmaxskill")>30 then
						hpmaxskill2=1.2+rs("hpmaxskill")/100
					end if
					if rs2("hpmaxskill")>100 then
						hpmaxskill2=1.5+rs("hpmaxskill")/100
					end if
					maxhp2 = int((rs2("mypetmaxhp")+vit2)*hpmaxskill2)
					Randomize '初始化随机数生成器。

					'各种属性的基础参数
					atkrand1=1
					defrand1=1
					atkrand2=1
					defrand2=1
					atkskill1=1
					atkskill2=1
					defskill1=1
					defskill2=1
					luck1=1
					luck2=1
					life1=1
					life2=1
					learn1=1
					learn2=1

					'攻击者的五行生克参数
					select case rs("mypetsx")
						case "金"
							if rs2("mypetsx") = "木" then atkrand1=1.5
							if rs2("mypetsx") = "土" then defrand1=0.75
							if rs2("mypetsx") = "龙" then atkrand1=0.8
						case "木"
							if rs2("mypetsx") = "土" then atkrand1=1.5
							if rs2("mypetsx") = "水" then defrand1=0.75
							if rs2("mypetsx") = "龙" then atkrand1=0.8
						case "水"
							if rs2("mypetsx") = "火" then atkrand1=1.5
							if rs2("mypetsx") = "金" then defrand1=0.75
							if rs2("mypetsx") = "龙" then atkrand1=0.8
						case "火"
							if rs2("mypetsx") = "金" then atkrand1=1.5
							if rs2("mypetsx") = "木" then defrand1=0.75
							if rs2("mypetsx") = "龙" then atkrand1=0.8
						case "土"
							if rs2("mypetsx") = "水" then atkrand1=1.5
							if rs2("mypetsx") = "火" then defrand1=0.75
							if rs2("mypetsx") = "龙" then atkrand1=0.8
						case "无"
							if rs2("mypetsx") = "龙" then atkrand1=0.7
						case "龙"
							atkrand1=1.3
					end select

					'防御者的五行生克参数
					select case rs2("mypetsx")
						case "金"
							if rs("mypetsx") = "木" then atkrand2=1.5
							if rs("mypetsx") = "土" then defrand2=0.75
							if rs("mypetsx") = "龙" then atkrand2=0.8
						case "木"
							if rs("mypetsx") = "土" then atkrand2=1.5
							if rs("mypetsx") = "水" then defrand2=0.75
							if rs("mypetsx") = "龙" then atkrand2=0.8
						case "水"
							if rs("mypetsx") = "火" then atkrand2=1.5
							if rs("mypetsx") = "金" then defrand2=0.75
							if rs("mypetsx") = "龙" then atkrand2=0.8
						case "火"
							if rs("mypetsx") = "金" then atkrand2=1.5
							if rs("mypetsx") = "木" then defrand2=0.75
							if rs("mypetsx") = "龙" then atkrand2=0.8
						case "土"
							if rs("mypetsx") = "水" then atkrand2=1.5
							if rs("mypetsx") = "火" then defrand2=0.75
							if rs1("mypetsx") = "龙" then atkrand2=0.8
						case "无"
							if rs("mypetsx") = "龙" then atkrand2=0.7
						case "龙"
							atkrand2=1.3
					end select
					'攻击者攻击技能的加成
					if rs("atkskill")>0 then
						atkskill1=1+rs("atkskill")/100
						if rs("atkskill")>30 then
							atkskill1=1.1+rs("atkskill")/100
							if rs("atkskill")>100 then
								atkskill1=1.3+rs("atkskill")/100
							end if
						end if
					end if
					'防御者攻击技能的加成
					if rs2("atkskill")>0 then
						atkskill2=1+rs("atkskill")/100
						if rs2("atkskill")>30 then
							atkskill2=1.1+rs("atkskill")/100
							if rs2("atkskill")>100 then
								atkskill2=1.3+rs("atkskill")/100
							end if
						end if
					end if
					'攻击者防御技能的加成
					if rs("defskill")>0 then
						defskill1=1+rs("defskill")/100
						if rs("defskill")>30 then
							defskill1=1.1+rs("defskill")/100
							if rs("defskill")>100 then
								defskill1=1.3+rs("defskill")/100
							end if
						end if
					end if
					'防御者防御技能的加成
					if rs2("defskill")>0 then
						defskill2=1+rs("defskill")/100
						if rs2("defskill")>30 then
							defskill2=1.1+rs("defskill")/100
							if rs2("defskill")>100 then
								defskill2=1.3+rs("defskill")/100
							end if
						end if
					end if
					'攻击者幸运技能的加成
					if rs("luckskill")>0 then
						if int((100-rs("luckskill")/2)*rnd)<2 then luck1=2
					end if
					if rs("luckskill")>30 then
						if int((100-rs("luckskill")/1.8)*rnd)<2 then luck1=2
					end if
					if rs("luckskill")>100 then
						if int((100-rs("luckskill")/1.5)*rnd)<2 then luck1=2
					end if
					'防御者幸运技能的加成
					if rs2("luckskill")>0 then
						if int((100-rs("luckskill")/2)*rnd)<2 then luck2=2
					end if
					if rs2("luckskill")>30 then
						if int((100-rs("luckskill")/1.8)*rnd)<2 then luck2=2
					end if
					if rs2("luckskill")>100 then
						if int((100-rs("luckskill")/1.5)*rnd)<2 then luck2=2
					end if
					'攻击者治疗技能的加成
					if rs("lifeskill")>0 then
						life1=1+rs("lifeskill")/100
					end if
					if rs("lifeskill")>30 then
						life1=1.2+rs("lifeskill")/100
					end if
					if rs("lifeskill")>100 then
						life1=1.5+rs("lifeskill")/100
					end if
					'防御者治疗技能的加成
					if rs2("lifeskill")>0 then
						life2=1+rs("lifeskill")/100
					end if
					if rs2("lifeskill")>30 then
						life2=1.2+rs("lifeskill")/100
					end if
					if rs2("lifeskill")>100 then  
						life2=1.5+rs("lifeskill")/100
					end if
					'攻击者学习技能的加成
					if rs("learnskill")>0 then
						learn1=1+rs("learnskill")/100
					end if
					if rs("learnskill")>30 then
						learn1=1.5+rs("learnskill")/100
					end if
					if rs("learnskill")>100 then
						learn1=2+rs("learnskill")/100
					end if
					'防御者学习技能的加成
					if rs2("learnskill")>0 then
						learn2=1+rs("learnskill")/100
					end if
					if rs2("learnskill")>30 then
						learn2=1.5+rs("learnskill")/100
					end if
					if rs2("learnskill")>100 then
						learn2=2+rs("learnskill")/100
					end if

					'攻击者对防御者的伤害
					atktemp1=(rs("mypetatk")+rs("item1Num")+rs("item2Num")+int(rs("str")/2))
					deftemp2=(rs2("mypetdef")+rs2("item3Num")+rs2("item4Num")+rs2("item5Num")+int(rs2("ski")/2))
					atktmp=int((atktemp1/2+atktemp1/2*rnd)*2*atkrand1*atkskill1-deftemp2*defrand2*defskill2)
					if luck1=2 then
						atktmp=int((atktemp1*2*atkrand1*atkskill1-deftemp2*defrand2*defskill2)*1.5)
					end if
					if (atktmp<1) then
						atk=0
					elseif not Dvbbs.master and (atktmp>1000) then
						atk=1000
					elseif (atktmp>rs2("mypethp")) then
						atk=rs2("mypethp")
					else
						atk=atktmp
					end if
					exp2=int(atk/10)

					'防御者对攻击者的伤害			
					atktemp2=(rs2("mypetatk")+rs2("item1Num")+rs2("item2Num")+int(rs2("str")/2))
					deftemp1=(rs("mypetdef")+rs("item3Num")+rs("item4Num")+rs("item5Num")+int(rs("ski")/2))
					atktmp2=int((atktemp2/2+atktemp2/2*rnd)*2*atkrand2*atkskill2-deftemp1*defrand1*defskill1)
					if luck2=2 then
						atktmp2=int((atktemp2*2*atkrand2*atkskill2-deftemp1*defrand1*defskill1)*1.5)
					end if
					if (atktmp2<1) then
						atk2=0
					elseif (atktmp2>1000) then
						atk2=1000
					elseif (atktmp2>rs("mypethp")) then
						atk2=rs("mypethp")
					else
						atk2=atktmp2
					end if

					'随机分配经验
					exp1=int(atk2/10)
					dim expz
					expz=exp1+exp2
					randomize
					exp1=cint(expz*rnd)
					exp2=expz-exp1
					exp1=int(exp1*learn1)
					exp2=int(exp2*learn2)

					'攻击先手优势
					if speed > speed2 and atk>userhp then atk2=0 end if 
					if speed < speed2 and atk2>pethp then atk=0 end if

					'躲避参数
					dim miss1,miss2
					miss1=int(rnd*(200+speed2/10-speed/10))
					miss2=int(rnd*(200+speed/10-speed2/10))

					'是否躲避成功
					if miss1<10 then atk2=0 end if
					if miss2<10 then atk=0 end if

					'判断攻击者是否死亡
					if (pethp-atk2<1) then
						pethp=0
						mypetdead=1
						exp1=0
					else
						pethp=pethp-atk2
						if learn1>1 then
							exp1=int(learn1*exp1)
						end if
						if life1>1 and atk2>3 then
							pethp= int(pethp+petmaxhp*(life1-1))
						end if
						if pethp>petmaxhp then
							pethp=petmaxhp
						end if
						mypetdead=0
					end if
	
					'宠物新等级
					petlevel = sqr((Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)))
					petshowlevel = int (petlevel + 1)

					'保存入数据库
					connpet.ExeCute("UPDATE mypetdata SET mypetexp=mypetexp+"&exp1&",mypetlevel="&petshowlevel&",mypethp="&pethp&",mypetdead="&mypetdead&",pktime="&Pet_NowString&" WHERE username='"& DvBBS.MemberName &"'")

					'判断防御者是否死亡				
					if (rs2("mypethp")-atk<1) then
						userhp=0
						mypetdead=1
						exp2=0
					else
						userhp=rs2("mypethp")-atk
						if learn2>1 then
							exp2=int(exp2*learn2)
						end if
						if life2>1 and atk>3 then
							userhp=int(userhp+maxhp2*(life2-1))
						end if
						if userhp>maxhp2 then
							userhp=maxhp2
						end if
						mypetdead=0
					end if

					'宠物新等级
					userpetlevel = sqr((Log(rs2("mypetexp")) / Log(10)) * (Log(rs2("mypetexp")) / Log(10)) * (Log(rs2("mypetexp")) / Log(10)) * (Log(rs2("mypetexp")) / Log(10)) * (Log(rs2("mypetexp")) / Log(10)))
					userpetshowlevel = int (userpetlevel + 1)
					'保存入数据库
					connpet.ExeCute("UPDATE mypetdata SET mypetexp=mypetexp+"& exp2 &",mypetlevel="&userpetshowlevel&",mypethp="&userhp&",mypetdead="&mypetdead&" WHERE username='"&atkname&"'")

					'给防御者发送攻击短消息			
					if DEF_PET_sendbattlemsg = 1 then
						msg1="你的宝宝受到 "&DvBBS.MemberName&" 的宝宝 "&atk&" 点攻击<br>"
						msg2=""
						msg4=""
						msg5=""
						if luck2=2 then
							msg2 = msg2 & "幸运技能使你的宝宝反击加倍，"
						end if
						msg3="你的宝宝进行了反击，"&msg2&"使他（她）受到 "&atk2&" 点攻击，你增加了 "&exp2&" 点经验值！<br>"
						if atk=0 then
							msg1="你的宝宝受到 "&DvBBS.MemberName&" 的宝宝的攻击，但防御成功！<br>"
						end if
						if atk2=0 then
							msg3="你的宝宝对"&DvBBS.MemberName&" 的宝宝进行反击，但反击失败！<br>"
						end if
						'治疗技能提示
						if life2>1 and atk>3 then
							msg4="你的宠物的治疗技能为宠物恢复些许生命<br>"
						end if
						'学习技能提示
						if learn2>1 then
							msg5="你的宠物的学习技能为宠物增加些许经验<br>"
						end if
						if userhp=0 then
							msg3 = "不幸牺牲"
							msg4=""
							msg5=""
						end if
						Dvbbs.execute("INSERT INTO Dv_Message (Incept, Sender, Title, Content, SendTime,flag, isSend) values('"&atkname&"','"&DvBBS.MemberName&"','你的宝宝受到攻击','"&msg1&""&msg3&""&msg4&""&msg5&"','"&now&"','0','1')")
						UPDATE_User_Msg(atkname)
					end if	

					'给攻击者发送攻击效果
					dim snum
					Randomize
					snum=Int((3 * Rnd) + 1)
					'基本输出属性
					msg1="你的宝宝给了 "&atkname&" 的宝宝 "&atk&" 点攻击<br>你增加了 "&exp1&" 点经验值<br><br>"
					msg2=""
					msg3="他（她）宝宝进行了反击，使你受到 "&atk2&" 点攻击！<br><br>"
					msg4=""
					msg5=""
					'幸运一击
					if luck1=2 then
						msg2="幸运技能使你的宝宝攻击加倍<br>"
					end if
					'攻击失败
					if atk=0 then
						msg1="你的宝宝对"&atkname&"的宝宝的攻击，但攻击失败<br><br>"
						msg2=""
					end if
					'防御反击成功
					if atk2=0 then
						msg3="你的宝宝受到"&atkname&"的宝宝反击，但防御成功<br><br>"
					end if
					'治疗技能提示
					if life1>1 and atk2>3 then
						msg4="你的宠物的治疗技能为宠物恢复些许生命<br>"
					end if
					'学习技能提示
					if learn1>1 then
						msg5="你的宠物的学习技能为宠物增加些许经验<br>"
					end if
					'pk牺牲
					if pethp=0 then
						msg3="你的宝宝受到"&atkname&"的宝宝反击，不幸牺牲<br>"
						msg4=""
						msg5=""
					end if
					call showmessage("<br><img src=""YD_plus/YD_pet/ATTACK0"& snum &".gif"" width=270 width=100><br><br>"&msg2&""&msg1&""&msg3&""&msg4&""&msg5&"","YD_petbattle.asp?atkname="&atkname&"")
				end if
			end if
		end if
		call main()		'调用主页面
	End If
End If
Set Dv_plus=Nothing
Dvbbs.Footer

'===============主页面部分=====================
sub main()
%>
<table class=tableborder1 cellspacing=1 cellpadding=3 align=center>
  <tr>
    <th height=27 align=center><%=Dvbbs.stats%></th>
  </tr>
  <tr>
    <td class=TableBody1>
      <table width="100%" align="center" cellpadding="3" cellspacing="3">
	<tr>
	  <td width="24%" rowspan="3" align="center"> 
	    <table width="79%" align="center" cellpadding="3" cellspacing="3">
	      <tr>
		<td width="100%" align="center">我的资料</td>
	      </tr>
	      <tr>
		<td align="center">
		<%
		'用户头像调用开始
		If IsNumeric(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text) And IsNumeric(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text) And Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text<>"" And Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text<>"" Then
			If Clng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text)=Clng(Dvbbs.Forum_Setting(39)) And Clng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text)=Clng(Dvbbs.Forum_Setting(38)) Then
				response.write "<img src="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text&">"
			Else
				response.write "<img src="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text&" width=100 height=100>"
			End If
		Else
			response.write "<img src=images/logo_2.gif>"
		End If
		'用户头像调用结束
		%>
		</td>
	      </tr>
	      <tr>
		<td align="center"><nobr>现金货币: <%=money%></nobr></td>
	      </tr>
	    </table>
	    <br>
	    <table width="90%" align="center" cellpadding="3" cellspacing="3">
	      <tr>
		<td align="center"><!--#include file="YD_petnav.asp"--></td>
	      </tr>
	    </table>
	  </td>
	  <td width="76%">
	    <table class=tableborder1 style="width:98%" cellspacing=1 cellpadding=3 align=center>
	      <tr>
		<th colspan=2 width="100%" align="center">我的宠物状态</th>
	      </tr>
	      <tr>
		<td class=TableBody2 width="33%" align="left">&nbsp;宠物名称：<%=rs("mypet")%></td>
		<td rowspan=8 class=TableBody1>
		  <table width="100%" cellspacing="2" cellpadding="2">
		    <tr>
		      <td width="35%">　</td>
		      <td width="20%" align="center"><img src="YD_plus/YD_pet/pet/head/<%=rs("item3")%>.gif" alt="<%=headname%> 防御力 <%=rs("item3Num")%>"></td>
		      <td width="35%">　</td>
		    </tr>
		    <tr>
		      <td align="right"><img height=30 src="YD_plus/YD_pet/pet/sword/<%=rs("item1")%>.gif" alt="<%=swordname%> 攻击力 <%=rs("item1Num")%>"></td>
		      <td rowspan="2" align="center">
			<%if rs("imgset")=-1 then%>
				<img src="YD_plus/YD_pet/pet/<%=petpic%>/<%=petpic%><%=levelpic%>.gif" border="0">
			<%else%>
				<img src="YD_plus/YD_pet/pet/<%=petpic%>/<%=petpic%><%=imgset%>.gif" border="0">
			<%end if%>
		      </td>
		      <td><img src="YD_plus/YD_pet/pet/body/<%=rs("item4")%>.gif" alt="<%=bodyname%> 防御力 <%=rs("item4Num")%>"></td>
		    </tr>
		    <tr> 
		      <td align="right"><img src="YD_plus/YD_pet/pet/necklace/<%=rs("item2")%>.gif" alt="<%=necklacename%> 攻击力 <%=rs("item2Num")%>" ></td>
		      <td><img src="YD_plus/YD_pet/pet/foot/<%=rs("item5")%>.gif" alt="<%=footname%> 防御力 <%=rs("item5Num")%>"></td>
		    </tr>
		  </table>
		</td>
	      </tr>
	      <tr>
		<td class=TableBody1 width="33%" align="left">&nbsp;宠物级别：<%=petshowlevel%></td>
	      </tr>
	      <tr>
		<td class=TableBody2 width="33%" align="left">&nbsp;宠物转生：<%=rs("relive")%></td>
	      </tr>
	      <tr>
		<td class=TableBody1 width="33%" align="left">&nbsp;宠物状态：<%=petdead%></td>
	      </tr>
	      <tr>
		<td class=TableBody2 width="33%" align="left">&nbsp;攻击力：<%=petatk%></td>
	      </tr>
	      <tr>
		<td class=TableBody1 width="33%" align="left">&nbsp;防御力：<%=petdef%></td>
	      </tr>
	      <tr>
		<td class=TableBody2 width="33%" align="left">&nbsp;宠物PK：<%=petpk%></td>
	      </tr>
	      <tr>
		<td class=TableBody1 width="33%" align="center">
		HP : <%=pethp%> / <%=petmaxhp%>
		  <table width="120" cellspacing="0" cellpadding="0">
		    <tr>
		      <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_left.gif" width=3></TD>
		      <TD width=114 background="YD_plus/YD_pet/RPG/img_backing.gif" height=13><img src="YD_plus/YD_pet/RPG/orange.gif" width="<%=hpf%>%" height="9"><img src="YD_plus/YD_pet/RPG/hp.gif" height="9"></td>
		      <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_right.gif" width=3></TD>
		    </tr>
		  </table>
		EXP : <%=petep%>%[<%=rs("mypetexp")%>]
		  <table width="120" cellspacing="0" cellpadding="0">
		    <tr>
		      <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_left.gif" width=3></TD>
		      <TD width=114 background="YD_plus/YD_pet/RPG/img_backing.gif" height=13><img src="YD_plus/YD_pet/RPG/blue.gif" width="<%=petep%>%" height="9"><img src="YD_plus/YD_pet/RPG/exp.gif" height="9"></td>
		      <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_right.gif" width=3></TD>
		    </tr>
		  </table>
		</td>
	      </tr>
	      <tr>
		<td colspan=2 class=TableBody1 width="100%" align="center">
		  <TABLE cellSpacing=3 cellPadding=3 width="100%" align=center height="75">
		    <TR>
		      <TD width="25%" height="16" align=center>HP药水拥有数量：<%=hpitem%>[<a href="YD_petitemuse.asp?action=usehp">使用</a>]</TD>
		      <TD width="25%" height="16" align="center">EXP药水拥有数量：<%=expitem%>[<a href="YD_petitemuse.asp?action=useexp">使用</a>]</TD>
		    </TR>
		    <TR>
		      <TD height="16" align="center">SP药水拥有数量：<%=spitem%>[<a href="YD_petitemuse.asp?action=usesp">使用</a>]</TD>
		      <TD height="16" align="center">复活拥有数量：<%=liveitem%>[<a href="YD_petitemuse.asp?action=uselive">使用</a>]</TD>
		    </TR>
		  </TABLE>
		</td>
	      </tr>
	    </table>
	  </td>
	</tr>
	<tr>
	  <td>
	    <table class=tableborder1 style="width:98%" cellspacing=1 cellpadding=3 align=center>
	      <tr>
		<th colspan=6 width=100% align=center><a href=YD_pettop.asp?action=pkon>宠物竞技名单</a>&nbsp;&nbsp;点击宠物名字展开攻击&nbsp;&nbsp;&nbsp;&nbsp;
		<% if not request("atkname")="" then%>
			<a href="YD_petbattle.asp?atkname=<%=Checkstr(request("atkname"))%>&action=atkpet">继续攻击<%=Checkstr(request("atkname"))%>的宠物</a>
		<%end if%>
		</th>
	      </tr>
	      <tr>
		<td class=TableBody2 width="20%">宠物主人</td>
		<td class=TableBody2 width="20%">宠物名字</td>
		<td class=TableBody2 width="15%">宠物等级</td>
		<td class=TableBody2 width="15%">宠物攻击力</td>
		<td class=TableBody2 width="15%">宠物防御力</td>
		<td class=TableBody2 width="15%">宠物状态</td>
	      </tr>
	      <tr>
		<td colspan=6 class=TableBody1 width="100%">
		<!-- #include file=YD_petpklist.asp -->
		</td>
	      </tr>
	    </table>
	  </td>
	</tr>
      </table>
    </td>
  </tr>
</table>
<%
end sub

'更新用户短信通知信息（新短信条数||新短讯ID||发信人名）
Sub UPDATE_User_Msg(username)
	Dim msginfo,i,UP_UserInfo,newmsg
	newmsg=newincept(username)
	If newmsg>0 Then
		msginfo=newincept(username) & "||" & inceptid(1,username) & "||" & inceptid(2,username)
	Else
		msginfo="0||0||null"
	End If
	Dvbbs.execute("UPDATE [Dv_User] Set UserMsg='"&Dvbbs.CheckStr(msginfo)&"' WHERE username='"&Dvbbs.CheckStr(username)&"'")
	If username=Dvbbs.MemberName Then
		UP_UserInfo=Session(Dvbbs.CacheName & "UserID")
		UP_UserInfo(30)=msginfo
		Session(Dvbbs.CacheName & "UserID")=UP_UserInfo
	Else
		Call Dvbbs.NeedUpdateList(username,1)
	End If
End Sub

'统计留言
Function newincept(iusername)
Dim Rs
Rs=Dvbbs.execute("SELECT Count(id) FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
    newincept=Rs(0)
	Set Rs=nothing
	If isnull(newincept) Then newincept=0
End Function

Function inceptid(stype,iusername)
	Set Rs=Dvbbs.execute("SELECT top 1 id,sender FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
	If not rs.eof Then
		If stype=1 Then
			inceptid=Rs(0)
		Else
			inceptid=Rs(1)
		End If
	Else
		If stype=1 Then
			inceptid=0
		Else
			inceptid="null"
		End If
	End If
	Set Rs=nothing
End Function
%>