<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!-- #include file=pet_conn.asp -->
<!--#include file="inc/plus_check.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 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("你还没有宠物啊，快攒钱去买吧~","petshop.asp")
		else

dim tmoney,sword,tmp,necklace,head,body,foot,rndNum
		
if request("action") = "" then
	action = "showroom"
	else
	action = lcase(request("action"))
end if


select case action
	case "buysword"
		sword = request("sword")
		tmoney=clng(DEF_PET_perswordmoney*sword*(1+sword/10))
		tmp=sword-rs("item1")
		if (money<tmoney) then
			call showmessage("你没有那么多钱购买这些物品","petweaponshop.asp")
                  '从这改，做个记号
                  elseif (tmp<1) then
                  call showmessage("你现有的装备等级高于你购买的装备，不用再买了","petweaponshop.asp")
		        else
	 		Dvbbs.execute("UPDATE [DV_user] SET userWealth=userWealth-" & tmoney & " WHERE username='"&DvBBS.MemberName&"'")
			Call UpdateUserInfo(-tmoney,0,0,0,0,0)	'道具Bug修正啦~ 绿光光	 2005-4-8
			connpet.ExeCute("UPDATE mypetdata SET item1="&sword&" WHERE username='"&DvBBS.MemberName&"'")
			randomize
			rndNum=clng((sword+rnd)*10)
			connpet.ExeCute("UPDATE mypetdata SET item1Num="&rndNum&" WHERE username='"&DvBBS.MemberName&"'")
			call showmessage("购买成功，你的攻击力增加 "&rndNum&" 点！","petweaponshop.asp")
		end if
	case "buynecklace"
		necklace = request("necklace")
		tmoney=clng(DEF_PET_pernecklacemoney*necklace*(1+necklace/10))
		tmp=necklace-rs("item2")
		if (money<tmoney) then
			call showmessage("你没有那么多钱购买这些物品","petweaponshop.asp")
        elseif(tmp<1) then
            call showmessage("你现有的装备等级高于你购买的装备，不用再买了","petweaponshop.asp")
		else
			Dvbbs.execute("UPDATE [DV_user] SET userWealth=userWealth-" & tmoney & " WHERE username='"&DvBBS.MemberName&"'")
			Call UpdateUserInfo(-tmoney,0,0,0,0,0)	'道具Bug修正啦~ 绿光光	 2005-4-8
			connpet.ExeCute("UPDATE mypetdata SET item2="&necklace&" WHERE username='"&DvBBS.MemberName&"'")
			randomize
			rndNum=clng((necklace+rnd)*10)
			connpet.ExeCute("UPDATE mypetdata SET item2Num="&rndNum&" WHERE username='"&DvBBS.MemberName&"'")
		   call showmessage("购买成功，你的攻击力增加 "&rndNum&" 点！","petweaponshop.asp")
		end if
	case "buyhead"
		head = request("head")
		tmoney=clng(DEF_PET_perheadmoney*head*(1+head/10))
		tmp=head-rs("item3")
		if (money<tmoney) then
			call showmessage("你没有那么多钱购买这些物品","petweaponshop.asp")
        elseif(tmp<1) then
            call showmessage("你现有的装备等级高于你购买的装备，不用再买了","petweaponshop.asp")
		else
			Dvbbs.execute("UPDATE [DV_user] SET userWealth=userWealth-" & tmoney & " WHERE username='"&DvBBS.MemberName&"'")
			Call UpdateUserInfo(-tmoney,0,0,0,0,0)	'道具Bug修正啦~ 绿光光	 2005-4-8
			connpet.ExeCute("UPDATE mypetdata SET item3="& head &" WHERE username='"&DvBBS.MemberName&"'")
			randomize
			rndNum=clng((head+rnd)*10)
			connpet.ExeCute("UPDATE mypetdata SET item3Num="&rndNum&" WHERE username='"&DvBBS.MemberName&"'")
			call showmessage("购买成功，你的防御力增加 "& rndNum &" 点！","petweaponshop.asp")
		end if
	case "buybody"
		body = request("body")
		tmoney=clng(DEF_PET_perbodyemoney*body*(1+body/10))
		tmp=body-rs("item4")
		if (money<tmoney) then
			call showmessage("你没有那么多钱购买这些物品","petweaponshop.asp")
        elseif(tmp<1) then
            call showmessage("你现有的装备等级高于你购买的装备，不用再买了","petweaponshop.asp")
		else
			Dvbbs.execute("UPDATE [DV_user] SET userWealth=userWealth-" & tmoney & " WHERE username='"&DvBBS.MemberName&"'")
			Call UpdateUserInfo(-tmoney,0,0,0,0,0)	'道具Bug修正啦~ 绿光光	 2005-4-8
			connpet.ExeCute("UPDATE mypetdata SET item4="&body&" WHERE username='"&DvBBS.MemberName&"'")
			randomize
			rndNum=clng((body+rnd)*10)
			connpet.ExeCute("UPDATE mypetdata SET item4Num="&rndNum&" WHERE username='"&DvBBS.MemberName&"'")
			call showmessage("购买成功，你的防御力增加 "&rndNum&" 点！","petweaponshop.asp")
		end if
	case "buyfoot"
		foot = request("foot")
		tmoney=clng(DEF_PET_perfootmoney*foot*(1+foot/10))
		tmp=foot-rs("item5")
		if (money<tmoney) then
			call showmessage("你没有那么多钱购买这些物品","petweaponshop.asp")
        elseif(tmp<1) then
            call showmessage("你现有的装备等级高于你购买的装备，不用再买了","petweaponshop.asp")
		else
			Dvbbs.execute("UPDATE [DV_user] SET userWealth=userWealth-" & tmoney & " WHERE username='"&DvBBS.MemberName&"'")
			Call UpdateUserInfo(-tmoney,0,0,0,0,0)	'道具Bug修正啦~ 绿光光	 2005-4-8
			connpet.ExeCute("UPDATE mypetdata SET item5="&foot&" WHERE username='"&DvBBS.MemberName&"'")
			randomize
			rndNum=clng((foot+rnd)*10)
			connpet.ExeCute("UPDATE mypetdata SET item5Num="&rndNum&" WHERE username='"&DvBBS.MemberName&"'")
			call showmessage("购买成功，你的防御力增加 "&rndNum&" 点！","petweaponshop.asp")
		end if
	case "upwna"		'Aven：物品升级……想得我头大
		dim uprnd,uptype,upnum,uppoint,upword
		uptype=cint(request("type"))
		upnum=cint(request("num"))
		if upnum=0 then
			call showmessage("0级装备无法升级!请购买高级装备！","petweaponshop.asp?action=showupdate")
		end if
		if money<DEF_UpWeopMoney then
			call showmessage("你的钱不够!","petweaponshop.asp?action=showupdate")
		elseif (uptype<=2 and rs("weopitem")<upnum) or (uptype>2 and rs("amoritem")<upnum) then
			'response.write uptype &" "&rs("weopitem")&" "&rs("amoritem")&" "& upnum
			call showmessage("你的升级材料不够!","petweaponshop.asp?action=showupdate")
		else
			randomize
			uprnd=(100*rnd)+1

			if uprnd<=cint((upnum*5+45)/2) then			'基础值50 每等级+5 呵呵 其实很公平啊
				uppoint = 2	
				upword = "运气真好 恭喜你 加强值提高 <font color=red>2</font> 点！"
			elseif uprnd<=(upnum*5+45) then
				uppoint = 1
				upword = "运气不错 恭喜你 加强值提高 <font color=red>1</font> 点！"
			elseif uprnd <= cint((upnum*5+45)*(10-upnum)/20) then
				uppoint = 0
				upword = "运气不好 加强值没有得到提高！"
			else
				uppoint = -1
				upword = "运气不会这么差吧！加强值降低 1 点！<br><font color=red>请注意：等级越高的物品进行升级，越不容易失败！</font>"
			end if
			
			SQL = "UPDATE mypetdata SET item"&uptype&"Num = item"&uptype&"Num + "&uppoint&" WHERE username='"&DvBBS.MemberName&"'"
			connpet.ExeCute(SQL)
			if uptype<=2 then
				connpet.ExeCute("UPDATE mypetdata SET weopitem = weopitem - "&upnum&" WHERE username='"&DvBBS.MemberName&"'")
			else
				connpet.ExeCute("UPDATE mypetdata SET amoritem = amoritem - "&upnum&" WHERE username='"&DvBBS.MemberName&"'")
			end if
			Dvbbs.execute("update [DV_user] set userWealth=userWealth-" & DEF_UpWeopMoney & " WHERE username='"&DvBBS.MemberName&"'")
			Call UpdateUserInfo(-DEF_UpWeopMoney,0,0,0,0,0)	'道具Bug修正啦~ 绿光光	 2005-4-8
			call showmessage(upword,"petweaponshop.asp?action=showupdate")

		end if
	end select		
		
	end if
	rs.close	
%>
<table  border="0" cellspacing="1" cellpadding="5" align="center" class=tableborder4>
  <tr>
	<td height=27 align="center" class=tbhead2><b><font class=HeadFont><%=stats%></font></b></td>
  </tr>
  <tr>
	<td class=tbbg1>
	
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td width="28%" rowspan="2"><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 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=60 height=60>"
            			End If
            		Else
            			response.write "<img src=dv_plus/pet/logo_2.gif>"
            		End If
					%>
					<br><img src=../dv_plus/pet/blank.gif width=2 height=5><br>                      
</div></td>
</tr><tr>
                    <td> <div align="center">
                        <nobr>现金货币: <%=money%></nobr>
                        </div></td>
</tr></table><br> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="3">
<tr><td><div align="center"></div>
<!-- #include file=petnav.asp --></td>
</tr></table><br><table width="79%" border="0" align="center" cellpadding="3" cellspacing="3">
<tr><td width="100%"><div align="center"><img src="dv_plus/pet/pet/27.gif"></div></td>
</tr></table><br><div align="right"></div></td>
<td><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr><td width="16%"><div align="center"><a href="petweaponshop.asp?action=showroom">武器柜台</a></div></td>
<td width="16%"><div align="center"><a href="petweaponshop.asp?action=shownecklace">项链柜台</a></div></td>
<td width="16%"><div align="center"><a href="petweaponshop.asp?action=showhead">头盔柜台</a></div></td>
<td width="16%"><div align="center"><a href="petweaponshop.asp?action=showbody">盔甲柜台</a></div></td>
<td width="16%"><div align="center"><a href="petweaponshop.asp?action=showfoot">鞋子柜台</a></div></td>
<td><div align="center"><a href="petweaponshop.asp?action=showupdate">升级柜台</a></div></td>
</tr></table></td></tr><tr><td width="72%"> 
<%
	if action<>"showupdate" then
	dim atkdef,MPO
	select case action

		case "showroom"
			sql = "SELECT * FROM petitemshop WHERE itemclass='sword' and itemNum <> 0"
			atkdef="攻击力"
			mpo=DEF_PET_perswordmoney
		
		case "shownecklace"
			sql = "SELECT * FROM petitemshop WHERE itemclass='necklace' and itemNum <> 0"
			atkdef="攻击力"
			mpo=DEF_PET_pernecklacemoney

		case "showhead"
			sql = "SELECT * FROM petitemshop WHERE itemclass='head' and itemNum <> 0"
			atkdef="防御力"
			mpo=DEF_PET_perheadmoney
		
		case "showbody"
			sql = "SELECT * FROM petitemshop WHERE itemclass='body' and itemNum <> 0"
			atkdef="防御力"
			mpo=DEF_PET_perbodyemoney

		case "showfoot"
			sql = "SELECT * FROM petitemshop WHERE itemclass='foot' and itemNum <> 0"
			atkdef="防御力"
			mpo=DEF_PET_perfootmoney

	end select
	rs.open sql,connpet,1,1
	rs.movefirst
%>
<form action=petweaponshop.asp name="name" method=post>
<TABLE class=text1 cellSpacing=1 cellPadding=3 width=530 align=center border=0><TR> 
<TD width=100><DIV align=center>名字</DIV></TD>
<TD width=100><DIV align=center>形象</DIV></TD>
<TD width=100><DIV align=center><%=atkdef%></DIV></TD>
<TD width=100><DIV align=center>价格</DIV></TD>
<TD width=100><div align=center>购买选项</div></TD>
</TR>
<%
do while not rs.eof
%>
<TR><TD width=100><DIV align=center><%=rs("ItemName")%></DIV></TD>
<TD width=100><DIV align=center><IMG height=30 src="dv_plus/pet/pet/<%=rs("ItemClass")%>/<%=rs("itemNum")%>.gif" width=30></DIV></TD>
<TD width=100><DIV align=center>＋<%=rs("itemNum")*10%>～<%=rs("itemNum")*10+9%></DIV></TD>
<TD><DIV align=center><%=clng(MPO*rs("itemNum")*(1+rs("itemNum")/10))%></DIV></TD>
<TD width=100 align=middle><div align="center"><input type="radio" name="<%=rs("itemclass")%>" value="<%=rs("itemNum")%>">购买</div></TD></TR>
<%
rs.movenext
loop
rs.movefirst
%>
<TR><TD colspan="5"><DIV align=center><br>
<input name="action" type="hidden" id="action" value="buy<%=rs("itemclass")%>">
<input type="submit" name="Submit2" value="结帐购买"></DIV>
</TD></TR></TABLE></form>
<%rs.close%>
<%
	else

	SQL = "SELECT * FROM mypetdata WHERE username='"&DvBBS.MemberName&"'"
	set rs = connpet.execute(SQL)


	'用很无聊的循环使用变量得到每种道具的名字……
	dim rs3,swordname,necklacename,headname,bodyname,footname
	set rs3 = connpet.execute("select * from petitemshop where itemclass='sword' and itemnum="&rs("item1"))
	swordname = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='necklace' and itemnum="&rs("item2"))
	necklacename = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='head' and itemnum="&rs("item3"))
	headname = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='body' and itemnum="&rs("item4"))
	bodyname = rs3("itemname")
	rs3.close
	set rs3 = connpet.execute("select * from petitemshop where itemclass='foot' and itemnum="&rs("item5"))
	footname = rs3("itemname")
	rs3.close

%>
	<div align=center>
	<table class=text1 cellSpacing=1 cellPadding=3 width=530 align=center border=0 width="100%">
	<tr>
		<td width="25%" height="30" align=center>宠物装备</td>
		<td width="25%" height="30" align=center>目前加强值</td>
		<td width="25%" height="30" colspan=2 align=center>消耗材料</td>
		<td width="25%" height="30" align=center>升级 <br><font color=red>(每次将消耗<%=DEF_UpWeopMoney%><%=DEF_PointsName%>)</font></td>
	</tr>
	<tr><form action="petweaponshop.asp" method="post">
		<td width="25%" height="30" align=center><img height=30 src="dv_plus/pet/pet/sword/<%=rs("item1")%>.gif" alt="<%=swordname%>"></td>
		<td width="25%" height="30" align=center>＋ <%=rs("item1Num")%></td>
		<td width="12.5%" height="30" align=right><img src="dv_plus/pet/pet/wp.gif" width="40" height="40" border="0" alt="武器升级材料"></td>
		<td width="12.5%" height="30" align=left> × <%=rs("item1")%></td>
		<td width="25%" height="30" align=center><input type="submit" value="升级"></td>
		<input type="hidden" name="action" value="upwna">
		<input type="hidden" name="type" value="1">
		<input type="hidden" name="num" value="<%=rs("item1")%>">
		</form>
	</tr>
	<tr><form action="petweaponshop.asp" method="post">
		<td width="25%" height="30" align=center><img height=30 src="dv_plus/pet/pet/necklace/<%=rs("item2")%>.gif" alt="<%=necklacename%>"></td>
		<td width="25%" height="30" align=center>＋ <%=rs("item2Num")%></td>
		<td width="12.5%" height="30" align=right><img src="dv_plus/pet/pet/wp.gif" width="40" height="40" border="0" alt="武器升级材料"></td>
		<td width="12.5%" height="30" align=left> × <%=rs("item2")%></td>
		<td width="25%" height="30" align=center><input type="submit" value="升级"></td>
		<input type="hidden" name="action" value="upwna">
		<input type="hidden" name="type" value="2">
		<input type="hidden" name="num" value="<%=rs("item2")%>">
		</form>
	</tr>
	<tr><form action="petweaponshop.asp" method="post">
		<td width="25%" height="30" align=center><img height=30 src="dv_plus/pet/pet/head/<%=rs("item3")%>.gif" alt="<%=headname%>"></td>
		<td width="25%" height="30" align=center>＋ <%=rs("item3Num")%></td>
		<td width="12.5%" height="30" align=right><img src="dv_plus/pet/pet/am.gif" width="40" height="40" border="0" alt="防具升级材料"></td>
		<td width="12.5%" height="30" align=left> × <%=rs("item3")%></td>
		<td width="25%" height="30" align=center><input type="submit" value="升级"></td>
		<input type="hidden" name="action" value="upwna">
		<input type="hidden" name="type" value="3">
		<input type="hidden" name="num" value="<%=rs("item3")%>">
		</form>
	</tr>
	<tr><form action="petweaponshop.asp" method="post">
		<td width="25%" height="30" align=center><img height=30 src="dv_plus/pet/pet/body/<%=rs("item4")%>.gif" alt="<%=bodyname%>"></td>
		<td width="25%" height="30" align=center>＋ <%=rs("item4Num")%></td>
		<td width="12.5%" height="30" align=right><img src="dv_plus/pet/pet/am.gif" width="40" height="40" border="0" alt="防具升级材料"></td>
		<td width="12.5%" height="30" align=left> × <%=rs("item4")%></td>
		<td width="25%" height="30" align=center><input type="submit" value="升级"></td>
		<input type="hidden" name="action" value="upwna">
		<input type="hidden" name="type" value="4">
		<input type="hidden" name="num" value="<%=rs("item4")%>">
		</form>
	</tr>
	<tr><form action="petweaponshop.asp" method="post">
		<td width="25%" height="30" align=center><img height=30 src="dv_plus/pet/pet/foot/<%=rs("item5")%>.gif" alt="<%=footname%>"></td>
		<td width="25%" height="30" align=center>＋ <%=rs("item5Num")%></td>
		<td width="12.5%" height="30" align=right><img src="dv_plus/pet/pet/am.gif" width="40" height="40" border="0" alt="防具升级材料"></td>
		<td width="12.5%" height="30" align=left> × <%=rs("item5")%></td>
		<td width="25%" height="30" align=center><input type="submit" value="升级"></td>
		<input type="hidden" name="action" value="upwna">
		<input type="hidden" name="type" value="5">
		<input type="hidden" name="num" value="<%=rs("item5")%>">
		</form>
	</tr>
	</table>
	<br>
	<table class=text1 cellSpacing=1 cellPadding=3 width=530 align=center border=0 width="100%">
	<tr>
		<td colspan=2><div align=center>我目前拥有武器/防具升级材料</div></td>
	</tr>
	<tr>
		<td><img src="dv_plus/pet/pet/wp.gif" width="40" height="40" border="0" alt="武器升级材料"> × <%=rs("weopitem")%> 个</td>
		<td><img src="dv_plus/pet/pet/am.gif" width="40" height="40" border="0" alt="防具升级材料"> × <%=rs("amoritem")%> 个</td>
	</tr>
	</table>
	</div>
<%
rs.close
end if
%>
<br>
<br>
</td>
</tr></table>
</td></tr></table>
<% End If  :   Set Dv_plus=Nothing : Dvbbs.Footer %>
