<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="YD_pet_conn.asp"-->

<%
'' ==========================================================
'     开发人员：Tony(绿光光)
'     编写时间：2005-6-21
'     文件名称：YD_pet_Load.asp
'     参数说明：	user:	帖子的作者
'				style:	效果选择
'     功能说明：生成xml树，调用pet节点
'' ==========================================================

Response.write "<?xml version=""1.0"" encoding=""gb2312""?>"
Response.write "<Tony>"
call Main()
Response.write "</Tony>"
Sub Main
	Response.Write "<pet>"& showPet(Request.querystring("user")) &"</pet>"
End Sub

Function showPet(Str)
	Dim poppet,pet,User
	User=Str
	poppet="select * from [mypetdata] where username ='"& User &"'"
	set rspet = connpet.execute(poppet)
if not rspet.eof then
Dim petname,t,today,pett,petlevel,petep,petshowlevel,level1,level2,petpic,pethp,petatk,petdef,petmaxhp,petsp,levelpic,mypet,mypetlevel,relive
Dim hpf,spf,petdead,petsex,petpk,mypetsx,imgset,str1,ski,def,vit,hpmaxskill
petname = rspet("mypet")
t=now()
today = date()
pett= DateDiff("d", rspet("petregdate"), today)    
petlevel = sqr((Log(rspet("mypetexp")) / Log(10)) * (Log(rspet("mypetexp")) / Log(10)) * (Log(rspet("mypetexp")) / Log(10)) * (Log(rspet("mypetexp")) / Log(10)) * (Log(rspet("mypetexp")) / Log(10)))
petsex = rspet("mypetsex")
		relive=int(rspet("relive"))  '转生设置
		if relive<1 then 
			relive = "{font color=""red""}未{/font}"
		else
			relive=relive &" 转"
		end if
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/2)
level2=int(petshowlevel/2)
petpic=rspet("mypetname")
pethp=rspet("mypethp")
str1=rspet("str")
ski=rspet("ski")
def=rspet("def")
vit=rspet("vit")


petatk=rspet("mypetatk")+rspet("item1Num")+rspet("item2Num")+int(str1/2)
petdef=rspet("mypetdef")+rspet("item3Num")+rspet("item4Num")+rspet("item5Num")+int(ski/2)


  '获取生命上限
          hpmaxskill=1
          if rspet("hpmaxskill")>0 then
          hpmaxskill=1+rspet("hpmaxskill")/100
          end if 
          if rspet("hpmaxskill")>30 then
          hpmaxskill=1.2+rspet("hpmaxskill")/100
          end if 
          if rspet("hpmaxskill")>100 then
          hpmaxskill=1.5+rspet("hpmaxskill")/100
          end if 
          petmaxhp = int((rspet("mypetmaxhp")+vit)*hpmaxskill)
petsp=rspet("mypetsp")-pett*DEF_PET_basicsp2
if(petsp>DEF_PET_basicsp) then petsp=DEF_PET_basicsp end if
hpf= int (100 * (pethp / petmaxhp)) - 1
spf= int (100 * (petsp / DEF_PET_basicsp)) - 1
if (pethp<0) then pethp=0 end if
if (petsp<0) then petsp=0 end if
if (rspet("openpk") < 2) then
petpk="来啊，PK，PK"
else
petpk="我不想打，不想不想……"
end if
if ( hpf >= 98 ) then hpf = hpf - 2 end if
if ( spf >= 98 ) then spf = spf - 2 end if


if pethp<1 or petsp<1 then 
petdead= "死亡"
else
if petsp<1000 then
petdead="<font color=red>我快饿死了,主人虐待我!</font>"
else
petdead= "生存"
end if
end if


if petsex>1 then 
petsex= "女生"
else
petsex= "男生"
end if


mypet=rspet("mypet")
mypetsx = rspet("mypetsx")
mypetlevel = rspet("mypetlevel")
dim petkill,pic
if (rspet("mypetdead") = 1) then
petkill="d-"
else
petkill=""
end if
imgset = rspet("imgset")    
if (imgset=-1)  then 
pic=levelpic
else
pic=imgset
end if
		Select Case Request.querystring("style")
			Case 1
				showPet="{table border=""0"" width=""100%""}" &_
				"{tr}" &_
				"{td}" &_
				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_ 
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{tr}{td}" &_ 
				"{br}" &_
				"{div align=""center""}{a href=""YD_petbattle.asp?atkname="& User &"&amp;action=atkpet"" title="& petsex &"}{img src=""YD_Plus/YD_pet/pet/"& petpic &"/"& petkill &""& petpic &""& pic &".gif"" border=""0""}{/a}{/div}" &_
				"{br}{/td}{/tr}{/table}{/td}{/tr}{/table}" &_
				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_ 
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{/table}{/td}{/tr}{/table}" &_
				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_ 
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{tr}{td}宠物状态："& petdead &" {/span}{/td}{/tr}{/table}{/td}{/tr}{/table}" &_
				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_ 
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{tr}{td}宠物级别："& petshowlevel &" {/span}{/td}{/tr}{/table}{/td}{/tr}{/table}" &_
				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_ 
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{tr}{td}宠物PK："& petpk &" {/span}{/td}{/tr}{/table}{/td}{/tr}{/table}" &_

				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{tr}{td}" &_ 
				"HP : "& pethp &" / "& petmaxhp &" {table width=""90%"" border=""0"" cellspacing=""0"" cellpadding=""0"" bordercolor=""#000000""}  {tr}{TD width=""3"" height=""13""}{IMG height=13 src=""YD_Plus/YD_pet/rpg/img_left.gif"" width=""3""}{/TD}{TD width=""98%"" 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}{/span}{/td}{/tr}{/table}{/td}{/tr}{/table}" &_
				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{tr}{td}" &_ 
				"SP : "& petsp &" / "& DEF_PET_basicsp &" {table width=""90%"" border=""0"" cellspacing=""0"" cellpadding=""0"" bordercolor=""#000000""}  {tr}{TD width=""3"" height=""13""}{IMG height=13 src=""YD_Plus/YD_pet/rpg/img_left.gif"" width=""3""}{/TD}{TD width=""98%"" background=""YD_Plus/YD_pet/rpg/img_backing.gif"" height=""13""}{img src=""YD_Plus/YD_pet/rpg/green.gif"" width="""& spf &"%"" height=""9""}{img src=""YD_Plus/YD_pet/rpg/mp.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}{/span}{/td}{/tr}{/table}{/td}{/tr}{/table}" &_
				"{table width=""100%"" border=""0"" cellspacing=""1""}{tr}{td}" &_
				"{table width=""100%"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""2"" style=""BORDER-left: #999999 1px solid;BORDER-right: #999999 1px solid;BORDER-TOP: #999999 1px solid;  BORDER-BOTTOM: #999999 1px solid;""}" &_
				"{tr}{td}" &_ 
				"EXP : "& petep &"%["& rspet("mypetexp") &"] {table width='90%' border='0' cellspacing='0' cellpadding='0' bordercolor='#000000'}  {tr}{TD width=3 height=13}{IMG height=13 src='YD_Plus/YD_pet/rpg/img_left.gif' width=3}{/TD}{TD width=98% 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}{/span}{/td}{/tr}{/table}{/td}{/tr}{/table}{/td}{/tr}{/table}"
			Case 2
				showPet = "{table collapse cellpadding=0 width=90% border=0 cellspacing=0 bordercolorlight=#a0cef}{tbody} {TR}{td WIDTH=100% }{div align=center}{a href=YD_petbattle.asp?atkname="& User &"&amp;action=atkpet}{img src=YD_Plus/YD_pet/pet/"&petpic&"/"&petkill&""&petpic&""&pic&".gif border=0}{/a}{BR}{div align=left}&#160;&#160;&#160;&#160;等级："&mypetlevel&"     转生："&turn&"{BR}&#160;&#160;&#160;&#160;属性："&mypetsx&"&#160;&#160; {a href=YD_petrisk.asp target=_blank title=宠物大冒险}宠物大冒险{/a} {br}&#160;&#160;&#160;&#160;攻击："&petatk&"&#160;&#160;&#160;  防御："&petdef&" {/div}HP : "&pethp&" / "&petmaxhp&"{br} {table width=120 border=0 cellspacing=0 cellpadding=0 bordercolor=#000000}{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}SP : "&petsp&" / "&DEF_PET_basicsp&"{br} {table width=120 border=0 cellspacing=0 cellpadding=0 bordercolor=#000000}{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/green.gif width="&spf&"% height=9}{img src=YD_Plus/YD_pet/rpg/mp.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 &"%["& rspet("mypetexp") &"]{br} {table width=120 border=0 cellspacing=0 cellpadding=0 bordercolor=#000000}{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}{/div}{/TD}{/TR}{/TBODY}{/TABLE}"
		End Select
	else
		   showPet = "&#160;&#160;&#160;&#160;{FONT COLOR=""#FF0000""}还没买宠物看什么看？{/FONT}{br /}"
	end if
	'任务结束清扫战场
	rspet.close
	set rspet = nothing
	connpet.close
End Function
%>