<!--#include file="Inc.asp"-->
<!-- #include file=pet_conn.asp -->
<%
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr,action
If Not BBS94KK.Founduser Then BBS94KK.GoToErr(10)
BBS94KK.Head("宠物宝贝 → 我的宠物")

    dim money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg,hpmaxskill,maxhp
    dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
    
    Dim Rs,SQL

	set rs=bbs94kk.execute("select * from [kk_User] where name='"&bbs94kk.myname &"'")
      	
   money=rs("coin")
    Form_userphoto = Rs("pic")
	DEF_PointsName="金币"

		Form_FaceWidth = Rs("picW")
		Form_FaceHeight = Rs("picH")	
		rs.close
	
	sql = "SELECT * FROM mypetdata WHERE username='"& bbs94kk.myname &"' "
		rs.open sql,connpet,1,3
	if rs.eof then
'call showmessage("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
Response.Write "<script language=JavaScript>{alert('你还没有宠物啊，快攒钱去买吧~');(location.href = 'petshop.asp')}</script>"
		else

dim t,today,petdiff,pett,petlevel,petep,petshowlevel,levelpic,intval,level1,petpic,pethp,petmaxhp,atkskill,defskill,lifeskill,luckskill,learnskill
dim petatk,petdef,updat,newpettoday,petsp,petsex,petpk
dim hpf,spf,mypetdead,petdead,mypetsex,str,ski,def,vit,szd,szd1,szd2,szd3,szd4,tszd,skill,tskill,it,skill1,skill2,skill3,skill4,skill5,skill6,speed
dim item1,item2,item3,item4,item5,mypet,mypetsx,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)
petpic=rs("mypetname")
pethp=rs("mypethp")

str=rs("str")
ski=rs("ski")
def=rs("def")
vit=rs("vit")
speed=rs("speed")+def
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="style='filter: Gray;' onLoad='javascript:if(this.width>100)this;if(this.height>100)this;'"
else
petkill=""
end if

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


'宠物的攻击技能
atkskill="atkskill_0"

if rs("atkskill")>0 then
    atkskill="atkskill_1"
end if

if rs("atkskill")>30 then
    atkskill="atkskill_2"
end if

if rs("atkskill")>100 then
    atkskill="atkskill_3"
end if



'宠物的防御技能
defskill="defskill_0"

if rs("defskill")>0 then
    defskill="defskill_1"
end if

if rs("defskill")>30 then
    defskill="defskill_2"
end if

if rs("defskill")>100 then
    defskill="defskill_3"
end if


'宠物的治疗技能
lifeskill="lifeskill_0"

if rs("lifeskill")>0 then
    lifeskill="lifeskill_1"
end if

if rs("lifeskill")>30 then
    lifeskill="lifeskill_2"
end if

if rs("lifeskill")>100 then
    lifeskill="lifeskill_3"
end if


'宠物的幸运技能
luckskill="luckskill_0"

if rs("luckskill")>0 then
    luckskill="luckskill_1"
end if

if rs("luckskill")>30 then
    luckskill="luckskill_2"
end if

if rs("luckskill")>100 then
    luckskill="luckskill_3"
end if



'宠物的学习技能
learnskill="learnskill_0"

if rs("learnskill")>0 then
    learnskill="learnskill_1"
end if

if rs("learnskill")>30 then
    learnskill="learnskill_2"
end if

if rs("learnskill")>100 then
    learnskill="learnskill_3"
end if



'宠物的血魔技能
hpmaxskill="hpmaxskill_0"

if rs("hpmaxskill")>0 then
    hpmaxskill="hpmaxskill_1"
end if

if rs("hpmaxskill")>30 then
    hpmaxskill="hpmaxskill_2"
end if

if rs("hpmaxskill")>100 then
    hpmaxskill="hpmaxskill_3"
end if

item1 = rs("item1")
item2 = rs("item2")
item3 = rs("item3")
item4 = rs("item4")
item5 = rs("item5")
mypet = rs("mypet")
mypetsx = rs("mypetsx")
imgset = rs("imgset") 
end if
	


'注册用户物品
Dim Rs1,SQL1,hpitem,spitem,expitem,liveitem,weopitem,amoritem,defitem
sql1 = "SELECT * FROM useritem WHERE username='"&bbs94kk.myname&"' "
set rs1=connpet.ExeCute(sql1)
hpitem=rs1("hpitem")
spitem=rs1("spitem")
expitem=rs1("expitem")
'defitem=rs1("defitem")
liveitem=rs1("liveitem")	
weopitem=rs1("weopitem")
amoritem=rs1("amoritem")
	rs1.close
		szd1 = int(request("szd1"))
		szd2 = int(request("szd2"))
		szd3 = int(request("szd3"))
		szd4 = int(request("szd4"))
	if  request("action") = "" and szd>0 then
    action = "show"
    else
    action = lcase(request("action"))
	end if	
	
	select case action
    case "sure"
			if (szd1<0 or szd2<0 or szd3<0 or szd4<0) then
'call showmessage("天哪，素质点不能是负的~","petmypet.asp")
Response.Write "<script language=JavaScript>{alert('天哪，素质点不能是负的~');(location.href = 'petmypet.asp')}</script>"
            end if
	case "add"
		tszd=szd-szd1-szd2-szd3-szd4
		if (szd-szd1-szd2-szd3-szd4<0) then
'call showmessage("你没有那么多的素质点","petmypet.asp")
Response.Write "<script language=JavaScript>{alert('你没有那么多的素质点');(location.href = 'petmypet.asp')}</script>"
        elseif (szd1<0 or szd2<0 or szd3<0 or szd4<0) then
'call showmessage("你输入的素质点有误，请重新输入~","petmypet.asp")
Response.Write "<script language=JavaScript>{alert('你输入的素质点有误，请重新输入~');(location.href = 'petmypet.asp')}</script>"
        else
            'Call UpdateUserInfo(-tszd,0,0,0,0,0)
            connpet.ExeCute("UPDATE mypetdata SET str=str+"&szd1&",ski=ski+"&szd2&",def=def+"&szd3&",vit=vit+"&szd4&" WHERE username='"&bbs94kk.myname&"'")
'call showmessage("加点成功!<br><br>力量增加了 "&szd1&" 点<br>皮肤增加了 "&szd2&" 点<br>敏捷增加了 "&szd3&" 点<br>体力增加了 "&szd4&" 点","petmypet.asp")
Response.Write "<script language=JavaScript>{alert('加点成功!力量增加了 "&szd1&" 点皮肤增加了 "&szd2&" 点敏捷增加了 "&szd3&" 点体力增加了 "&szd4&" 点');(location.href = 'petmypet.asp')}</script>"
        end if
	case "addskill"
		tskill=skill
		skill1=rs("atkskill")
		skill2=rs("defskill")
		skill3=rs("lifeskill")
		skill4=rs("luckskill")
		skill5=rs("learnskill")
		skill6=rs("hpmaxskill")
		it=request("it")
		if it=1 then skill1=skill1+1 end if
		if it=2 then skill2=skill2+1 end if
		if it=3 then skill3=skill3+1 end if
		if it=4 then skill4=skill4+1 end if
		if it=5 then skill5=skill5+1 end if
		if it=6 then skill6=skill6+1 end if
		if (skill-1<0) then
'call showmessage("你没有那么多的技能点","petmypet.asp")
Response.Write "<script language=JavaScript>{alert('你没有那么多的技能点.');(location.href = 'petmypet.asp')}</script>"
        elseif (skill=0) then
'call showmessage("你输入的技能点有误，请重新输入~","petmypet.asp")
Response.Write "<script language=JavaScript>{alert('你输入的技能点有误，请重新输入~.');(location.href = 'petmypet.asp')}</script>"
        else
           ' Call UpdateUserInfo(-skill,0,0,0,0,0)
			connpet.ExeCute("UPDATE mypetdata SET atkskill="&skill1&",defskill="&skill2&",lifeskill="&skill3&",luckskill="&skill4&",learnskill="&skill5&",hpmaxskill="&skill6&" WHERE username='"&bbs94kk.myname&"'")
'call showmessage("加点成功~","petmypet.asp")
Response.Write "<script language=JavaScript>{alert('加点成功~');(location.href = 'petmypet.asp')}</script>"
        end if	
	
	
	end select


%>
<table width="753" border="0" cellspacing="1" cellpadding="5" align="center" class=TBone>
  <tr>
	<td height=27 align="center" class=tbhead2 width="741"><b><font class=HeadFont><%=stats%></font></b></td>
  </tr>
  <tr>
	<td class=tbbg1 width="741">
	
<table width="554"  border="0" align="center" cellpadding="3" cellspacing="3">
<tr><td width="178" 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">
					<img border="0" src="<%=Form_userphoto%>" width="<%=Form_FaceWidth%>" height="<%=Form_Faceheight%>">
					<br><img src="images/blank.gif" width="2" height="5"><br>
                    </div></td>
                  </tr>
					<br><img src="images/blank.gif" width="2" height="5"><br>
</div></td>
</tr><tr>
                    <td> <div align="center">
                        <nobr>用户<%=DEF_PointsName%>: <%=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"><a href="petshop.asp"><img src="images/pet/25.gif"></a></div></td></tr></table></div>
<div align="center"></div></td><td width="648">
					<table width="494" border="0" cellspacing="2" cellpadding="2">
                        <tr> 
							<td width="335">　
					<table width="286" border="0" cellspacing="2" cellpadding="2">
                        <tr> 
							<td width="187">　</td>
                            <td width="105"> 
          <div align="center"><img border=0 src="images/pet/head/<%=rs("item3")%>.gif" alt="<%=headname%> 防御力 <%=rs("item3Num")%>" width="23" height="30"></div>
        </td>
                            <td width="170">　</td>
                        </tr>
                        <tr> 
                            <td width="187">
          <div align="right"><img height=30 border=0 src="images/pet/sword/<%=rs("item1")%>.gif" alt="<%=swordname%> 攻击力 <%=rs("item1Num")%>" width="23"></div>
        </td>
                            <td rowspan="2" width="105">
          <div align="center"> 
            <%if rs("imgset")=-1 then%>
            <img src='images/pet/<%=petpic%>/<%=petpic%><%=levelpic%>.gif' border="0" <%=petkill%> > 
            <%else%>
            <img src='images/pet/<%=petpic%>/<%=petpic%><%=imgset%>.gif' border="0" width="23" height="30" <%=petkill%> > 
            <%end if%>
          </div>
        </td>
                            
        <td width="170"><img src="images/pet/body/<%=rs("item4")%>.gif" border=0 alt="<%=bodyname%> 防御力 <%=rs("item4Num")%>" width="23" height="30"></td>
                        </tr>
                        <tr> 
                            <td width="187">
          <div align="right"><img border=0 src="images/pet/necklace/<%=rs("item2")%>.gif" alt="<%=necklacename%> 攻击力 <%=rs("item2Num")%>" width="23" height="30" ></div>
        </td>
                            
        <td width="170"><img src="images/pet/foot/<%=rs("item5")%>.gif" border=0 alt="<%=footname%> 防御力 <%=rs("item5Num")%>" width="23" height="30"></td>
                        </tr>
                        </table></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>

				  <table width='100%' border='0' cellpadding='1' cellspacing='1'>

					<tr><td width='33%'><div align="left">宠物名称：<%=mypet%>
						  <br>
						  宠物性别：<%=petsex%><br>
                      宠物状态：<%=petdead%><br>
						宠物属性：<%=mypetsx%></div><div align="left">宠物挑战：<%=petpk%></div><div align="left">宠物转生：<%=rs("relive")%></div><div align="left">宠物级别：<%=petshowlevel%></div></td>
					  <td width='33%'> <span lang="zh-cn">力量</span>：<%=str%><br>
						  <span lang="zh-cn">皮肤</span>：<%=ski%><br>
						  <span lang="zh-cn">敏捷</span>：<%=def%><br>
						  <span lang="zh-cn">体力</span>：<%=vit%><br>
                        攻击：<%=petatk%><br>
                        防御：<%=petdef%><br>
                        速度：<%=speed%>
                        　</td>
					  <td width='33%'>
				<%if action = "show" then%><form action=petmypet.asp name="name" mtehod=post>
					  剩余素质点：<%=szd%><br><span lang="zh-cn">力量 + </span>  
					  <input class='94kk' name="szd1" type="text" value="0" size="6" maxlength="5"><br>
                      <span lang="zh-cn">皮肤 + </span>  
					  <input class='94kk' name="szd2" type="text" value="0" size="6" maxlength="5"><span lang="zh-cn"><br>
                      敏捷 + </span>  
					  <input class='94kk' name="szd3" type="text" value="0" size="6" maxlength="5"><span lang="zh-cn"><br>
                      体力 + </span>  
					  <input class='94kk' name="szd4" type="text" value="0" size="6" maxlength="5"><br>
                      <span lang="zh-cn"><input class='94kk' type="hidden" name="action" value="sure">
                      　　<input class='94kk' type="submit" name="submit" value="加点"></span></form>
               <%end if%>
                       
               	<%if action = "sure" then%><form action=petmypet.asp name="name" mtehod=post>
                        力量 + <%=szd1%> 点<br>
                        皮肤 + <%=szd2%> 点<br>
                        敏捷 + <%=szd3%> 点<br>
                        体力 + <%=szd4%> 点<br>
                        <input class='94kk' type="hidden" name="szd1" value="<%=szd1%>">
						<input class='94kk' type="hidden" name="szd2" value="<%=szd2%>">
						<input class='94kk' type="hidden" name="szd3" value="<%=szd3%>">
						<input class='94kk' type="hidden" name="szd4" value="<%=szd4%>">
						<input class='94kk' type="hidden" name="action" value="add">
						　　<input class='94kk' type="submit" value="确定"> </form> 
				<%end if%>
                      
                      
                      
                  </td></tr></table>    
				</td>
			  </tr>

			<tr>
			<td width='650' align="left">
            <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="495" id="AutoNumber1">
              <tr>
	    <td width='67' align="center"> <a href="petmypet.asp?action=addskill&it=1"> 
          <img src='images/pet/skill/<%=atkskill%>.jpg' border="0" width="42" height="48"  alt="增加攻击技能？"></a></td>
			
        <td width='67' align="center"> <a href="petmypet.asp?action=addskill&it=2"> 
          <img src='images/pet/skill/<%=defskill%>.jpg'  border="0" width="42" height="48" alt="增加防御技能？"></a></td>
			
        <td width='67' align="center"> <a href="petmypet.asp?action=addskill&it=3"> 
          <img src='images/pet/skill/<%=lifeskill%>.jpg'  border="0" width="42" height="48" alt="增加治疗技能？"></a></td>
			
        <td width='68' align="center"> <a href="petmypet.asp?action=addskill&it=4"> 
          <img src='images/pet/skill/<%=luckskill%>.jpg'  border="0" width="42" height="48" alt="增加幸运技能？"></a></td>
			
        <td width='68' align="center"> <a href="petmypet.asp?action=addskill&it=5"> 
          <img src='images/pet/skill/<%=learnskill%>.jpg'  border="0" width="42" height="48" alt="增加学习技能？"></a></td>
			
        <td width='42' align="center"> <a href="petmypet.asp?action=addskill&it=6"> 
          <img src='images/pet/skill/<%=hpmaxskill%>.jpg'  border="0" width="42" height="48" alt="增加生命技能？"></a></td>
			<td width='335' align="left">
            &nbsp;攻击技能：<%=rs("atkskill")%><br>
			&nbsp;防御技能：<%=rs("defskill")%><br>
			&nbsp;幸运技能：<%=rs("luckskill")%><br>
			&nbsp;总技能点：<%=rs("skill")+petshowlevel%><br></td>
			<td width='398' align="left">
            &nbsp;治疗技能：<%=rs("lifeskill")%><br>
			&nbsp;生命技能：<%=rs("hpmaxskill")%><br>
			&nbsp;学习技能：<%=rs("learnskill")%><br>
			&nbsp;剩余技能：<%=skill%><br></td>
              </tr>
            </table>
            </td>
			</tr>
				
<tr><td width="648"><TABLE cellSpacing=3 cellPadding=3 width="100%" align=center border=0>
					<TR> 
					  <TD colspan="4">
                      <p align="center">　<span lang="zh-cn">★★★ </span><a href="petitbox.asp">宠物物品箱</a>
                      <span lang="zh-cn">★★★</span></TD>
					</TR>

					<tr>
					  <TD width="25%"> 
          <DIV align=center><a href="petitemuse.asp?action=usehp"><IMG height=35 src="images/pet/hp.gif" width=34 border="0" alt="点击使用"></a><BR>
						  HP药水</DIV></TD>
					  <TD width="25%"> <DIV align=center>拥有数量：<%=hpitem%> 
						  <BR>
						  [<a href="petitemuse.asp?action=usehp">使用</a>]</DIV></TD>
					  <TD width="25%">
                      
          <p align="center"><a href="petitemuse.asp?action=useexp"><IMG height=35 src="images/pet/exp.gif" width=35 border="0" alt="点击使用"></a><BR>
						  EXP药水</TD>
					  <TD width="25%">
                      <p align="center">拥有数量：<%=expitem%><BR>
						  [<a href="petitemuse.asp?action=useexp">使用</a>]</TD>
					</tr>
                    <tr>
					  <TD>
          <DIV align=center><a href="petitemuse.asp?action=usesp"><img height=35 src="images/pet/sp.gif" width=35 border="0" alt="点击使用"></a><BR>
						  SP药水</DIV></TD>
					  <TD><DIV align=center>拥有数量：<%=spitem%><BR>
						  [<a href="petitemuse.asp?action=usesp">使用</a>]</DIV></TD>
					  <TD>
                      
          <p align="center"> <a href="petitemuse.asp?action=uselive"><IMG height=35 src="images/pet/liv.gif" width=34 border="0" alt="点击使用"></a><BR>
						  <font color="#000000">复活药水</font></TD>
					  <TD>
                      <p align="center">拥有数量：<%=liveitem%><BR>
						  [<a href="petitemuse.asp?action=uselive">使用</a>]</TD>
					</tr>


					<TR> 
					  <TD colspan="4">
                      <p align="center">　</TD>
					</TR>

				  </TABLE></td>
</tr></table>

	</td></tr></table>
<% bbs94kk.footer() %>