争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

用ASP完成网上“5子棋”大赛

时间:2024/7/9作者:未知来源:争怎路由网人气:

"

for j=1 to 15

win=false

loss=false

five_me=0

five_he=0

for i=1 to 15

if application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(i) & "_" &
cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

 

'斜向判断"/"

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=i+4 to 1 step -1

if application("color" & session("class") & "_" & cstr(j) & "_" & cstr
(i+5-j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(j) & "_" &
cstr(i+5-j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

 

'斜向判断"\"

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=12-i to 15

if application("color" & session("class") & "_" & cstr(13-i-j) & "_"
& cstr(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(13-i-j)
& "_" & cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

%>

</body>

</html>

   如果某点没有棋子,则加上一个超连接,根据擂主与攻擂手的区别放上一个不同颜色的棋子。最后的一段是用来判断输与赢,分为横,列和两个斜线方向。具体内容看一下就可以明白。

   最后要说的一点就是global.asa ,这是站点上的一个核心文件,为了在退出棋局后,将位置留给别人,需要在sesison_onend中加入代码进行处理,如下:

<script language=vbscript runat = server>

sub application_onstart

session.timeout=1

end sub

sub session_onstart

if application("num")="" then

application("num")=0

end if

application("num")=application("num")+1

end sub

</script>

 

<script language=vbscript runat = server>

sub session_onend

if application("num")="" then

application("num")=0

end if

application("num")=application("num")-1

 

if application("first1")=session("nice") then

application("first1")=""

elseif application("second1")=session("nice") then

application("second1")=""

 

elseif application("first2")=session("nice") then

application("first2")=""

elseif application("second2")=session("nice") then

application("second2")=""

 

elseif application("first3")=session("nice") then

application("first3")=""

elseif application("second3")=session("nice") then

application("second3")=""

 

elseif application("first4")=session("nice") then
application("first4")=""
elseif application("second4")=session("nice") then
application("second4")=""
 

elseif application("first5")=session("nice") then

application("first5")=""

elseif application("second5")=session("nice") then

application("second5")=""

end if

for i=1 to 15

for j=1 to 15

application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(J))=""

application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""

next

next

application(session("nice"))=""

end sub

</script>

以上就是几个主要的文件,大家可以一试。什么,想做围棋?把棋盘改一下就可以了。

祝大家成功! 

关键词:用ASP完成网上“5子棋”大赛




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版