“五子棋”是大家都非常熟悉的一種益智類游戲
對於ASP
游戲的過程是這樣的
如果你是以擂主身份進入的
該站點有幾個主要的文件是
Index
Index
Match
Back
在程序的初始化的時候
先看看登錄文件
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio
<title>星球大戰之“五子連珠”大賽!</title>
</HEAD>
<BODY>
<p align=center><font size=
<table border=
<tr><td>星球</td><td>擂主</td><td>大戰</td><td>攻擂</td></tr>
<tr>
<td>金星</td>
<td>
<%
if application("first
%>
<form action=index
<INPUT id=text
type=submit value=進入>
</form>
<%
else
response
end if
%>
</td>
<td>大戰</td>
<td>
<%
if application("second
%>
<form action=index
<INPUT id=text
name=submit
</form>
<%
else
response
end if
%>
</td>
</tr>
<tr>
<td>木星</td>
<td>
<%
if application("first
%>
<form action=index
<INPUT id=text
type=submit value=進入>
</form>
<%
else
response
end if
%>
</td>
<td>大戰</td>
<td>
<%
if application("second
%>
<form action=index
<INPUT id=text
name=submit
</form>
<%
else
response
end if
%>
</td>
</tr>
<tr>
<td>金星</td>
<td>
<%
if application("first
%>
<form action=index
<INPUT id=text
type=submit value=進入>
</form>
<%
else
response
end if
%>
</td>
<td>大戰</td>
<td>
<%
if application("second
%>
<form action=index
<INPUT id=text
name=submit
</form>
<%
else
response
end if
%>
</td>
</tr>
<tr>
<td>金星</td>
<td>
<%
if application("first
%>
<form action=index
<INPUT id=text
type=submit value=進入>
</form>
<%
else
response
end if
%>
</td>
<td>大戰</td>
<td>
<%
if application("second
%>
<form action=index
<INPUT id=text
name=submit
</form>
<%
else
response
end if
%>
</td>
</tr>
<tr>
<td>金星</td>
<td>
<%
if application("first
%>
<form action=index
<INPUT id=text
type=submit value=進入>
</form>
<%
else
response
end if
%>
</td>
<td>大戰</td>
<td>
<%
if application("second
%>
<form action=index
<INPUT id=text
name=submit
</form>
<%
else
response
end if
%>
</td>
</tr>
</table>
</BODY>
</HTML>
這個文件不用做過多的說明
index
<%@ Language=VBScript %>
<%
if Request
session("nice")=Request
if application(request
application(request
session("class")=right(request
if left(request
application(session("nice"))=false
elseif left(request
application(session("nice"))=false
application(application("first" & session("class")))=true
end if
Response
end if
end if
%>
<HTML>
</HTML>
該程序中
first
“水”“火”“土”分別表示為
<html>
<head>
<meta http
<meta name="GENERATOR" content="Microsoft FrontPage
<meta name="ProgId" content="FrontPage
<META http
<title>連珠大賽
</head>
<%
Response
& " 攻擂
("class"))
if Request
application("pos" & session("class") & Request
=true
end if
%>
<body>
<%
if application("first" & session("class"))=session("nice") then
color="black"
if Request
if session("last")="" then session("last")="abc"
if session("last")<> Request
application(application("first" & session("class")))=false
if application("second" & session("class"))<>"" then application
(application("second" & session("class")))=true
session("last")=Request
END IF
end if
else
if application("second" & session("class"))=session("nice") then
color="white"
if Request
if session("last")<> Request
application(application("first" & session("class")))=true
application(application("second" & session("class")))=false
session("last")=Request
END IF
end if
else
if application("second" & session("class"))="" then
application("second" & session("class"))=session("nice")
color="white"
if Request
if session("last")="" then session("last")="abc"
if session("last")<> Request
application(application("first" & session("class")))=true
application(application("second" & session("class")))=false
session("last")=Request
END IF
end if
else
color=""
end if
end if
end if
Response
cellpadding=
for i=
Response
for j=
if application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""
then
application("color" & session("class") & "_" & Request
("pos"))=color
Response
if application(session("nice"))=true then
response
& "><img border=
else
response
end if
response
else
Response
application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(j)) & "
end if
next
Response
next
Response
if application("first" & session("class"))=session("nice") then
m="black"
h="white"
else
h="black"
m="white"
end if
for i=
win=false
loss=false
five_me=
five_he=
for j=
if application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(j))=m then
five_me=five_me+
five_he=
elseif application("color" & session("class") & "_" & cstr(i) & "_" &
cstr(j))=h then
five_me=
five_he=five_he+
else
five_me=
five_he=
end if
if five_me=
win=true
loss=false
exit for
elseif five_he=
win=false
loss=true
exit for
end if
next
if win or loss then exit for
next
if win then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
if loss then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
for j=
win=false
loss=false
five_me=
five_he=
for i=
if application("color" & session("class") & "_" & cstr(i) & "_" & cstr
(j))=m then
five_me=five_me+
five_he=
elseif application("color" & session("class") & "_" & cstr(i) & "_" &
cstr(j))=h then
five_me=
five_he=five_he+
else
five_me=
five_he=
end if
if five_me=
win=true
loss=false
exit for
elseif five_he=
win=false
loss=true
exit for
end if
next
if win or loss then exit for
next
if win then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
if loss then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
for i=
win=false
loss=false
five_me=
five_he=
for j=i+
if application("color" & session("class") & "_" & cstr(j) & "_" & cstr
(i+
five_me=five_me+
five_he=
elseif application("color" & session("class") & "_" & cstr(j) & "_" &
cstr(i+
five_me=
five_he=five_he+
else
five_me=
five_he=
end if
if five_me=
win=true
loss=false
exit for
elseif five_he=
win=false
loss=true
exit for
end if
next
if win or loss then exit for
next
if win then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
if loss then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
for i=
win=false
loss=false
five_me=
five_he=
for j=
if application("color" & session("class") & "_" & cstr(
& cstr(j))=m then
five_me=five_me+
five_he=
elseif application("color" & session("class") & "_" & cstr(
& "_" & cstr(j))=h then
five_me=
five_he=five_he+
else
five_me=
five_he=
end if
if five_me=
win=true
loss=false
exit for
elseif five_he=
win=false
loss=true
exit for
end if
next
if win or loss then exit for
next
if win then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
if loss then
response
application(application("first" & session("class")))=false
application(application("second" & session("class")))=false
end if
%>
</body>
</html>
如果某點沒有棋子
最後要說的一點就是global
<script language=vbscript runat = server>
sub application_onstart
session
end sub
sub session_onstart
if application("num")="" then
application("num")=
end if
application("num")=application("num")+
end sub
</script>
<script language=vbscript runat = server>
sub session_onend
if application("num")="" then
application("num")=
end if
application("num")=application("num")
if application("first
application("first
elseif application("second
application("second
elseif application("first
application("first
elseif application("second
application("second
elseif application("first
application("first
elseif application("second
application("second
elseif application("first
application("first
elseif application("second
application("second
elseif application("first
application("first
elseif application("second
application("second
end if
for i=
for j=
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實現網上“五子棋”大賽
From:http://tw.wingwit.com/Article/program/net/201311/14337.html