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

	sql = "SELECT * FROM [mypetdata] WHERE username='"& DvBBS.MemberName &"' "
	rs.open sql,connpet,1,3
	if rs.eof then
		call showmessage("你还没有宠物啊，快攒钱去买吧~","YD_petshop.asp")
	else
		dim petlevel,relive,atkskill,defskill,luckskill,learnskill,lifeskill,hpmaxskill,temp
		if request("action") = "change" then
			if rs("mypetdead") <> 0 then
				call showmessage("先把宝宝救活再说吧:(","YD_petmypet.asp")
			end if
			relive=int(rs("relive"))
			petlevel=int(rs("mypetlevel"))
			atkskill=rs("atkskill")
			defskill=rs("defskill")
			luckskill=rs("luckskill")
			learnskill=rs("learnskill")
			lifeskill=rs("lifeskill")
			hpmaxskill=rs("hpmaxskill")
			temp = int(6*rnd)+1
			select case temp
				case 1
					atkskill=atkskill+1
				case 2
					defskill=defskill+1
				case 3
					luckskill=luckskill+1		
				case 4
					learnskill=learnskill+1
				case 5
					hpmaxskill=hpmaxskill+1
				case 6
					lifeskill=lifeskill+1
			end select

			if petlevel<100 then
				call showmessage("你的级别不够，还是先练练吧~","YD_petrisk.asp")
			elseif request("petname") = "" then
				call showmessage("你还没有选定你要转生的宝宝啊，请重新选择","YD_petrelive.asp")
			elseif money < DEF_PET_relmoney then
				call showmessage("你没有足够的钱转生","YD_petrelive.asp")
			else
				dim pettoday,pets,relmoney,pethp,petsp,petatk,petdef,szd,skill
				Randomize '初始化随机数生成器。
				pettoday = date()
				pets = rs("mypetsex")
				relmoney = DEF_PET_relmoney 
				pethp = DEF_PET_basichp
				petsp = DEF_PET_basicsp
				petatk = Int(rs("mypetatk")+10)
				petdef = Int(rs("mypetdef")+10)
				szd=rs("szd")+30
				skill=rs("skill")+5
				relive = relive + 1

				if request("petname") = 1 then
					SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
					Dvbbs.ExeCute(SQL)
					'道具Bug修正
					Call UpdateUserInfo(-relmoney,0,0,0,0,0)
					SQL = "UPDATE mypetdata SET mypetname='dragon',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='火',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
					connpet.ExeCute(SQL)
					call showmessage("转生成功！你的宠物转生为<font color=blue>泡泡龙</font>宝宝，防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
				elseif request("petname") = 2 then
					SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
					Dvbbs.ExeCute(SQL)
					'道具Bug修正
					Call UpdateUserInfo(-relmoney,0,0,0,0,0)
					SQL = "UPDATE mypetdata SET mypetname='bst',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='土',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
					connpet.ExeCute(SQL)
					call showmessage("转生成功！你的宠物转生为<font color=blue>猫尾球</font>宝宝，防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
				elseif request("petname") = 3 then
					SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
					Dvbbs.ExeCute(SQL)
					'道具Bug修正
					Call UpdateUserInfo(-relmoney,0,0,0,0,0)
					SQL = "UPDATE mypetdata SET mypetname='bird',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='水',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
					connpet.ExeCute(SQL)
					call showmessage("转生成功！你的宠物转生为<font color=blue>天使球</font>宝宝，防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
				elseif request("petname") = 4 then
					SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
					Dvbbs.ExeCute(SQL)
					'道具Bug修正
					Call UpdateUserInfo(-relmoney,0,0,0,0,0)
					SQL = "UPDATE mypetdata SET mypetname='green',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='木',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
					connpet.ExeCute(SQL)
					call showmessage("转生成功！你的宠物转生为<font color=blue>苹果宝宝</font>宝宝，防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
				elseif request("petname") = 5 then
					SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
					Dvbbs.ExeCute(SQL)
					'道具Bug修正
					Call UpdateUserInfo(-relmoney,0,0,0,0,0)
					SQL = "UPDATE mypetdata SET mypetname='devil',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='金',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
					connpet.ExeCute(SQL)
					call showmessage("转生成功！你的宠物转生为<font color=blue>幽灵球</font>宝宝，防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
				elseif request("petname") = 6 then
					SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
					Dvbbs.ExeCute(SQL)
					'道具Bug修正
					Call UpdateUserInfo(-relmoney,0,0,0,0,0)
					SQL = "UPDATE mypetdata SET mypetname='bleb',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='水',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
					connpet.ExeCute(SQL)
					call showmessage("转生成功！你的宠物转生为<font color=blue>史莱姆</font>宝宝，防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
				elseif request("petname") = 7 then
					SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
					Dvbbs.ExeCute(SQL)
					'道具Bug修正
					Call UpdateUserInfo(-relmoney,0,0,0,0,0)
					SQL = "UPDATE mypetdata SET mypetname='flower',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='无',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
					connpet.ExeCute(SQL)
					call showmessage("转生成功！你的宠物转生为<font color=blue>星星花</font>宝宝，攻击、防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
				elseif request("petname") = 8 then
					if relive<3 then
						call showmessage("3转才可以选择该宠物","YD_petrelive.asp")
					else
						SQL = "UPDATE [Dv_user] SET userWealth=userWealth-"&relmoney&" WHERE userid="&Dvbbs.UserId
						Dvbbs.ExeCute(SQL)
						'道具Bug修正
						Call UpdateUserInfo(-relmoney,0,0,0,0,0)
						SQL = "UPDATE mypetdata SET mypetname='Gol',mypetlevel='1',mypetexp='1',mypethp='"&pethp&"',mypetmaxhp='"&pethp&"',mypetsp='"&petsp&"',mypetatk='"&petatk&"',mypetdef='"&petdef&"',mypetsx='龙',petregdate='"&pettoday&"',atkskill='0',defskill='0',luckskill='0',hpmaxskill='0',learnskill='0',lifeskill='0',str='0',ski='0',def='0',vit='0',szd='"&szd&"',skill='"&skill&"',relive='"&relive&"' WHERE username='"& DvBBS.MemberName &"' "
						connpet.ExeCute(SQL)
						call showmessage("转生成功！你的宠物转生为<font color=blue>百变兽</font>宝宝，攻击、防御和技能均有提升，继续努力吧~","YD_petmypet.asp")
					end if
				end if
			end if
		end if
	end if                    
	rs.close
	set rs=nothing
	Endcon()
	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_petrelive.asp name="petname" mtehod=post>
      <table width="100%" cellspacing="0" cellpadding="0">
	<tr>
	  <td width="28%">
	    <table width="79%" 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
		'用户头像调用结束
		%>
		</td>
	      </tr>
	      <tr>
		<td align="center"><nobr>现金货币: <%=money%></nobr></td>
	      </tr>
	    </table>
	    <br>
	    <br>
	    <table width="79%" align="center" cellpadding="3" cellspacing="3">
	      <tr>
		<td width="100%" align="center"><!-- #include file=YD_petnav.asp --></td>
	      </tr>
	    </table>
	  </td>
	  <td width="72%">
	    <table class=tableborder1 style="width:100%" cellspacing=1 cellpadding=3 align=center>
	      <tr>
		<td colspan=3 class=TableBody2>
		<font color=blue><%=Dvbbs.MemberName%></font>，欢迎你来到宠物转生所！如果你的宠物等级到达125以上，就可以来这选定你要转生的属系；转生后宠物将重新开始升级，每转1次基本攻击和防御都上升10，增加30点素质点，增加5点技能值。</td>
	      </tr>
	      <tr>
		<th width="24%" align="center">宠物名称</th>
		<th width="58%" align="center">宠物介绍</th>
		<th width="18%" align="center">选择转生</th>
	      </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_relmoney%> 
		<%=DEF_PointsName%></font>
		</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_relmoney%> 
		<%=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_relmoney%> 
		<%=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_relmoney%> 
		<%=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_relmoney%> 
		<%=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_relmoney%> 
		<%=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_relmoney%> 
		<%=DEF_PointsName%></font>
		</td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="7">选择</td>
	      </tr>
	      <tr>
		<td class=TableBody1 align="center"><img src="YD_plus/YD_pet/PET/Gol.gif" width="88" height="77"><br>百变兽（神兽系）</td>
		<td class=TableBody1>神圣的百变兽，由于强大的能力，让他居于乱世中的中立，最终形态是兽王<br>
		宠物属性：龙 <font color="#FF0000">转生费用： <%=DEF_PET_relmoney%> 
		<%=DEF_PointsName%></font></td>
		<td class=TableBody1 align="center"><input type="radio" name="petname" value="8">选择</td>
	      </tr>
	      <tr>
		<td colspan="3" class=TableBody2 align="center">
		<input type="hidden" name="action" value="change">
		<input name="submit" type="submit" value="选择">
		</td>
	      </tr>
	    </table>
	  </td>
	</tr>
      </table> 
      </form>
    </td>
  </tr>
</table>
<%
end sub
%>