<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!-- #include file=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,"","宠物中心","petcenter.asp"

if DvBBS.UserId = 0 then
	AlarmErrmsg
else
    dim money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg
    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("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
		else

dim t,today,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
dim item1,item2,item3,item4,item5,mypet,mypetsx,hpitem,atkitem,spitem,defitem,expitem,liveitem,wpitem,amitem,imgset	

'用很无聊的循环使用变量得到每种道具的名字……
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

t=now()
today = date()
petdiff = DateDiff("d", rs("petregdate"), today)

pett= DateDiff("d", rs("petregdate"), today)

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/2)
petpic=rs("mypetname")
pethp=rs("mypethp")
petmaxhp=rs("mypetmaxhp")
petatk=rs("mypetatk")+rs("item1Num")+rs("item2Num")+2+level1
petdef=rs("mypetdef")+rs("item3Num")+rs("item4Num")+rs("item5Num")+3+level1
updat=0
newpettoday = Now()
if petshowlevel<2 then 
	petmaxhp = DEF_PET_basichp
else 
	petmaxhp=DEF_PET_basichp + petshowlevel*5
end if

if pethp > petmaxhp then
	pethp = petmaxhp
end if

petsp=rs("mypetsp")-pett*DEF_PET_basicsp2
if petsp>DEF_PET_basicsp then
	petsp=DEF_PET_basicsp
end if	
if pett>0 then
	updat=1
end if
hpf= int(100 * (pethp / petmaxhp)) - 1
spf= int(100 * (petsp / DEF_PET_basicsp)) - 1
if pethp<1 then
	pethp=0
	mypetdead=1
	updat=1
elseif petsp<1 then
	petsp=0
	mypetdead=1
	updat=1
else 
	mypetdead=0
	updat=1
end if

if pethp<1 or petsp<1 then
	petdead="死亡"
else
	petdead="生存"
end if
if rs("mypetsex")<2 then 
	petsex="雄"
	else 
	petsex="雌"
end if
if rs("openpk")<2 then 
	petpk="等待挑战"
else 
	petpk="拒绝挑战"
end if
if hpf >= 98 then hpf = hpf - 2 end if
if spf >= 98 then spf = spf - 2 end if
dim petkill
if petdead="死亡" then
	petkill="d-"
else
	petkill=""
end if

if updat=1 then
	sql = "UPDATE mypetdata SET mypetlevel="& petshowlevel &",mypethp="& pethp &",mypetsp="&petsp&",mypetmaxhp="&petmaxhp&",mypetdead="&mypetdead&",petregdate='"&newpettoday&"' WHERE username='"& DvBBS.MemberName &"'"
	connpet.ExeCute(sql)
	updat=0
end if

item1 = rs("item1")
item2 = rs("item2")
item3 = rs("item3")
item4 = rs("item4")
item5 = rs("item5")
mypet = rs("mypet")
mypetsx = rs("mypetsx")
hpitem = rs("hpitem")
atkitem = rs("atkitem")
spitem = rs("spitem")
defitem = rs("defitem")
expitem = rs("expitem")
liveitem = rs("liveitem")
wpitem = rs("weopitem")
amitem = rs("amoritem")
imgset = rs("imgset") 
	end if
	
%>
<table width="100%" border="0" cellspacing="1" cellpadding="5" align="center" class=TBone>
  <tr>
	<td height=27 align="center" class=tbhead2><b><font class=HeadFont><%=stats%></font></b></td>
  </tr>
  <tr>
	<td class=tbbg1>
	
<table width="100%"  border="0" align="center" cellpadding="3" cellspacing="3">
<tr><td width="24%" rowspan="3"><div align="center"> 
<table width="79%"  border="0" align="center" cellpadding="3" cellspacing="3">
<tr><td width="100%"><div align="center">我的资料</div></td>
</tr><tr><td><div align="center">
					<%
            		If IsNumeric(Dvbbs.MyUserInfo(12)) And IsNumeric(Dvbbs.MyUserInfo(13)) And Dvbbs.MyUserInfo(13)<>"" And Dvbbs.MyUserInfo(12)<>"" Then
            			If Clng(Dvbbs.MyUserInfo(13))=Clng(Dvbbs.Forum_Setting(39)) And Clng(Dvbbs.MyUserInfo(12))=Clng(Dvbbs.Forum_Setting(38)) Then
            			response.write "<img src="&Dvbbs.MyUserInfo(11)&">"
            			Else
            			response.write "<img src="&Dvbbs.MyUserInfo(11)&" width=60 height=60>"
            			End If
            		Else
            			response.write "<img src=images/logo_2.gif>"
            		End If
					%>
					<br><img src=../images/blank.gif width=2 height=5><br>
</div></td>
</tr><tr>
                    <td> <div align="center">
                        <nobr>现金货币: <%=money%></nobr>
                        </div></td>
                        </tr></table><br>
<table width="90%"  border="0" align="center" cellpadding="3" cellspacing="3">
<tr><td><div align="center"></div>
<!-- #include file=petnav.asp --></td></tr></table><br><br>
<table width="79%" border="0" align="center" cellpadding="3" cellspacing="3">
<tr><td width="100%"><div align="center"><img src="images/pet/25.gif"></div></td></tr></table></div>
<div align="center"></div></td><td width="76%">
					<table width="100%" border="0" cellspacing="2" cellpadding="2">
                        <tr> 
							<td width="35%">&nbsp;</td>
                            <td width="20%"> <div align="center"><img src="images/pet/head/<%=rs("item3")%>.gif" alt="<%=headname%> 防御力 <%=rs("item3Num")%>"></div></td>
                            <td width="35%">&nbsp;</td>
                        </tr>
                        <tr> 
                            <td><div align="right"><img height=30 src="images/pet/sword/<%=rs("item1")%>.gif" alt="<%=swordname%> 攻击力 <%=rs("item1Num")%>"></div></td>
                            <td rowspan="2"><div align="center">
							<%if rs("imgset")=-1 then%>
							<img src='images/pet/<%=petpic%>/<%=petkill%><%=petpic%><%=levelpic%>.gif' border="0">
							<%else%>
							<img src='images/pet/<%=petpic%>/<%=petkill%><%=petpic%><%=imgset%>.gif' border="0">
							<%end if%>

							</div></td>
                            <td><img src="images/pet/body/<%=rs("item4")%>.gif" alt="<%=bodyname%> 防御力 <%=rs("item4Num")%>"></td>
                        </tr>
                        <tr> 
                            <td><div align="right"><img src="images/pet/necklace/<%=rs("item2")%>.gif" alt="<%=necklacename%> 攻击力 <%=rs("item2Num")%>" ></div></td>
                            <td><img src="images/pet/foot/<%=rs("item5")%>.gif" alt="<%=footname%> 防御力 <%=rs("item5Num")%>"></td>
                        </tr>
                        </table>
				  <br>
				  <table width='100%' border='0' cellpadding='1' cellspacing='1'>
					<tr><td width='33%'><div align="left">宠物名称：<%=mypet%>
						  <br>
						  宠物性别：<%=petsex%><br>
						  攻击力：<%=petatk%><br>
						  防御力：<%=petdef%></div></td>
					  <td width='33%'> 宠物状态：<%=petdead%><br>
						宠物级别：<%=petshowlevel%><br>
						宠物转生：<%=rs("relive")%><br>
						宠物属性：<%=mypetsx%><br>
						宠物PK：<%=petpk%></td>
					  <td width='33%'> 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='images/rpg/img_left.gif' width=3></TD><TD width=114 background=images/rpg/img_backing.gif height=13><img src='images/rpg/orange.gif' width='<%=hpf%>%' height='9'><img src='images/rpg/hp.gif' height='9'></td>
<TD width=3 height=13><IMG height=13 src='images/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='images/rpg/img_left.gif' width=3></TD><TD width=114 background=images/rpg/img_backing.gif height=13><img src='images/rpg/green.gif' width='<%=spf%>%' height='9'><img src='images/rpg/mp.gif' height='9'></td>
<TD width=3 height=13><IMG height=13 src='images/rpg/img_right.gif' width=3></TD>
</tr></table>EXP : <%=petep%>%[<%=rs("mypetexp")%>]<br> <table width='120' border='0' cellspacing='0' cellpadding='0' bordercolor='#000000'><tr><TD width=3 height=13><IMG height=13 src='images/rpg/img_left.gif' width=3></TD>
<TD width=114 background=images/rpg/img_backing.gif height=13><img src='images/rpg/blue.gif' width='<%=petep%>%' height='9'><img src='images/rpg/exp.gif' height='9'></td>
<TD width=3 height=13><IMG height=13 src='images/rpg/img_right.gif' width=3></TD>
</tr></table></td></tr></table>
				</td>
			  </tr>
<tr><td><TABLE cellSpacing=3 cellPadding=3 width="100%" align=center border=0>
					<TR> 
					  <TD width="25%"> <DIV align=center><IMG height=35 src="images/pet/hp.gif" width=34><BR>
						  HP药水</DIV></TD>
					  <TD width="25%"> <DIV align=center>拥有数量：<%=hpitem%> 
						  <BR>
						  [<a href="petitemuse.asp?action=usehp">使用</a>]</DIV></TD>
					  <TD width="25%"><div align="center"> <IMG height=35 src="images/pet/atk.gif" width=34><BR>
						  攻击力药水</div></TD>
					  <TD width="25%"><div align="center">拥有数量：<%=atkitem%><BR>
						  [<a href="petitemuse.asp?action=useatk">使用</a>]</div></TD>
					</TR>
					<TR> 
					  <TD><DIV align=center><img height=35 src="images/pet/sp.gif" width=35><BR>
						  SP药水</DIV></TD>
					  <TD><DIV align=center>拥有数量：<%=spitem%><BR>
						  [<a href="petitemuse.asp?action=usesp">使用</a>]</DIV></TD>
					  <TD><div align="center"><IMG height=35 src="images/pet/def.gif" width=34><BR>
						  防御力药水</div></TD>
					  <TD><div align="center">拥有数量：<%=defitem%><BR>
						  [<a href="petitemuse.asp?action=usedef">使用</a>]</div></TD>
					</TR>
					<TR> 
					  <TD><DIV align=center><IMG height=35 src="images/pet/exp.gif" width=35><BR>
						  EXP药水</DIV></TD>
					  <TD width="25%"> <div align="center">拥有数量：<%=expitem%><BR>
						  [<a href="petitemuse.asp?action=useexp">使用</a>]</div></TD>
					  <TD><div align="center"><br>
						  <IMG height=35 src="images/pet/liv.gif" width=34><BR>
						  <font color="#000000">复活药水</font></div></TD>
					  <TD><div align="center">拥有数量：<%=liveitem%><BR>
						  [<a href="petitemuse.asp?action=uselive">使用</a>]</div></TD>
					</TR>
					<TR> 
					  <TD><DIV align=center><IMG height=40 src="images/pet/wp.gif" width=40><BR>
						  武器升级材料</DIV></TD>
					  <TD width="25%"> <div align="center">拥有数量：<%=wpitem%></div></TD>
					  <TD><div align="center"><br>
						  <IMG height=40 src="images/pet/am.gif" width=40><BR>
						  防具升级材料</div></TD>
					  <TD><div align="center">拥有数量：<%=amitem%></div></TD>
					</TR>
				  </TABLE></td>
</tr></table>

	</td></tr></table>
<% End If  :   Set Dv_plus=Nothing : Dvbbs.Footer %>
