<!--#include file="connection.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/plus_check.asp"-->
<!-- #include file=pet_conn.asp -->
<%

dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr,rspet,sql

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

	set rs=Dvbbs.execute("select Jamonery from [Jauser] where Jauid="&DvBBS.UserId)
      	
    money=rs("jamonery")

	    

    rs.close
    


            
dim action,petsp,pettoday,newexp,levelpic,thispetsex
if request("action") = "" then
    action = "adopt"
    else
    action = lcase(request("action"))
end if

select case action
    case "delpet"

    SQL = "SELECT * FROM mypetdata WHERE username='"& Dvbbs.MemberName &"'"
    rs.open SQL,conn,1,3
    if rs.eof then
            call showmessage("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
        else
        
        if rs("mypetdead") <> 0 then 
                call showmessage("宠物收容所不接受死亡的宠物，先复活它吧~","petmypet.asp")
            else

                petsp=DEF_PET_basicsp
                pettoday = now()
        
                newexp=rs1("mypetexp")-int(rs1("mypetexp")*20/100)
                conn.ExeCute("INSERT INTO petdeldata (username, mypet,mypetname,mypetlevel,mypetexp,mypetmaxhp,mypetatk,mypetdef,mypetsex,mypetsx,petdeldate)VALUES ('"& Dvbbs.MemberName &"', '"& rs("mypet") &"', '"& rs("mypetname") &"', '"& rs("mypetlevel") &"', '"& newexp &"','"& rs("mypetmaxhp") &"', '"& rs("mypetatk") &"', '"& rs("mypetdef") &"', '"& rs("mypetsex") &"', '"& rs("mypetsx") &"', '"& pettoday &"')")
                conn.ExeCute("DELETE FROM mypetdata WHERE username='"& Dvbbs.MemberName &"'")
                call showmessage("丢弃完了，宠物已经放在宠物收容所了","petorphanage.asp")
            
        end if

    end if
    rs.close

    case "alldelpet"

    SQL = "SELECT * FROM mypetdata WHERE username='"& Dvbbs.MemberName &"'"
    rs.open SQL,conn,1,3
    if rs.eof then
            call showmessage("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
        else

        conn.ExeCute("DELETE FROM mypetdata WHERE username='"& Dvbbs.MemberName &"'")
        call showmessage("丢弃完了，宠物已经去天堂了，你好狠心啊","petorphanage.asp")

    end if
    rs1.close

    case "adoptpet"
        
    SQL = "SELECT * FROM mypetdata WHERE username='"& Dvbbs.MemberName &"'"
    rs1.open SQL,conn,1,3
    if not rs.eof then
            call showmessage("你已经有一个宠物了，做人不要三心两意啊~","petorphanage.asp")
        else
        
        petsp=DEF_PET_basicsp
        pettoday = now()

        dim petid,mypet
        petid = request.querystring("petid")
        if petid = "" then petid = 0 end if

        SQL = "SELECT * FROM petdeldata WHERE id="&petid
        'response.write sql: response.end
        set rspet = conn.ExeCute(SQL)
        if rspet.eof then
                call showmessage("你没有成功领养宠物，你要领养的宠物不存在~","petorphanage.asp")
            else
                mypet = rspet("mypet")
                conn.ExeCute("INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,hpitem,spitem,expitem)VALUES ('"& Dvbbs.MemberName &"', '"& rspet("mypet") &"', '"& rspet("mypetname") &"', '"& rspet("mypetlevel") &"', '"& rspet("mypetexp") &"', '"& rspet("mypetmaxhp") &"', '"& rspet("mypetmaxhp") &"', '"& petsp &"', '"& rspet("mypetatk") &"', '"& rspet("mypetdef") &"', '0', '"& rspet("mypetsex") &"', '"& rspet("mypetsx") &"', '"& pettoday &"', '0', '0', '0')")
                conn.ExeCute("DELETE FROM petdeldata WHERE id="&petid)
                call showmessage("你领养了 "& mypet &" 好好照顾他啊","petorphanage.asp")
        end if
        rspet.close

    end if
    rs.close
    
end select


%>

<table border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder1">
  <tr> 
    <th height="25">&nbsp;</th>
  </tr>
  <tr> 
    <td height="200" valign="top" class=TableBody1> 
      <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" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="28%"> 
                  <div align="right"> 
                    <table width="79%"  border="0" align="center" cellpadding="3" cellspacing="3">
                      <tr> 
                        <td width="100%">
                          <div align="center"> 
                            <script src="z_visual_const2.asp?n=1"></script>
							
                            <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>
                    <table width="100%" border="0" cellspacing="4" cellpadding="4">
                      <tr> 
                        <td>
                          <div align="center"><a href="petorphanage.asp?action=adopt">领养宠物</a></div>
                          <div align="center"><a href="petorphanage.asp?action=del">丢弃宠物</a></div>
                        </td>
                      </tr>
                    </table>
                    <table width="90%"  border="0" align="center" cellpadding="3" cellspacing="3">
                      <tr> 
                        <td>
                          <div align="center"></div>
						  
                          <!-- #include file=petnav.asp -->
						  
                        </td>
                      </tr>
                    </table>
                  </div>
                </td>
                <td> 
                  <div align="center"> </div>
                  <div align="center"></div>
                  <%if action = "adopt" then%>
                  <table class=text1 cellspacing=1 cellpadding=3 width=100% align=center border=0>
                    <tr> 
                      <td colspan="5"> <div align=center> 
                        <table width="100%" border="0" align="center" cellpadding="3" cellspacing="3">
                          <tr> 
                            <td width="28%">
                              <div align="center">宠物照片</div>
                            </td>
                            <td width="24%">
                              <div align="center">宠物介绍</div>
                            </td>
                            <td width="33%"> 
                              <div align="center">收养宠物</div>
                            </td>
                          </tr>
                          <%
SQL = "SELECT * FROM petdeldata ORDER BY mypetlevel DESC"
set rspet = conn.ExeCute(SQL)
dim num
num = 0

while not rspet.eof and num < 10
            
levelpic=int(rspet("mypetlevel")/10)
if (levelpic>10) then levelpic=11 end if
if (rspet("mypetsex")=1) then
    thispetsex="雄"
else 
    thispetsex="雌"
end if
%>
                          <tr>
                            <td width='28%'>
                              <div align='center'><img src='images/pet/<%=rspet("mypetname")%>/<%=rspet("mypetname")%><%=levelpic%>.gif'></div>
                            </td>
                            <td width='24%'>宠物名字：<%=rspet("mypet")%><br>
                              宠物级别：<%=rspet("mypetlevel")%><br>
                              宠物攻击力：<%=rspet("mypetatk")%><br>
                              宠物防御力：<%=rspet("mypetdef")%><br>
                              宠物性别：<%=thispetsex%><br>
                              宠物前主人：<a href="dispuser.asp?name=<%=rspet("username")%>"><%=rspet("username")%></a></div>
                        </table>
                      </td>
                      <td width='10%'>
                        <div align='center'> 
                          <input name='Submit2' type='button' value='领养宠物' onClick="javascript:window.location='petorphanage.asp?action=adoptpet&petid=<%=rspet("id")%>';">
                        </div>
                      </td>
                    </tr>
                    <%
rspet.movenext
num = num + 1
wend
rspet.close
%>
                  </table></DIV>
                </td>
              </tr>
            </table>
            <%end if%>
            <%if action = "del" then%>
            <form action=petorphanage.asp name="name" mtehod=post>
              <table class=text1 cellspacing=0 cellpadding=0 width=100% align=center border=0>
                <tr> 
                  <td width="57%"> 
                    <div align=center><img src="images/pet/30.gif"></div>
                  </td>
                </tr>
                <tr> 
                  <td>
                    <div align="center"><br>
                      <a href="petorphanage.asp?action=delpet">放进孤儿院</a> <a href="petorphanage.asp?action=alldelpet">彻底丢弃</a></div>
                  </td>
                </tr>
              </table>
            </form>
            <%end if%>
          </td>
        </tr>
      </table>


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