<!--#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,action

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 Rs,SQL
    sql = "SELECT * FROM mypetdata WHERE username='"&Dvbbs.MemberName&"' "
    set rs=conn.ExeCute(sql)
    if rs.eof then
        call showmessage("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
        else
        
dim mypethp,mypetmaxhp,mypetsp,mypetdead,hpitem,spitem,expitem,atkitem,defitem,liveitem,basichp,basicsp,basicusehp,basicuseexp,atkup,defup,hptemp,pettoday,petlevel
dim petshowlevel
mypethp = rs("mypethp")
mypetmaxhp = rs("mypetmaxhp")
mypetsp = rs("mypetsp")
mypetdead =rs("mypetdead")
hpitem=rs("hpitem")
spitem=rs("spitem")
expitem=rs("expitem")
atkitem=rs("atkitem")
defitem=rs("defitem")
liveitem=rs("liveitem")
basichp=def_pet_basichp
basicsp=DEF_PET_basicsp
basicusehp=def_pet_basicusehp
basicuseexp=def_pet_basicuseexp
atkup=def_pet_atkup
defup=def_pet_defup
hptemp=mypetmaxhp-mypethp
pettoday = now()
        


select case lcase(request("action"))
    case "usehp"
        if(hpitem<1) then
            call showmessage("你没有HP药水","petmypet.asp")
        elseif(mypethp=mypetmaxhp or mypetdead=1) then
            if (mypethp=mypetmaxhp) then
                call showmessage("你的宝宝体力充沛，不用喝药水了","petmypet.asp")
            else 
                call showmessage("先把宝宝救活再说吧:(","petmypet.asp")
            end if
        elseif(hptemp<basicusehp) then
            conn.ExeCute("UPDATE mypetdata SET mypethp=mypetmaxhp,hpitem=hpitem-1 WHERE username='"& Dvbbs.MemberName &"'")
            call showmessage("使用成功，你的宝宝HP增加了 "& hptemp &" ！","petmypet.asp")
        else
            conn.ExeCute("UPDATE mypetdata SET mypethp=mypethp+"&basicusehp&",hpitem=hpitem-1 WHERE username='"& Dvbbs.MemberName &"'")
            call showmessage("使用成功，你的宝宝HP增加了 "&basicusehp&" ！","petmypet.asp")
        end if
    case "usesp"
        if (spitem<1 or mypetdead=1) then
               if (spitem<1) then
                call showmessage("你没有SP药水","petmypet.asp")
               else 
                call showmessage("先救活宝宝再喂它吧:(","petmypet.asp")
               end if
        else
            conn.ExeCute("UPDATE mypetdata SET mypetsp="&basicsp&",spitem=spitem-1,petregdate='"&pettoday&"' WHERE username='"& Dvbbs.MemberName &"'")
            call showmessage("使用成功，你的宝宝SP吃饱了 ！","petmypet.asp")
        end if
    case "useexp"
        if (expitem<1 or mypetdead=1) then
            if (expitem<1) then
               call showmessage("你没有EXP药水","petmypet.asp")
               else 
               call showmessage("先救活宝宝再喂它吧:(","petmypet.asp")
            end if
        else
            petlevel = (Log(rs("mypetexp")+basicuseexp) / Log(10)) * (Log(rs("mypetexp")+basicuseexp) / Log(10)) * (Log(rs("mypetexp")+basicuseexp) / Log(10))
            petshowlevel = int (petlevel + 1)
            if(petshowlevel<2 ) then
                mypetmaxhp=basichp
            else 
                mypetmaxhp=basichp+petshowlevel*5
            end if
            conn.ExeCute("UPDATE mypetdata SET mypetexp=mypetexp+"&basicuseexp&",expitem=expitem-1,mypetlevel="&petshowlevel&",mypetmaxhp="&mypetmaxhp&" WHERE username='"& Dvbbs.MemberName &"'")
            call showmessage("使用成功，你的宝宝EXP增加了 "& basicuseexp &"！","petmypet.asp")
        end if
    case "useatk"
        if (atkitem<1) then
            call showmessage("你没有攻击力药水","petmypet.asp")
        else
            conn.ExeCute("UPDATE mypetdata SET mypetatk=mypetatk+"&atkup&",atkitem=atkitem-1 WHERE username='"& Dvbbs.MemberName &"'")
            call showmessage("使用成功，你的宝宝攻击力增加了 "& atkup &" ！","petmypet.asp")
        end if
    case "usedef"
        if (defitem<1) then
            call showmessage("你没有防御力药水","petmypet.asp")
        else
            conn.Execute("UPDATE mypetdata SET mypetdef=mypetdef+"&defup&",defitem=defitem-1 WHERE username='"& Dvbbs.MemberName &"'")
            call showmessage("使用成功，你的宝宝防御力增加了 "& defup &" ！","petmypet.asp")
        end if
    case "uselive"
        if (liveitem<1) then
            call showmessage("你没有复活药水","petmypet.asp")
        elseif(mypetdead<1) then
            call showmessage("你的宝宝还没有死，干吗复活啊？","petmypet.asp")
        else
            conn.ExeCute("UPDATE mypetdata SET mypethp="& mypetmaxhp &",mypetsp="& basicsp &",liveitem=liveitem-1,petregdate='"& pettoday &"',mypetdead=0 WHERE username='"& Dvbbs.MemberName &"'")
            call showmessage("使用成功，你的宝宝复活了 ！","petmypet.asp")
        end if
end select
    
    end if
    rs.close
end if    
%>