<!-- #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  money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg
    dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
    
set rs=joekoe_cms.exec("select * from user_data where username='"&login_username&"'",1)
    money=rs("emoney")
    rs.close
    

    sql = "SELECT * FROM mypetdata WHERE username='"&login_username&"' "
    rs.open sql,connpet,1,3
    if rs.eof then
        call showmessage("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
        else
        
dim basichpmoney,basicspmoney,basicexpmoney,atkmoney,defmoney,livemoney
dim item1,item2,item3,item4,item5,item6,tmoney,petmoney

basichpmoney=def_pet_basichpmoney
basicspmoney=def_pet_basicspmoney
basicexpmoney=def_pet_basicexpmoney
atkmoney=def_pet_atkmoney
defmoney=def_pet_defmoney
livemoney=def_pet_livemoney


'注册用户物品
Dim Rs2,SQL2,hpitem,spitem,expitem,liveitem
sql2 = "SELECT * FROM useritem WHERE username='"&login_username&"' "
set rs2=connpet.ExeCute(sql2)
hpitem=rs2("hpitem")
spitem=rs2("spitem")
expitem=rs2("expitem")
'atkitem=rs2("atkitem")
'defitem=rs2("defitem")
liveitem=rs2("liveitem")


item1 = int(request("item1"))
item2 = int(request("item2"))
item3 = int(request("item3"))
item4 = 0
item5 = 0
item6 = int(request("item6"))

if request("action") = "" then
    action = "showroom"
    else
    action = lcase(request("action"))
end if

select case action
    case "countitem"


        if (item1<0 or item2<0 or item3<0 or item6<0) then
            call showmessage("你购买数量有错误，请重新购买~","petitemshop.asp")
            else
            tmoney=item1*basichpmoney+item2*basicspmoney+item3*basicexpmoney+item4*atkmoney+item5*defmoney+item6*livemoney
        end if
    case "buyitem"
        petmoney=money
        tmoney=item1*basichpmoney+item2*basicspmoney+item3*basicexpmoney+item4*atkmoney+item5*defmoney+item6*livemoney
        if (petmoney<tmoney) then
            call showmessage("你没有那么多钱购买这些物品","petitemshop.asp")
        elseif (item1<0 or item2<0 or item3<0 or item6<0) then
            call showmessage("你购买数量有错误，请重新购买~","petitemshop.asp")
        else
            call joekoe_cms.exec("update user_data set emoney=emoney-"&tmoney&" where username='"&login_username&"'",0)
            connpet.ExeCute("UPDATE useritem SET hpitem=hpitem+"&item1&",spitem=spitem+"&item2&",expitem=expitem+"&item3&",liveitem=liveitem+"&item6&" WHERE username='"&login_username&"'")
            call showmessage("购买成功!<br><br>你HP药水增加了 "&item1&" 个<br>SP药水增加了 "&item2&" 个<br>EXP药水增加了 "&item3&" 个<br>复活药水增加了 "&item6&" 个！","petmypet.asp")

        end if
end select
        
        
    end if
    rs2.close
    rs.close    
%>
<table width="760" border="0" cellspacing="1" cellpadding="5" align="center" class=TBone>
  <tr>
    <td class=tbbg1>
    

            <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="28%"><table width="79%"  border="0" align="center" cellpadding="3" cellspacing="3">
                  <tr> 
                    <td width="100%"> <div align="center">我的资料</div></td>
                  </tr>
                  <%call pet_left("")%>
                  <tr> 
                    <td> <div align="center">
                        <nobr>用户<%=DEF_PointsName%>: <%=money%>金币 </nobr>    
                        </div></td>
                  </tr>
                </table>                <br>
                <br>
                <table width="79%"  border="0" align="center" cellpadding="3" cellspacing="3">
                  <tr> 
                    <td width="100%">
<!-- #include file=petnav.asp --><br><br>
                     <div align="center"><img src="images/pet/25.gif"></div>
                      </td>
                  </tr>
                </table> 
                <div align="right"></div></td>
                <td width="72%"> 
                  <%if action = "showroom" then%>
                  <form action=petitemshop.asp name="name" mtehod=post>
<TABLE cellSpacing=3 cellPadding=3 width="100%" align=center valign="top" border=0>
                      <TR> 
                        <TD colspan="3"><div align="center">物品列表</div></TD>
                      </TR>
                      <TR> 
                        <TD width="12%"> <DIV align=center><IMG height=35 src="images/pet/hp.gif" width=34><BR>
                            HP药水</DIV></TD>
                        <TD width="18%"><div align="center">增加宠物 <%=DEF_PET_basicusehp%>      
                            点HP <FONT color=#ff0000><BR>     
                            出售价格： </FONT><font color="#FF0000"><%=DEF_PET_basichpmoney%>      
                            <%=DEF_PointsName%> </font><BR>
                          </div></TD>
                        <TD width="19%"> <DIV align=center>购买数量： 
                            <input class='94kk' name="item1" type="text" value="0" size="6" maxlength="5">
                            <br>
                            你所拥有数量：<%=hpitem%> <BR>
                          </DIV></TD>
                      </TR>
                      <TR> 
                        <TD><DIV align=center><img height=35 src="images/pet/sp.gif" width=35><BR>
                            SP药水</DIV></TD>
                        <TD><div align="center">补满宠物的SP<FONT color=#ff0000><BR>
                            出售价格： </FONT><font color="#FF0000"> <%=def_pet_basicspmoney%>      
                            <%=DEF_PointsName%> </font></div></TD>
                        <TD><DIV align=center>购买数量： 
                            <input class='94kk' name="item2" type="text" value="0" size="6" maxlength="5">
                            <br>
                            你所拥有数量：<%=spitem%><BR>
                          </DIV></TD>
                      </TR>
                      <TR> 
                        <TD><DIV align=center><IMG height=35 src="images/pet/exp.gif" width=35><BR>
                            EXP药水</DIV></TD>
                        <TD><div align="center">随机增加宠物 10-<%=def_pet_basicuseexp+10%> 点<FONT color=#000000>EXP</FONT><FONT color=#ff0000><BR>     
                            出售价格： </FONT><font color="#FF0000"> <%=def_pet_basicexpmoney%>      
                            <%=DEF_PointsName%></font></div></TD>
                        <TD><DIV align=center>购买数量： 
                            <input class='94kk' name="item3" type="text" value="0" size="6" maxlength="5">
                            <br>
                            你所拥有数量：<%=expitem%><BR>
                          </DIV></TD>
                      </TR>
                      <TR> 
                        <TD><div align="center"><IMG height=35 src="images/pet/liv.gif" width=34><BR>
                            <font color="#000000">复活药水</font></div></TD>
                        <TD><div align="center">使你的宝宝复活<FONT color=#ff0000><BR>
                            出售价格： </FONT><font color="#FF0000"><%=def_pet_livemoney%> 
                            <%=DEF_PointsName%></font></div></TD>
                        <TD><div align="center">购买数量： 
                            <input class='94kk' name="item6" type="text" value="0" size="6" maxlength="5">
                            <br>
                            你所拥有数量：<%=liveitem%><BR>
                          </div></TD>
                      </TR>
                      <TR> 
                        <TD colspan="3"><div align="center"> 
                            <table width="100%" border="0" cellspacing="2" cellpadding="2">
                              <tr> 
                                <td> <div align="center"> 
                                    <input class='94kk' type="hidden" name="action" value="countitem">
                                    <input class='94kk' type="submit" name="submit" value="结帐购买">
                                  </div>
                                  <div align="left"> </div></td>
                              </tr>
                            </table>
                          </div></TD>
                      </TR>
                    </TABLE>
                  </form><%end if%>

  <%if action = "countitem" then%>
<form action=petitemshop.asp name="name" mtehod=post>
                    <TABLE cellSpacing=3 cellPadding=3 width="100%" align=center valign="top" border=0>
                      <TR> 
                        <TD width="49%"><div align="center">购买清单</div></TD>
                      </TR>
                      <TR> 
                        <TD> <DIV align=center> 
                            <table width="41%" border="0" cellspacing="2" cellpadding="2">
                              <tr> 
                                <td width="44%"><div align="right">HP药水：</div></td>
                                <td width="56%"><%=item1%> 个</td>
                              </tr>
                              <tr> 
                                <td><div align="right">SP药水：</div></td>
                                <td><%=item2%> 个</td>
                              </tr>
                              <tr> 
                                <td><div align="right">EXP药水：</div></td>
                                <td><%=item3%> 个</td>
                              </tr>

                              <tr> 
                                <td><div align="right">复活药水：</div></td>
                                <td><%=item6%> 个</td>
                              </tr>
                              <tr> 
                                <td><div align="right">总计价格：</div></td>
                                <td><%=tmoney%> <font color="#000000"><%=DEF_PointsName%></font></td>
                              </tr>
                            </table>
                          </DIV></TD>
                      </TR>
                      <TR> 
                        <TD><div align="center"> 

<TABLE cellSpacing=2 cellPadding=2 width="100%" border=0>
<TR><TD><DIV align=center> 
<input class='94kk' type="hidden" name="item1" value="<%=item1%>">
<input class='94kk' type="hidden" name="item2" value="<%=item2%>">
<input class='94kk' type="hidden" name="item3" value="<%=item3%>">
<input class='94kk' type="hidden" name="item6" value="<%=item6%>">
<input class='94kk' type="hidden" name="action" value="buyitem">
<input class='94kk' type="submit" value="购买">
</DIV></TD></TR></TABLE></div></TD></TR></TABLE></form><%end if%>
</td>
            </tr>
          </table> 

	</td></tr></table>
<%call web_end(0,0)%>