<!-- #include file=../include/skin.asp -->
<!-- #include file=include/con_pet.asp -->
<!-- #include file=pet_conn.asp -->
<%
tit="查看宠物信息"
call web_head(2,0,0,0,0)

    dim allpetpeople,mypetname,username
    SQL = "SELECT * FROM mypetdata WHERE username='"&request.querystring("username")&"'"
    set rs = connpet.execute(SQL)
    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,str,ski,def,vit,szd,skill,hpmaxskill
dim item1,item2,item3,item4,item5,mypet,mypetsx,imgset,mypetlevel	
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)
petpic=rs("mypetname")
pethp=rs("mypethp")
str=rs("str")
ski=rs("ski")
def=rs("def")
vit=rs("vit")
szd=rs("szd")+petshowlevel*5-str-ski-def-vit
skill=rs("skill")+petshowlevel-rs("atkskill")-rs("defskill")-rs("lifeskill")-rs("luckskill")-rs("learnskill")-rs("hpmaxskill")
petatk=rs("mypetatk")+rs("item1Num")+rs("item2Num")+int(str/2)
petdef=rs("mypetdef")+rs("item3Num")+rs("item4Num")+rs("item5Num")+int(ski/2)
updat=0
newpettoday = Now()
 '获取生命上限
   	      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)


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 pethp<=0 or petsp<=0 then
    sql = "UPDATE mypetdata SET mypetdead=1 WHERE username='"&request.querystring("username")&"'"
    connpet.ExeCute(sql)
end if

item1=rs("item1")
item2=rs("item2")
item3=rs("item3")
item4=rs("item4")
item5=rs("item5")
mypet=rs("mypet")
mypetsx = rs("mypetsx")
mypetlevel = rs("mypetlevel")
imgset = rs("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

    end if
%>
<table width="760" border="0" cellspacing="1" cellpadding="5" align="center" class=TBone>
  <tr>
    <td height=27 align="center" class=tbhead2><b><font class=HeadFont><a href="petcenter.asp">返回宠物中心</a></font></b></td>
  </tr>
  <tr>
    <td class=tbbg1>
    
					<table width="100%" border="0" cellspacing="2" cellpadding="2">
                        <tr> 
							<td width="35%">　</td>
                            <td width="20%"> 
            <div align="center"><img src="images/pet/head/<%=rs("item3")%>.gif" alt="<%=headname%> 防御力 <%=rs("item3Num")%>" width="23" height="30"></div>
          </td>
                            <td width="35%">　</td>
                        </tr>
                        <tr> 
                            <td>
            <div align="right"><img height=30 src="images/pet/sword/<%=rs("item1")%>.gif" alt="<%=swordname%> 攻击力 <%=rs("item1Num")%>" width="23"></div>
          </td>
                            <td rowspan="2"><div align="center"><a href="petbattle.asp?atkname=<%=request("username")%>&action=atkpet" title="攻击 <%=request("username")%> 的宝宝">
							<%if rs("imgset")=-1 then%>
							<img src='images/pet/<%=petpic%>/<%=petpic%><%=levelpic%>.gif' border="0">
							<%else%>
							<img src='images/pet/<%=petpic%>/<%=petpic%><%=imgset%>.gif' border="0">
							<%end if%>
							</a></div></td>
                            
          <td><img src="images/pet/body/<%=rs("item4")%>.gif" alt="<%=bodyname%> 防御力 <%=rs("item4Num")%>" width="23" height="30"></td>
                        </tr>
                        <tr> 
                            <td>
            <div align="right"><img src="images/pet/necklace/<%=rs("item2")%>.gif" alt="<%=necklacename%> 攻击力 <%=rs("item2Num")%>" width="23" height="30" ></div>
          </td>
                            
          <td><img src="images/pet/foot/<%=rs("item5")%>.gif" alt="<%=footname%> 防御力 <%=rs("item5Num")%>" width="23" height="30"></td>
                        </tr>
                        </table>
                  <table width='63%' border='0' align="center" 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>
                        宠物属性：<%=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%>%<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>
                  </table></td>
              </tr>
            </table>
	</td></tr></table>
<%call web_end(0,0)%>
