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

<%
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr,imgset
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 allpetpeople,mypetname,mypet,levelpic,mypetlevel,username,level1,petatk,petdef,petdead
	dim str,ski,def,vit
	Dim Rs,SQL
	call main()
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 valign=top>
      <table width="100%" cellspacing="2" cellpadding="2">
	<tr>
	  <td width="30%" valign=top>
	    <table width="100%" align="center" cellpadding="2" cellspacing="2">
	      <tr> 
		<td align="center"><img src="YD_plus/YD_pet/PET/28.gif" width="150" height="150"></td>
	      </tr>
	    </table>
	    <br>
	    <br>
	    <table width="90%" align="center" cellpadding="3" cellspacing="3">
	      <tr> 
		<td align="center">
		<!-- #include file=YD_petnav.asp -->
		</td>
	      </tr>
	    </table>
	  </td>
	  <td align=center valign=top>
<%
	select case lcase(request("action"))
		case "pkon"
%>
	    <table class=tableborder1 style="width:100%" cellspacing=1 cellpadding=3 align=center>
	      <tr>
		<td class=TableBody2 width="20%" align=center>宠物主人</td>
		<td class=TableBody2 width="20%" align=center>宠物名字</td>
		<td class=TableBody2 width="15%" align=center>宠物等级</td>
		<td class=TableBody2 width="15%" align=center>宠物攻击力</td>
		<td class=TableBody2 width="15%" align=center>宠物防御力</td>
		<td class=TableBody2 width="15%" align=center>宠物状态</td>
	      </tr>
<%
			SQL = "SELECT * FROM mypetdata where openpk<2 ORDER BY relive DESC,mypetexp DESC"
			set rs = connpet.execute(SQL)
			while not rs.eof 
				str=rs("str")
				ski=rs("ski")
				def=rs("def")
				vit=rs("vit")
				level1=int(rs("mypetlevel"))
				petatk=rs("mypetatk")+rs("item1Num")+rs("item2Num")+int(str/2)
				petdef=rs("mypetdef")+rs("item3Num")+rs("item4Num")+rs("item5Num")+int(ski/2)
				if rs("mypethp")<1 or rs("mypetsp")<1 then 
					petdead="死亡"
				else
					petdead="生存"
				end if
%>
	      <tr>
		<td class=TableBody1 width="20%" align="center"><a href="dispuser.asp?name=<%=rs("username")%>"><%=rs("username")%></a></td>
		<td class=TableBody1 width="20%" align="center"><a href="YD_petview.asp?username=<%=rs("username")%>"><%=rs("mypet")%></a></td>
		<td class=TableBody1 width="15%" align="center"><%=rs("mypetlevel")%></td>
		<td class=TableBody1 width="15%" align="center"><%=petatk%></td>
		<td class=TableBody1 width="15%" align="center"><%=petdef%></td>
		<td class=TableBody1 width="15%" align="center"><%=petdead%></td>
	      </tr>
<%
				rs.movenext	
			wend
			rs.close
%>
	    </table>
<%
		case else
%>
	    <table class=tableborder1 style="width:100%" cellspacing=1 cellpadding=3 align=center>
	      <tr>
		<td class=TableBody2 width="20%" align="center">宠物照片</td>
		<td class=TableBody2 width="20%" align="center">宠物名字</td>
		<td class=TableBody2 width="20%" align="center">宠物等级</td>
		<td class=TableBody2 width="20%" align="center">宠物转生</td>
		<td class=TableBody2 width="20%" align="center">宠物主人</td>
	      </tr>

<%
			SQL = "SELECT top 10 username,mypet,mypetlevel,mypetname,imgset,relive FROM mypetdata ORDER BY relive DESC,mypetexp DESC"
			set rs = connpet.execute(SQL)
			dim num
			num = 0
			while not rs.eof and num < 10
				levelpic=int(rs("mypetlevel")/10)
				if levelpic>10 then levelpic=11 end if
				imgset = rs("imgset")
%>
	      <tr>
		<td class=TableBody1 width="20" align="center">
		<%if rs("imgset")=-1 then%>
			<IMG src="YD_plus/YD_pet/PET/<%=rs("mypetname")%>/<%=rs("mypetname")%><%=levelpic%>.gif">
		<%else%>
			<IMG src="YD_plus/YD_pet/PET/<%=rs("mypetname")%>/<%=rs("mypetname")%><%=imgset%>.gif">
		<%end if%>
		</td>
		<td class=TableBody1 width="20%" align="center"><a href="YD_petview.asp?username=<%=rs("username")%>"><%=rs("mypet")%></a></td>
		<td class=TableBody1 width="20%" align="center"><%=rs("mypetlevel")%></td>
		<td class=TableBody1 width="20%" align="center"><%=rs("relive")%></td>
		<td class=TableBody1 width="20%" align="center"><a href="dispuser.asp?name=<%=rs("username")%>"><%=rs("username")%></a></td>
	      </tr>
<%
				rs.movenext	
				num = num + 1
			wend
			rs.close
%>
	    </table>
<%
	end select
%>
	  </td>
	</tr>
      </table> 
    </td>
  </tr>
</table>
<%
end sub
%>