<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/plus_check.asp"-->
<!--#include file="YD_pet_conn.asp"-->

<%
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr
chentitle="社区宠物商店社区宠物商店社区宠物商店社区宠物商店社区宠物商店社区宠物商店"
Dv_plus.name="petcenter"
'Dv_plus.checklogin()
Dvbbs.LoadTemplates("")
Dvbbs.Stats="社区宠物商店"
Dvbbs.Nav()
Dvbbs.Head_var 0,"","宠物中心","YD_petcenter.asp"

if DvBBS.UserId = 0 then
	AlarmErrmsg
else
	'宠物插件状态
	if DEF_PET_close>1 then
		'暂时关掉开始
		if not dvbbs.master then
			call showmessage("调试中,请以后再来~","index.asp")
		end if
		'暂时关掉结束
	end if

	dim money,smoney,saveday,allmoney,time1,time2,daikuang,dkdu,daiday,sucmsg
	dim Form_userphoto,Form_FaceUrl,Form_FaceWidth,Form_FaceHeight
	Dim Rs,SQL
	set rs=Dvbbs.execute("select userWealth from [Dv_User] where UserID="&DvBBS.UserId)
	money=rs("userWealth")
	rs.close

	if request("action") = "buy" then
		SQL = "SELECT * FROM mypetdata WHERE username='"& Dvbbs.MemberName &"' "
		rs.open sql,connpet,1,3

		if not rs.eof then
			call showmessage("你已经有一个宠物了，做人不要三心两意啊~","YD_petshop.asp")
		elseif request("petname") = "" then
			call showmessage("你还没有选定你要的宝宝啊，请重新选择","YD_petshop.asp")
		elseif money < DEF_PET_eggmoney then
			call showmessage("你没有足够的钱买宠物","YD_petshop.asp")
		else
			dim pettoday,pets,eggmoney,pethp,petsp,petatk,petdef,temp
			dim atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill
			Randomize '初始化随机数生成器。
			pettoday = date()
			pets = Int((2 * Rnd) + 1)
			eggmoney = DEF_PET_eggmoney 
			pethp = DEF_PET_basichp
			petsp = DEF_PET_basicsp
			petatk = Int((9 * Rnd) + 1)
			petdef = Int((9 * Rnd) + 1)
			atkskill=0
			defskill=0
			luckskill=0
			learnskill=0
			lifeskill=0
			hpmaxskill=0

			if request("petname") = 1 then
				SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&eggmoney&" WHERE userid="&Dvbbs.UserId
				Dvbbs.ExeCute(SQL)
				Call UpdateUserInfo(-eggmoney,0,0,0,0,0)	'道具Bug修正
				SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill)VALUES ('"& Dvbbs.MemberName &"', '泡泡龙', 'dragon', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '火', '"&pettoday&"', '"&atkskill&"','"&defskill&"','"&luckskill&"','"&learnskill&"','"&lifeskill&"','"&hpmaxskill&"')"
				connpet.ExeCute(SQL)
				call showmessage("你已经有了一个泡泡龙宝宝，一定要好好照顾他/她啊","YD_petmypet.asp")
			elseif request("petname") = 2 then
				SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&eggmoney&" WHERE userid="&Dvbbs.UserId
				Dvbbs.ExeCute(SQL)
				Call UpdateUserInfo(-eggmoney,0,0,0,0,0)	'道具Bug修正
				SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill)VALUES ('"& Dvbbs.MemberName &"', '猫尾球', 'bst', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '土', '"&pettoday&"', '"&atkskill&"','"&defskill&"','"&luckskill&"','"&learnskill&"','"&lifeskill&"','"&hpmaxskill&"')"
				connpet.ExeCute(SQL)
				call showmessage("你已经有了一个猫尾球宝宝，一定要好好照顾他/她啊","YD_petmypet.asp")
			elseif request("petname") = 3 then
				SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&eggmoney&" WHERE userid="&Dvbbs.UserId
				Dvbbs.ExeCute(SQL)
				Call UpdateUserInfo(-eggmoney,0,0,0,0,0)	'道具Bug修正
				SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill)VALUES ('"& Dvbbs.MemberName &"', '天使球', 'bird', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '水', '"&pettoday&"', '"&atkskill&"','"&defskill&"','"&luckskill&"','"&learnskill&"','"&lifeskill&"','"&hpmaxskill&"')"
				connpet.ExeCute(SQL)
				call showmessage("你已经有了一个天使球宝宝，一定要好好照顾他/她啊","YD_petmypet.asp")
			elseif request("petname") = 4 then
				SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&eggmoney&" WHERE userid="&Dvbbs.UserId
				Dvbbs.ExeCute(SQL)
				Call UpdateUserInfo(-eggmoney,0,0,0,0,0)	'道具Bug修正
				SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill)VALUES ('"& Dvbbs.MemberName &"', '苹果宝宝', 'green', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '木', '"&pettoday&"','"&atkskill&"','"&defskill&"','"&luckskill&"','"&learnskill&"','"&lifeskill&"','"&hpmaxskill&"')"
				connpet.ExeCute(SQL)
				call showmessage("你已经有了一个苹果宝宝，一定要好好照顾他/她啊","YD_petmypet.asp")
			elseif request("petname") = 5 then
				SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&eggmoney&" WHERE userid="&Dvbbs.UserId
				Dvbbs.ExeCute(SQL)
				Call UpdateUserInfo(-eggmoney,0,0,0,0,0)	'道具Bug修正
				SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill)VALUES ('"& Dvbbs.MemberName &"', '幽灵球', 'devil', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '金', '"&pettoday&"', '"&atkskill&"','"&defskill&"','"&luckskill&"','"&learnskill&"','"&lifeskill&"','"&hpmaxskill&"')"
				connpet.ExeCute(SQL)
				call showmessage("你已经有了一个幽灵球宝宝，一定要好好照顾他/她啊","YD_petmypet.asp")
			elseif request("petname") = 6 then
				SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&eggmoney&" WHERE userid="&Dvbbs.UserId
				Dvbbs.ExeCute(SQL)
				Call UpdateUserInfo(-eggmoney,0,0,0,0,0)	'道具Bug修正
				SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill)VALUES ('"& Dvbbs.MemberName &"', '史莱姆', 'bleb', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '水', '"&pettoday&"', '"&atkskill&"','"&defskill&"','"&luckskill&"','"&learnskill&"','"&lifeskill&"','"&hpmaxskill&"')"
				connpet.ExeCute(SQL)
				call showmessage("你已经有了一个史莱姆宝宝，一定要好好照顾他/她啊","YD_petmypet.asp")
			elseif request("petname") = 7 then
				SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&eggmoney&" WHERE userid="&Dvbbs.UserId
				Dvbbs.ExeCute(SQL)
				Call UpdateUserInfo(-eggmoney,0,0,0,0,0)	'道具Bug修正
				SQL = "INSERT INTO mypetdata (username, mypet,mypetname,mypetlevel,mypetexp,mypethp,mypetmaxhp,mypetsp,mypetatk,mypetdef,mypetdead,mypetsex,mypetsx,petregdate,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill)VALUES ('"& Dvbbs.MemberName &"', '星星花', 'flower', '1', '1', '"&pethp&"', '"&pethp&"', '"&petsp&"', '"&petatk&"', '"&petdef&"', '0', '"&pets&"', '无', '"&pettoday&"','"&atkskill&"','"&defskill&"','"&luckskill&"','"&learnskill&"','"&lifeskill&"','"&hpmaxskill&"')"
				connpet.ExeCute(SQL)
				call showmessage("你已经有了一个星星花宝宝，一定要好好照顾他/她啊","YD_petmypet.asp")
			end if
		end if
	end if
	call main()
end If
Set Dv_plus=Nothing
Dvbbs.Footer

sub main()
%>
<table class=tableborder1 cellspacing=1 cellpadding=3 align=center>
  <tr>
    <th height=27 align=center><%=Dvbbs.Stats%></th>
  </tr>
  <tr>
    <td class=TableBody1>
    <form action=YD_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%" align="center">我的资料</td>
	      </tr>
	      <tr>
		<td align="center">
		<%
		'用户头像调用开始
		If IsNumeric(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text) And IsNumeric(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text) And Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text<>"" And Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text<>"" Then
			If Clng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text)=Clng(Dvbbs.Forum_Setting(39)) And Clng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text)=Clng(Dvbbs.Forum_Setting(38)) Then
				response.write "<img src="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text&">"
			Else
				response.write "<img src="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text&" width=100 height=100>"
			End If
		Else
			response.write "<img src=images/logo_2.gif>"
		End If
		'用户头像调用结束
		%>
		<br><img src=../images/blank.gif width=2 height=5><br>
		</td>
	      </tr>
	      <tr> 
		<td align="center"><nobr>现金货币: <%=money%></nobr></td>
	      </tr>
	    </table>
	    <br>
	    <br>
	    <table width="79%"  border="0" align="center" cellpadding="3" cellspacing="3">
	      <tr> 
		<td width="100%" align="center"><img src="YD_plus/YD_pet/PET/25.gif"></td>
	      </tr>
	    </table>
	  </td>
	  <td width="72%">
	    <table class=tableborder1 style="width:90%" cellspacing=1 cellpadding=3 align=center>
	      <tr> 
		<td class=TableBody2 width="100%">本社区宠物每只定价：<%=DEF_PET_eggmoney%>龙币，您可以根据自己的喜好进行购买。若您的资金不够，可以上<a href=YD_petorphanage.asp>宠物孤儿院</a>看看有无宠物孤儿，在那里领养一只是不花银子地-_-</td>
	      </tr>
	    </table><br>
	    <table class=tableborder1 style="width:90%" cellspacing=1 cellpadding=3 align=center>
	      <tr> 
		<td class=TableBody2 width="24%" align="center">宠物名称</td>
		<td class=TableBody2 width="58%" align="center">宠物介绍（购买新宠物赠送技能和素质点）</td>
		<td class=TableBody2 width="18%" align="center">购买宠物</td>
	      </tr>
	      <tr> 
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/dragon.gif" width="45" height="46">
		<br>泡泡龙（龙系）
		</td>
		<td class=TableBody1>来自东方的一条龙，随着你升级而升级，最终形态将是。。。。。。。<br>
		宠物属性：火 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
		<%=DEF_PointsName%></font><br>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="1">
		购买
		</td>
	      </tr>
	      <tr> 
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/bst.gif" width="45" height="42">
		<br>猫尾球（兽系）
		</td>
		<td class=TableBody1>可爱的兽系宠物，也是人类最好的朋友，最终形态是。。。。。。。。<br>
		宠物属性：土 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
		<%=DEF_PointsName%></font>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="2">
		购买</td>
	      </tr>
	      <tr> 
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/bird.gif" width="45" height="44">
		<br>天使球（鸟系）
		</td>
		<td class=TableBody1>小鸟每个人都喜欢，但是你知道他们还有强大的能力，最终形态是。。。。。。。<br>
		宠物属性：水 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
		<%=DEF_PointsName%></font>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="3">
		购买
		</td>
	      </tr>
	      <tr> 
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/green.gif" width="45" height="46">
		<br>苹果球（植物系）
		</td>
		<td class=TableBody1>谁也没有想到植物会如此强大，孵化后完全拥有飞行和行走能力，最终形态是。。。。。。。<br>
		宠物属性：木 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
		<%=DEF_PointsName%></font>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="4">
		购买
		</td>
	      </tr>
	      <tr> 
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/devil.gif" width="45" height="46">
		<br>幽灵球（恶魔系）
		</td>
		<td class=TableBody1>一生下来就有神秘色彩的幽灵球，同时也拥有神秘的功能，最终形态是。。。。。。。<br>
		宠物属性：金 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
		<%=DEF_PointsName%></font>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="5">
		购买
		</td>
	      </tr>
	      <tr> 
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/bleb.gif" width="45" height="46">
		<br>史莱姆（外星系）
		</td>
		<td class=TableBody1>来自水星的软体动物，到地球后变形为机器人，拥有在水中所有能力，最终进化形态是。。。。。。。<br>
		宠物属性：水 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
		<%=DEF_PointsName%></font>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="6">
		购买
		</td>
	      </tr>
	      <tr> 
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/flower.gif" width="45" height="46">
		<br>星星花（水晶系）
		</td>
		<td class=TableBody1>又一个来自异世界的小可爱，升级会随意获取其他系宠物形态，最终形态为。。。。。。。（特别开放的无属性宠物哦！）<br>
		宠物属性：无 <font color="#FF0000">出售价格： <%=DEF_PET_eggmoney%> 
		<%=DEF_PointsName%></font>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="7">
		购买
		</td>
	      </tr>
	      <tr> 
		<td class=TableBody2 colspan="3" align="center">
		<input type="hidden" name="action" value="buy">
		<input name="submit" type="submit" value="购买">
		</td>
	      </tr>
	    </table>
	  </td>
	</tr>
      </table> 
      </form>
    </td>
  </tr>
</table>
<%
end sub
%>