<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_popfun.asp -->
<!-- #include file=pet_conn.asp -->
<!--#include file=pet_config.asp-->
<%
DEF_BBS_HomeUrl = "../../"
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr

chentitle="宠物商店"
chenbackasp="petcenter.asp"
stats="社区宠宠物商店"
BBS_SiteHead DEF_SiteNameString&" "&DEF_BBS_Name,GBL_board_ID,">>&nbsp;<a href=petcenter.asp>宠物中心</a>&nbsp;>>&nbsp;" & chentitle

if GBL_CHK_User="" 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,SQL

	OpenDatabase	
    set rs=con.execute("select * from [leadbbs_user] where username='"&GBL_CHK_User&"' ")
      	
    money=rs("points")

	Form_userphoto = Rs("Userphoto")
	If DEF_AllDefineFace = 1 Then
		Form_FaceUrl = Rs("FaceUrl")
		Form_FaceWidth = Rs("FaceWidth")
		Form_FaceHeight = Rs("FaceHeight")
	End If    

    rs.close
    

    
    if request("action") = "buy" then
        SQL = "SELECT * FROM mypetdata WHERE username='"&GBL_CHK_User&"' "
        rs.open sql,connpet,1,3
        if not rs.eof then
            call showmessage("你已经有一个宠物了，做人不要三心两意啊~","petshop.asp")
            elseif request("petname") = "" then
                call showmessage("你还没有选定你要的宝宝啊，请重新选择","petshop.asp")
                elseif money < DEF_PET_eggmoney then
                    call showmessage("你没有足够的钱买宠物","petshop.asp")
                    else
                    dim pettoday,pets,eggmoney,pethp,petsp,petatk,petdef
                    
                    Randomize '初始化随机数生成器。

                    pettoday = date()
                    pets = Int((2 * Rnd) + 1)
                    eggmoney = DEF_PET_eggmoney 
                    pethp = DEF_PET_basichp
                    petsp = DEF_PET_basicsp
                    petatk = Int((10 * Rnd) + 1)
                    petdef = Int((10 * Rnd) + 1)
                    
                    if request("petname") = 1 then
                        SQL = "UPDATE [leadbbs_user] SET points=points-"&eggmoney&" WHERE username='"&GBL_CHK_User&"'"
                        con.ExeCute(SQL)
                        SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,hpitem,spitem,expitem)VALUES ('"&GBL_CHK_User&"', '泡泡龙', 'dragon', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '火', '"&pettoday&"', '1', '1', '0')"
                        'response.write sql : response.end
                        connpet.ExeCute(SQL)
                        call showmessage("你已经有了一个泡泡龙宝宝，一定要好好照顾他/她啊","mypet.asp")
                    elseif request("petname") = 2 then
                        SQL = "UPDATE [leadbbs_user] SET points=points-"&eggmoney&" WHERE username='"&GBL_CHK_User&"'"
                        con.ExeCute(SQL)
                        SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,hpitem,spitem,expitem)VALUES ('"&GBL_CHK_User&"', '猫尾球', 'bst', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '土', '"&pettoday&"', '1', '1', '0')"
                        connpet.ExeCute(SQL)
                        call showmessage("你已经有了一个猫尾球宝宝，一定要好好照顾他/她啊","mypet.asp")
                    elseif request("petname") = 3 then
                        SQL = "UPDATE [leadbbs_user] SET points=points-"&eggmoney&" WHERE username='"&GBL_CHK_User&"'"
                        con.ExeCute(SQL)
                        SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,hpitem,spitem,expitem)VALUES ('"&GBL_CHK_User&"', '天使球', 'bird', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '水', '"&pettoday&"', '1', '1', '0')"
                        connpet.ExeCute(SQL)
                        call showmessage("你已经有了一个天使球宝宝，一定要好好照顾他/她啊","mypet.asp")
                    elseif request("petname") = 4 then
                        SQL = "UPDATE [leadbbs_user] SET points=points-"&eggmoney&" WHERE username='"&GBL_CHK_User&"'"
                        con.ExeCute(SQL)
                        SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,hpitem,spitem,expitem)VALUES ('"&GBL_CHK_User&"', '苹果宝宝', 'green', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '木', '"&pettoday&"', '1', '1', '0')"
                        connpet.ExeCute(SQL)
                        call showmessage("你已经有了一个苹果宝宝，一定要好好照顾他/她啊","mypet.asp")
                    elseif request("petname") = 5 then
                        SQL = "UPDATE [leadbbs_user] SET points=points-"&eggmoney&" WHERE username='"&GBL_CHK_User&"'"
                        con.ExeCute(SQL)
                        SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,hpitem,spitem,expitem)VALUES ('"&GBL_CHK_User&"', '幽灵球', 'devil', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '金', '"&pettoday&"', '1', '1', '0')"
                        connpet.ExeCute(SQL)
                        call showmessage("你已经有了一个幽灵球宝宝，一定要好好照顾他/她啊","mypet.asp")
                    end if
                end if
        end if
                    

%>
<% If GBL_TableHeadString <> "" Then %><table width=<%=DEF_BBS_ScreenWidth%> border=0 cellspacing=0 cellpadding=0 align=center><tr><td><%=GBL_TableHeadString%></td></tr></table><% End If %>
<table width="<%=DEF_BBS_ScreenWidth%>" 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>
    
<form action=petshop.asp name="petname" mtehod=post>

          <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>
                  <tr> 
                    <td> <div align="center">
					<%
					If isNull(Form_FaceUrl) Then Form_FaceUrl = ""
					If DEF_AllDefineFace = 0 or Trim(Form_FaceUrl) = "" Then%>
					<img src=<%=DEF_BBS_HomeUrl%>images/face/<%=string(4-len(cstr(Form_userphoto)),"0")&Form_userphoto%>.gif align=absmiddle width=62 height=62>
					<%Else%>
						<img src="<%=htmlencode(replace(Form_FaceUrl,"../","../../"))%>" align=absmiddle width=<%=Form_FaceWidth%> height=<%=Form_FaceHeight%>>
					<%End If%>
					<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>
                <br>
                <table width="79%"  border="0" align="center" cellpadding="3" cellspacing="3">
                  <tr> 
                    <td width="100%"> <div align="center"><img src="images/pet/25.gif"></div>
                      </td>
                  </tr>
                </table> 
                <div align="right"></div></td>
              <td width="72%"><table width="100%"  border="0" align="center" cellpadding="3" cellspacing="3">
                  <tr> 
                    <td width="24%"><div align="center">宠物名称</div></td>
                    <td width="58%"><div align="center">宠物介绍</div></td>
                    <td width="18%"><div align="center">购买宠物</div></td>
                  </tr>
                  <tr> 
                    <td><div align="center"><img src="images/pet/dragon.gif" width="45" height="46"><br>
                        泡泡龙（龙系）</div></td>
                    <td>来自东方的一条龙，随着你升级而升级，最终形态将是十分帅气人龙。<br>
                      宠物属性：火 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
                      <%=DEF_PointsName%> </font><br> </td>
                    <td><div align="center"> 
                        <input type="radio" name="petname" value="1">
                        购买</div></td>
                  </tr>
                  <tr> 
                    <td><div align="center"><img src="images/pet/bst.gif" width="45" height="42"><br>
                        猫尾球（兽系） </div></td>
                    <td>可爱的兽系宠物，也是人类最好的朋友，最终形态是黑暗守护犬。<br>
                      宠物属性：土 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
                      <%=DEF_PointsName%> </font></td>
                    <td><div align="center"> 
                        <input type="radio" name="petname" value="2">
                        购买</div></td>
                  </tr>
                  <tr> 
                    <td><div align="center"><img src="images/pet/bird.gif" width="45" height="44"><br>
                        天使球（鸟系） </div></td>
                    <td>小鸟每个人都喜欢，但是你知道他们还有强大的能力，最终形态是大红鹰<br>
                      宠物属性：水 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
                      <%=DEF_PointsName%> </font></td>
                    <td><div align="center"> 
                        <input type="radio" name="petname" value="3">
                        购买</div></td>
                  </tr>
                  <tr> 
                    <td><div align="center"><img src="images/pet/green.gif" width="45" height="46"><br>
                        苹果宝宝（植物系） </div></td>
                    <td>谁也没有想到植物有如此强大的能力，最终形态是节节高<br>
                      宠物属性：木 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
                      <%=DEF_PointsName%> </font></td>
                    <td><div align="center"> 
                        <input type="radio" name="petname" value="4">
                        购买</div></td>
                  </tr>
                  <tr> 
                    <td><div align="center"><img src="images/pet/devil.gif" width="45" height="46"><br>
                        幽灵球（恶魔系） </div></td>
                    <td>一生下来就有神秘色彩的幽灵球，同时也拥有神秘的功能，最终形态是巨灵恶魔<br>
                      宠物属性：金 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
                      <%=DEF_PointsName%> </font></td>
                    <td><div align="center"> 
                        <input type="radio" name="petname" value="5">
                        购买</div></td>
                  </tr>
                  <tr> 
                    <td colspan="3"><div align="center"> 
                        <input type="hidden" name="action" value="buy">
                        <input name="submit" type="submit" value="购买">
                      </div></td>
                  </tr>
                </table></td>
            </tr>
          </table> 
          </form>


	</td></tr></table>
<% If GBL_TableBottomString <> "" Then %><table width=<%=DEF_BBS_ScreenWidth%> border=0 cellspacing=0 cellpadding=0 align=center><tr><td><%=GBL_TableBottomString%></td></tr></table><% End If %>
<%    
end if

SiteBottom 
If GBL_SiteBottomString <> "" Then Response.Write GBL_SiteBottomString
%>