发新话题
打印

[原创] 用ASP实现网上“五子棋”大赛

用ASP实现网上“五子棋”大赛

“五子棋”是大家都非常熟悉的一种益智类游戏,相关的游戏软件也非常多,在此我向大家隆重推出一款新的纯“网络版”的五子棋,它利用ASP做为开发环境,因此在Internet上对战的时候无需下载客户端软件,只要你有一个浏览器就可以了。你也可以在局域网上进行这个游戏。 8 |# G% `. {0 ~: @  O# {
对于ASP,我不想做过多的说明,在以前的文章中,我已经说过很多。
5 T- Y- r1 Q2 |! X' x0 K2 F游戏的过程是这样的,我们首先登录,然后可以选择战场,有“金星”、“木星”、“水星”、“火星”、“土星”等五个战场,如果你自认为是一个高手,可以选择金星,否则可以依次选择其它几个星球做为战场。如果这个星球上没有擂主,你就应该以擂主的身份进入,然后别人就可以和你进行对战了。当然,如果所有的星球上都已经开始了战争,那么你就只能等一会儿了。
' l7 e% d. V* r8 X2 f) X! ^如果你是以擂主身份进入的,你可以等待别人来和你对战,如果你是以攻擂手的身份登录,你可以很快的和擂主展开战斗。开始战斗后,由擂主执黑先行,然后由攻擂手出招,如此这般。当最后决出胜负的时候,会有相应的提示。 $ D, m. y% _* @: N& U2 S; I3 P
该站点有几个主要的文件是:
/ @( F! f, w( k/ ]7 `Index.asp 登录文件:
( o  E* o# T3 G5 Q. gIndex0.asp中间文件: & c0 V+ V" O% h# ~
Match.asp 比赛文件:
7 a$ U# k3 h4 F1 kBack0.jpg white0.jpg black0.jpg 中间用到的图形文件,分别指的棋盘,白子和黑子,如下图:
+ z0 J  ?; S% I; A在程序的初始化的时候,将棋盘上分成若干的表格,将背景图片放入其中,形成一个棋盘,然后在放上一个棋子后,再将图片换上相应的白子或黑子就可以了。 $ b( e5 W& R6 q: E/ y- X+ s
先看看登录文件: * N" {: E! y8 L2 q
<%@ Language=VBScript %> 2 q/ r) V4 w7 q% n1 f, A0 T0 Q
<HTML> 4 o( r) c, }5 \" i: ]1 I& N4 _
<HEAD>
, O7 r8 ?0 H: G( `<META NAME="GENERATOR" C> $ ?' k9 L/ a( h8 L6 }4 Z' {' ?
<title>星球大战之“五子连珠”大赛!</title> 2 k: h3 Q. D+ H* s& R" h, [! ~
</HEAD>
' ]& [. Z7 j2 _( |4 ]( ]<BODY> 4 |( U. m' W. g% }" q# p
 
' i. d. d4 F: d1 Y<p align=center><font size=6>星球大战</font></P>
# y6 Q  }" b" b6 N* b! o, `<table border=1 width=80% align=center> 3 H; ~4 p, y' {
<tr><td>星球</td><td>擂主</td><td>大战</td><td>攻擂</td></tr> 9 D* x7 s8 n$ ^0 Z* v4 T) Q5 _
<tr>
3 {7 _! x# T1 N$ p+ A" x8 m& h<td>金星</td>
  s3 C: L6 A4 D: Q0 A<td>
2 T6 S+ @% B6 s1 L7 j$ P<%
' p% d, \. s9 b0 ?if application("first1")="" then
) ^' g7 E% j, [%> 7 y; \. g; T! f: g
<form action=index0.asp?flag=First1 method=post> / G- _7 F, n9 P
<INPUT id=text1 name=txtFirst1 size=10><INPUT id=submit1 name=submit1
+ G5 \7 m+ S' S+ i$ {! itype=submit value=进入>
2 a6 n& I: _; V8 ?2 ~3 C5 e</form>
. F  y2 d% d; y) F9 w" y- s0 X<%
) f, M4 P4 T# n0 V! }; kelse 6 x( V1 N6 ?) s3 A
response.write application("first1")
3 M3 \3 k5 o3 L" u, w, ?3 wend if - U% l9 o3 R. T
%>
$ B3 e% p+ z- {# o. X3 U& K</td> / }9 N$ \  K) }7 Q2 h5 e
<td>大战</td> 3 I# j' T0 E" T4 ?8 a
<td> * a- M8 ]" E) v% U! Z
<%
; m1 p1 }) |( l. D6 Q8 O* zif application("second1")="" then
! l  ^2 f8 W# ^( m8 y5 H$ f%> 4 u- [) U: C) I
  1 }0 |9 L# B* k( l, w
<form action=index0.asp?flag=second1 method=post>
* H. _: V% R0 k; z& F7 |<INPUT id=text1 name=txtSecond1 size=10><INPUT id=submit1 ( ^. {1 v: T+ c7 d! u# i4 z
name=submit1 type=submit value=进入> ( J# E/ f6 o" S4 d3 m' v  L' {0 n
</form> / y$ `6 r) R/ K4 e
<% 3 F5 Z# y' {7 Q7 D# y
else
" Q6 ~* t. p* U1 @" b  a4 `/ Yresponse.write application("Second1")
' R& d. o0 h- t: |( Jend if 7 Q  j3 b$ V. x
%>
9 V- z' h- n( Q5 L</td>
; [9 a, j3 A% [6 C</tr>
; G) q- M0 o8 h$ t6 b  - h1 T2 U0 P6 w
<tr> 7 @+ F* Y6 b" Q$ F8 [
<td>木星</td>
: P+ ]: G- W. ?6 [& _( i& _8 u<td> ! q$ N0 |( K( o/ R
<% ' A3 E# Q+ u+ D
if application("first2")="" then 3 [/ ]/ ^/ \, z
%>
9 f  \+ E1 f* w! G$ D* N: F6 [* z4 f<form action=index0.asp?flag=First2 method=post>
9 r! L. j, N8 h. Y) |- O  p<INPUT id=text1 name=txtFirst2 size=10><INPUT id=submit1 name=submit1 9 ?: ^5 {2 H) V
type=submit value=进入>
) ~* Z) M" Q8 ?9 ~4 m& c  C: D</form>
% k( m! _7 Q- j2 t% F' K3 n<%
( Q2 J, D4 Q0 c& C6 Y4 m1 l1 ?else & e3 P) e- v. ?1 e& y  x( s. A
response.write application("first2")
) M- M( J; A6 M3 i1 I+ send if
+ ~  C& L" m+ M& h%> * j( f( V9 D. g; F: P  Z
</td>
3 s, c; X7 M, t9 _. [<td>大战</td> . W& U; D. V& I
<td>
: u( h! k6 M9 i' x2 h2 Q8 A# L<%
3 Q) H) w  v; \4 yif application("second2")="" then 2 t* y; Z" h0 C7 }. ~; C  X
%> 1 z7 j' _! y4 x
 
* U! E. G% Z/ T<form action=index0.asp?flag=second2 method=post>
2 ^) \4 Y1 b- I3 `" ?* F! g$ ^<INPUT id=text1 name=txtSecond2 size=10><INPUT id=submit1 : R9 ~3 M1 V9 {; C: I
name=submit1 type=submit value=进入>
9 i( {' b+ N6 z$ h! a; g' t</form> 8 ~% a) c# T- G8 [# g, o
<%
( u8 D; f, ?; f9 t7 Zelse # t6 T( d( i+ S0 n$ z- I
response.write application("Second2") & I. c# R+ b% l' Q
end if $ d8 |+ @$ c7 @
%>
: w; a" p9 Z6 D: N7 Y</td>
1 G6 r$ o7 _" L$ {  V6 l</tr> 4 k4 Z" F% f3 I$ a; t% _" G
  - J* ?' |+ n) L0 W# d
<tr>
: A" r2 i( o# f0 T" k% E5 `+ d<td>金星</td>
; {5 p) H$ P5 f) S. S  N<td>
/ k3 ]3 l7 O4 b  R; X* c6 g<%
9 i8 M% _' t& B2 G& Y8 P4 lif application("first3")="" then
7 ~2 T* W4 L+ U. ?6 P%>
+ E1 r3 s* Q( F9 h+ n  ?<form action=index0.asp?flag=First3 method=post>
3 Z5 q' \, p# N& B- `<INPUT id=text1 name=txtFirst3 size=10><INPUT id=submit1 name=submit1
) r; |7 i2 a9 k( Vtype=submit value=进入> 0 c1 R& r6 Z" T! X1 r
</form> # C/ l" f+ p7 l8 {, o+ q
<%
4 M; H$ B. T! H0 N$ l3 x8 kelse
; H9 y- Y  L7 i2 I3 [8 w$ A! Sresponse.write application("first3") 8 u3 F# j' R* H# I! `
end if ' A0 B6 Q  @* i( r
%>
9 R+ p- j$ U) `% R</td>
% K3 t' p+ D/ H4 \<td>大战</td> % b& D* E0 c" m. ~: w& }% L
<td>
4 o7 \4 x2 e" e9 z<% ) H" J8 h. i  m& k, m0 B
if application("second3")="" then
+ Q" t! T" `( I8 Y+ @5 R%> , V. s6 s. y2 y! b! j, }6 K9 i( I
  5 g! m& Z1 `9 E% D* r
<form action=index0.asp?flag=second3 method=post>
  r( @: ]' p; m8 |<INPUT id=text1 name=txtSecond3 size=10><INPUT id=submit1   t- h* }  O9 m/ x0 T+ V; Y# h' [
name=submit1 type=submit value=进入>
( k+ L; }+ U- l7 }9 S</form> 7 s& R; |  m$ @. G: v9 I$ \
<% - W+ }9 @, v) t/ M* E
else ( ]2 }# z2 u1 B
response.write application("Second3")
9 L5 w; w; J/ P% s% p5 @end if ' F* N- [! p& z/ ^
%> % \; ~4 G/ N6 b
</td>
. f, o% a$ R5 d' q6 ?' _; B8 p7 x</tr>
% s: b# f7 m; Q 
9 `5 [  ~  f* \- J<tr> # j% p$ O, j7 x9 N
<td>金星</td> 4 i3 N4 [# t1 j( ^; ?  v" S
<td> ; r/ L$ t* |9 A
<% ; m( {' [) J& n! `' h- S
if application("first4")="" then + w" B" T0 b/ U5 m
%> $ i. @" ^  X' c
<form action=index0.asp?flag=First4 method=post> % `8 C7 M8 J" J
<INPUT id=text1 name=txtFirst4 size=10><INPUT id=submit1 name=submit1
4 t& ?# y6 H' A! Y: `+ [! p  m4 [type=submit value=进入> * b  \6 K* X+ {1 E
</form>
) D, o& y. v6 q. ]! _2 y<%
6 M5 b- A. ?7 P9 G" r& Jelse * x0 y: {* p+ I0 V) ]
response.write application("first4")
  V/ P( t9 t, C7 E5 f# b: ?- qend if
* u4 A. R$ j. T9 z! P- Q  p%> + f# |/ o6 E8 t" B! o
</td> ) e5 X6 d% m2 [5 t
<td>大战</td> ! j* k+ }1 J9 V! l. I" X# N
<td> * ~2 \  C* ?  B
<% 2 E& [. F$ S4 X/ e$ u+ o. p  Z
if application("second4")="" then
  n; h+ @3 E) o$ X0 O  ]9 l9 z%>
, k# Z6 @/ t+ e1 \" `. K% n  ! r1 @$ I8 a! L8 \2 D$ ?
<form action=index0.asp?flag=second4 method=post>
" z% k, k& W* d+ D& r7 d<INPUT id=text1 name=txtSecond4 size=10><INPUT id=submit1 & r" M$ y  Q7 [- K/ U, g3 j
name=submit1 type=submit value=进入>
2 W+ K) c0 |; c" Q* D1 B9 y</form> * B; ~5 ?  w1 G1 H8 s
<% & L: u. u, r' g, L! r0 U
else 6 q8 d7 F/ o3 A+ Y
response.write application("Second4")
- y2 a/ l* H9 ]7 o% |$ @6 a4 @( }7 _) Dend if
) k" p. h' M6 {- `2 i% `- d0 L%>
( M+ n3 \3 k, L) e# H4 x: t/ n4 l</td> $ f" u, g3 V9 k+ i* z' e6 L
</tr>
$ r( u8 c7 t2 P: F; f9 H2 S3 ]2 I 
5 E  I9 e: k! \4 o. A* A<tr> 5 H8 @) \% N0 t9 m
<td>金星</td> 6 g" R) z7 k) B5 J: }
<td>
( }4 D9 }7 Y7 n# Q<% 8 x- I7 ^8 a0 @5 F  P4 `/ K
if application("first5")="" then 8 @5 t+ J% G/ w0 N) Z( L
%> 5 V3 E3 }  I& B) c- t4 K
<form action=index0.asp?flag=First5 method=post> 4 ^& Y- V# F) L
<INPUT id=text1 name=txtFirst5 size=10><INPUT id=submit1 name=submit1
% z" s/ x" L5 t+ u: ^! A' Utype=submit value=进入>
0 P. O1 ^3 |/ b& j5 A2 x</form>
+ K9 y' {- b/ ^; _6 `0 U5 o" y$ t<% 5 C# Q8 ]( r" H+ C3 \- {) e0 q
else
$ r( J6 ]/ n) K# P  m$ H3 O, Presponse.write application("first5")
8 T( b: r% ]9 v+ i3 F; {6 Fend if 1 M$ q/ J4 H! S. M! {! ]/ `, l% t' k
%>
, R; k; x6 P3 }" X</td>
  a' N( G0 y9 {<td>大战</td> 6 N, T6 a, \3 p) t: V- \
<td> 9 x, Z) m5 g, Q& h5 `
<%
# ?- }) N# k2 Rif application("second5")="" then 7 E+ P; r; s8 X. m: |$ q& J, D; s: Q
%>
( L/ l0 `3 a1 f$ w# y# P' g 
5 P1 K# @- J- S) F<form action=index0.asp?flag=second5 method=post> " ^9 W0 Z6 f# D' ~
<INPUT id=text1 name=txtSecond5 size=10><INPUT id=submit1
6 N, g$ a/ [0 K- b8 Y4 S4 Mname=submit1 type=submit value=进入>
2 i/ `* y: i8 N' s, m</form>
. D6 I/ {  [5 B" a$ N- g9 g% u<% 9 v& v. e, Y& h; L
else % i7 m0 D+ J9 d4 x3 T, M3 M
response.write application("Second5")
$ r* l7 R/ T0 D* p+ ]8 k; Qend if
% s' L. w9 M5 [%>
6 R" d, @7 R/ C7 }% |4 p, G</td> 1 A7 S  g; I* ?, }+ l
</tr>  6 [  k9 q, V6 r: m) [* }
</table> " H, H, y( [7 n% @/ x/ b* h
</BODY> 1 m+ G6 c' N+ e3 R2 I
</HTML>
0 o/ k" }0 S$ K1 z% q# R
这个文件不用做过多的说明,就是一个大的表格,大家可以从那里进入,如果某个位置已经被使用,则它会变成该大 侠的名字,不允许重复登录。在登录后进入
: |( b+ r) ^8 A2 i( h2 f  rindex0.asp,这是一个中间交换文件,在里面进行一些变量的处理及赋值,然后再进入match.asp,进行正式的比赛。我们来看一下index0.asp的内容: 4 }' e: {5 E$ w8 z; E8 N9 @
<%@ Language=VBScript %> ) v0 c$ p% W4 S1 Z2 S7 e; c
<% : d- j% p; u9 p0 R
if Request.Form("txt" & request.querystring("flag"))<>"" then
% Q/ _' L  }# ~: q'response.write "in!" & ""
# u7 C7 R  d/ F1 D6 h. y, usession("nice")=Request.Form("txt" & request.querystring("flag"))
3 H$ ~* ~( [% B/ U+ w3 E) e  b'response.write session("nice") & ""
: e  M  b! O1 s" ?0 T$ S'response.write application(request.querystring("flag"))
4 `" d& J8 O3 I) ^2 T& ]if application(request.querystring("flag"))="" then
* E: c4 b! s) k2 eapplication(request.querystring("flag"))=session("nice")
+ ]- R! M9 H* t! usession("class")=right(request.querystring("flag"),1) 8 H- U! \2 X3 F% }, i
if left(request.querystring("flag"),1)="f" then 6 y6 `  \  U9 d/ Y8 [  [/ z
application(session("nice"))=false * p9 z7 [& {" X; {3 u
elseif left(request.querystring("flag"),1)="s" then 2 p0 W& N  N3 }7 w- M
application(session("nice"))=false
3 \2 t; L1 |% G" k/ F; W1 }9 kapplication(application("first" & session("class")))=true
! H, y& _5 m! z- |end if 9 R/ y8 V% B4 P$ ]- W' N
Response.Redirect "match.asp" ; p& s9 h' Q$ m$ n
end if
7 m$ i( d! d3 b" g# I+ Z$ z: ~% {  . J5 O2 k# g+ A% @8 {+ O5 U- B
  9 i5 U9 C- N! s% x: u& H  P
end if " J& `8 D5 e, k4 `
 
( v. ~; s& k; b* |- A1 `- g& c% {%> 6 k3 m+ g  h  L1 U% J" n' W
<HTML> 1 `% o6 N5 H6 y/ _6 g9 L# J
</HTML> 7 t  d( k5 u% {3 P5 V. G
该程序中,用session(“nice”)来记录您登录的大名,以后的处理中,很多都要用到它,用它来区分很多的用户。如果您是从擂主的位置进入,则您的权利是 7 y; W% I/ n; y& {. [( J
first,否则是second,用session("class")来记录位于哪个战场场,“金”“木”
; |/ ]' n+ H& D# J3 L+ ]“水”“火”“土”分别表示为1、2、3、4、5,因为有多个战场可能同时开战,如果不能正确地区分开,则可能导致一片混乱。application(session("nice"))是一个逻辑型变量,用真假来表示您是否可以出棋,如果是假,您要等待一个,如果是真,您就可以下棋了。只有一个战场上的两个人都进入了以后,擂主方可以下棋,而且只有当擂主出子以后,攻擂手才可以下棋。准备好以后,下面就进入赛场,请看文件match.asp
" ]) `; G( @, M. b2 _
7 x/ z1 U# e2 `( b<html>
& q3 Y0 i9 B( }! h<head>
  v! f' {4 Z* ~/ Q$ ?1 t7 I3 \<meta http-equiv="Content-Type" c>
( [: o" m$ {2 I* V7 |<meta name="GENERATOR" c>
: x8 R7 R1 n7 p+ P9 N<meta name="ProgId" c>
! C" ~' y. |' o& X, m# f+ M; }& K/ K<META http-equiv=refresh content=3> $ p3 |8 |, p8 b' u
<title>连珠大赛...</title>
/ `; N( g# `! S. [8 T) B</head>
0 Y3 Y: x, k$ e4 T  M5 I$ t<% ' \0 \) A# |1 w8 Y
Response.Write "擂主:" & application("first" & session("class"))
9 b" h0 E3 }' D& "    攻擂:" & application("second" & session " t. X4 E# g8 }& S/ O
("class"))
" M1 E  T, B- Hif Request.QueryString("pos")<>"" then
( |8 Q, t0 I* \" [application("pos" & session("class") & Request.QueryString("pos"))
8 U( ?3 Z; V$ W9 h; L=true % t1 @! d) j- p( U4 b1 J5 e+ K( o
end if * e. e: T5 F) j' Q( L4 J
%>
3 s- a4 q( G7 z: u  g<body>
5 E6 o5 [! @- w/ i<% - B, R0 H# v* M; J! v# H) S
'Response.Write application("aaa") . U4 \7 Z. _: ~1 x+ z9 f
if application("first" & session("class"))=session("nice") then 0 B# a  j' K8 Z5 }& ?
color="black" : G1 ]2 l" ?# O2 p$ E4 c
if Request.QueryString("pos")<>"" then
3 E9 A1 a' u7 k8 A8 _! ~if session("last")="" then session("last")="abc"
4 g5 \5 `! T) g/ H/ z. N  oif session("last")<> Request.QueryString("pos") then 5 t: K8 Y3 o9 P- c) x
application(application("first" & session("class")))=false 5 c6 O8 e, @6 ]  q( N! q
if application("second" & session("class"))<>"" then application - X0 y6 K& L& r8 P: \0 ]2 u/ z$ Q
(application("second" & session("class")))=true
4 @( b" r6 ]% G. m& Lsession("last")=Request.QueryString("pos") + [0 k' S+ J5 a
END IF
; [/ u1 J- ~8 u3 f! O* t$ jend if
: R. z" Y# P" w' g: {else / U" m) ?7 v  y: I1 l) o  S4 F$ ~6 @
if application("second" & session("class"))=session("nice") then
- w* e+ l+ |' p+ T& `color="white" 1 s& s! S0 Y+ D  C9 f
if Request.QueryString("pos")<>"" then
$ b$ L% F* ~; `'if session("last")="" then session("last")="abc" : H* M! |6 u( }$ w6 s5 ?, D
if session("last")<> Request.QueryString("pos") then 2 z, X  E0 v: i) h1 ]8 T1 s
application(application("first" & session("class")))=true - D& ?* a7 _% A! y
application(application("second" & session("class")))=false
* I- |9 s! [: c3 T" P% vsession("last")=Request.QueryString("pos") ( i7 O$ g: x# {$ t; a
END IF 5 O. f: _( |( U: z* O- l
end if , _' x3 Z5 R) m& w( y, Z9 t* p8 a
else
/ R4 I9 N* |6 s/ W% `0 k1 n: I: n4 Aif application("second" & session("class"))="" then 3 M3 g/ \& C( j3 D! }
application("second" & session("class"))=session("nice")
/ V8 Y3 V/ }( c/ W- Y/ ~1 r7 b7 y4 Pcolor="white"
1 S+ n) }& D) f1 r3 a+ j' w- ^$ Hif Request.QueryString("pos")<>"" then 0 ~) \& ]$ Y) ^
if session("last")="" then session("last")="abc" " _, P+ ?) ~- `# n* d% }
if session("last")<> Request.QueryString("pos") then % A/ G) A2 z) \: u3 J
application(application("first" & session("class")))=true 1 P& W! d, b% h1 b  X
application(application("second" & session("class")))=false ' T& z: T. c+ F/ |; y0 Q7 p- q
session("last")=Request.QueryString("pos")
* Z# {4 \! w& LEND IF . j; j9 k+ ]+ n# F! t5 g+ S$ N/ E
end if , i* c1 Z- ]% J3 L0 F
else % V9 ^" N9 X/ ?& j1 O
color=""
% d; G( M' r. W% M& bend if
. W% K" `" T2 a/ s0 q! a5 U" c" g  D  cend if * h* w/ U  d! S+ k2 }" x8 h
end if   E% v% `- v. q, }( L; h
Response.Write "<table width=400 height=400 border=0 cellspacing=0
. g$ n. S! [9 O% T6 x/ [cellpadding=0>"
$ @8 a% V1 [' G9 B+ H9 Z1 pfor i=1 to 16
$ n' y9 o) E" E: R5 YResponse.Write "<tr>" 3 a$ R: H7 K7 C; `
for j=1 to 16
; s; r2 x$ p. r+ Q) Q  s- P1 sif application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""
* C8 f* a5 ~8 P. b' s7 h6 Q. ithen
- d# s0 {9 E+ c  P  u4 Happlication("color" & session("class") & "_" & Request.QueryString
, H& o  P& w  L8 d("pos"))=color
/ ?$ `1 ?( Y9 T% `Response.Write "<td width=25 height=25>" # k2 g% x/ L0 F4 F/ J
'response.write application(application("first" & session("class")))
) l! @# k0 v: j# W/ [8 hif application(session("nice"))=true then
: O+ I& C5 X+ a$ C7 L6 q- v  }, Mresponse.write "<a href=match.asp?pos=" & cstr(i) & "_" & cstr(j) 1 G5 u9 i1 a0 S3 [5 Z
& "><img border=0 src=back0.jpg width=25 height=25></a>" % f; m9 Q, ~% C* L. o" V" {
else 1 r1 p$ M5 W6 N; g/ w; `
response.write "<img border=0 src=back0.jpg width=25 height=25>" % t# a0 y) T( z' ^/ R+ R) t, I
end if
. w$ S8 C/ s7 O, Eresponse.write "</td>"
: M6 V' Z+ i5 z8 J5 Q1 k4 m6 Nelse ; W& ]+ f# f; r2 F. ^3 q6 U( C! g, ^
Response.Write "<td width=25 height=25><img border=0 src=" & - G5 \/ }7 x% O7 g, I) |
application("color" & session("class") & "_" & cstr(i) & "_" & cstr
- W) Z8 ]$ |1 g7 F' C8 m(j)) & "0.jpg width=25 height=25></td>" & chr(13) 4 \+ c8 o  \2 x6 X6 J5 s9 s6 D
end if + q, m( I% [' w& h+ ~
next / p3 R; h) \% E& D/ O
Response.Write "</tr>"
. `0 A( S4 k& E( b0 D" K; |next - K8 D1 S( n- I& S. ^4 z
Response.Write "</table>" 3 l# U# b* V2 j2 {) U' c2 \0 w
'判断输赢
( }9 u9 j! H+ ~7 Yif application("first" & session("class"))=session("nice") then " t' y0 g; P$ i) d6 J. m
m="black" ) M8 b& ~/ v! _5 w* s- Y
h="white"
+ R/ A$ \% ~" @, t" Relse ' m3 a' j$ I3 A
h="black"
0 F  @7 c- G7 h4 r- D: Em="white"
" r/ H. \, M) e% t( c% c! xend if
- v2 J  g  X3 `- K) b'横向判断"-"
5 A" e. Z8 G. W- Ofor i=1 to 15
# Q% I6 t4 b4 Q4 ^) N: Wwin=false
2 A1 M% j' u! c# E: H1 ?loss=false
- M# V3 Z) G' u( Pfive_me=0   ~) C; \; [( W+ C* W# S4 c, n. T% v
five_he=0 % Y! N9 b  V1 D* R" s/ x! v: W
for j=1 to 15 - @% ~) w  ?. m/ |
if application("color" & session("class") & "_" & cstr(i) & "_" & cstr 2 P6 j) @! A+ q* d$ B4 Y. U- w& o
(j))=m then 0 i2 ^/ T3 Y' n  N/ Y  g! d$ g) \- C
five_me=five_me+1 ) y8 Y9 l8 X) T) u
five_he=0 9 ^- u1 b+ C: k/ ~' C: O
elseif application("color" & session("class") & "_" & cstr(i) & "_" &
4 f" m! y* Z' l4 S5 N' Hcstr(j))=h then 8 y$ i- p! N9 @8 r+ J
five_me=0 1 G2 R6 B! J1 q2 o/ l- n  a
five_he=five_he+1
5 ~0 J, r7 J6 E- x- i$ K/ yelse
( S7 r3 N3 R4 nfive_me=0
3 R. f) ?  h( r2 n4 b# Dfive_he=0
" z. |( S2 _2 o: e7 [0 Send if
* N( T- G9 S' R( fif five_me=5 then
0 K3 _5 u& [8 p) b; z. R1 ^win=true * S. m, O; W4 a+ s" o- u
loss=false
* V8 f; d& a: n: {6 f6 l- k* S, Vexit for 4 v9 f  ~& e' n# s5 \
elseif five_he=5 then   M& k8 N5 _' b2 B8 c
win=false
, S  z8 v- T0 r3 ^) `$ \loss=true
' p; X1 S; ?7 g. j* Rexit for - \8 X( K2 J& B5 Z: T) S9 j' w1 K
end if
8 q( Y, z$ D& b5 ?( ~" B$ H2 X5 m7 Bnext
- P8 s$ A" W- Dif win or loss then exit for : z  k7 U6 a5 o; m; Q8 R
next 5 a1 V% ^6 Y4 X6 `$ u4 y
if win then " ]- w- k" O9 D8 ?- r2 f" F* Y
response.write "你赢了!" ; S" I8 U  N" R3 u: O/ ]! `
application(application("first" & session("class")))=false
( D( C- x7 ]& p8 w' ^application(application("second" & session("class")))=false 7 U# S8 w" F6 L. Y4 h
end if
) g# G4 i, x( V+ D1 M2 @if loss then 4 l9 \/ u% T2 m* {0 M: u: X
response.write "对不起,你输了!"
1 Y5 U$ K7 g4 N3 Capplication(application("first" & session("class")))=false 1 L* V5 Q$ s4 H5 y/ J3 ?
application(application("second" & session("class")))=false
9 Q  P% b! r7 t, `  q! U! Gend if
# s- ?: N( O( z4 p- K$ R& c  9 v2 B; R" u; A5 Z. H* H
'列向判断"|"
* F& B$ J. j. M1 L- qfor j=1 to 15
6 N6 c) a! S0 Bwin=false & _  U8 F9 g; O& u
loss=false # J, Z/ K6 \2 Z
five_me=0   U( q; s3 ]7 R) o- {( e; [
five_he=0 " Q$ K5 h! ?; S; Z
for i=1 to 15
% _0 H1 l- W$ B+ }- @- @* Nif application("color" & session("class") & "_" & cstr(i) & "_" & cstr 1 ~# s# J$ h& c% U: O/ N
(j))=m then - ^' Q0 G/ k0 b) C8 M6 }
five_me=five_me+1 ; K% ~: s9 g8 o4 _4 S* ?, @- j. B
five_he=0
/ ?" ^! s+ ]" _% T1 Kelseif application("color" & session("class") & "_" & cstr(i) & "_" & 1 @1 v7 u$ E6 l6 a7 p) m6 p# [
cstr(j))=h then ! _9 f! ]8 r8 W" F! Y
five_me=0
4 c( i7 d. q& F2 o* g1 efive_he=five_he+1
/ c  C, B- r7 D$ f) p% eelse
0 ?- Y( v7 `! G+ n; d6 ofive_me=0
7 ~0 f- W* v" l3 @  l# m/ C+ Ifive_he=0
# k5 E+ z+ z, ^2 dend if
2 s* q( z3 O1 W$ q+ jif five_me=5 then   f3 N: J+ n0 f" S6 b
win=true
# N+ [5 _' }4 j, Q0 E+ floss=false
+ [- a9 _$ ~5 v5 H. C; H% Fexit for . ?3 d+ H( p- m, b  b) L3 D
elseif five_he=5 then ) @2 m1 k5 l  z5 t) M6 s. ]
win=false
; d' f( ?6 Y) `  ]+ t3 Tloss=true & g5 ]: M4 e/ r8 N. c; y' j
exit for
+ V# O; @9 `& O( z2 p& \end if : |5 _1 x8 I& n
next
1 v) s5 g/ ~5 qif win or loss then exit for , \7 Y3 e" i  j" R% g
next
6 O; Q7 Q4 n! ?if win then
/ y3 S% o. O: y* V- O; w8 ]response.write "你赢了!" 8 T7 Q* A+ t/ B0 K8 E8 d
application(application("first" & session("class")))=false " e5 _' i8 a; T" A0 z$ f/ R# ^
application(application("second" & session("class")))=false 0 v+ v; [* J  O* z- d# y5 W
end if + C9 z/ n/ R8 I
if loss then
* T- a# a* ?( P* w: T. Sresponse.write "对不起,你输了!" 5 T( [7 L$ r+ s7 m
application(application("first" & session("class")))=false   y3 o8 T2 V: j- }' A
application(application("second" & session("class")))=false 5 u( g3 J9 }. Z1 I8 y! N! j! d
end if 9 t7 ]+ F& q  m, @4 R0 n
 
5 v% _5 q: y5 v6 j' R0 E'斜向判断"/"
  S! S7 @7 _+ X  Z- C. `0 {7 pfor i=1 to 11
" K. K4 N! u9 @) @- Wwin=false 8 B  W5 x9 t- e$ K& F9 k( `1 {0 D* z
loss=false
6 ^, Y$ A6 y  x: R) K( w2 m0 C/ j/ `five_me=0 4 P' {+ Y+ H# _; c' ^6 O* R0 V% X/ w
five_he=0 " I' {9 {7 e1 U9 m5 V3 c
for j=i+4 to 1 step -1
+ _1 c) A/ _! v9 fif application("color" & session("class") & "_" & cstr(j) & "_" & cstr 2 P  n/ x3 B, O3 x2 m0 R* C9 u  F8 o
(i+5-j))=m then 3 O+ o! b- S0 t. m- k
five_me=five_me+1 * h& w& k5 h2 Q8 J0 X+ V6 i
five_he=0 $ x& ~7 u6 j, [5 H' c
elseif application("color" & session("class") & "_" & cstr(j) & "_" &
) F; `7 m+ r4 ~( c3 @( q2 e% Ecstr(i+5-j))=h then 6 l  ?/ A% }& B) }9 X7 L
five_me=0 , ]3 k0 O/ P) P! I6 @2 i4 h
five_he=five_he+1
6 R# B/ J% o$ I! R5 felse
0 K, V# W; u+ j) Y2 C' h+ B: F3 Dfive_me=0
, Y: r3 R9 ]0 G2 `( F; U/ _/ Rfive_he=0
. y' {" c0 O. {5 K9 C+ {end if
. N  f' j7 d$ b2 [! x; g: ~if five_me=5 then 0 R$ |' b( l9 H% U0 Q
win=true 1 j5 ]+ |* L6 N; ~3 T/ c
loss=false
9 b7 I) z/ H7 I* z0 T5 m& O9 Zexit for " ~) H' N6 {# S; ]0 i
elseif five_he=5 then & g3 {8 W3 g: @+ W+ I' o2 ]: J
win=false 1 T8 G4 q8 k; F4 o+ J
loss=true 8 z9 A4 A* I5 M! I- C0 j0 r
exit for   K. d! L4 u+ i/ H
end if
& A* ?7 `9 `2 |0 A; Fnext ( }' F$ K7 y9 q3 A
if win or loss then exit for
5 A; M' w; V& J$ Knext
1 J# X% _1 t; c1 g; p& n4 b( o+ vif win then $ T& N3 G1 y- i2 u2 u
response.write "你赢了!" - p: l) |% s; C7 \
application(application("first" & session("class")))=false
3 o$ r: m, r: g0 R3 japplication(application("second" & session("class")))=false
3 I5 M/ E9 A! e8 [end if
/ t$ I& r  C) R7 l3 r! M$ Zif loss then
+ x$ R! c% {9 C. l& zresponse.write "对不起,你输了!"
/ X: x3 f; k! A) s- kapplication(application("first" & session("class")))=false ' u: d5 h6 U% w. `7 O3 U
application(application("second" & session("class")))=false ) ~" t' W5 ?) P9 }
end if 0 G2 i% F7 Z) Y
  6 a3 G1 @7 \1 d: h; I) ^/ v2 N
'斜向判断"\" 4 j; i. w) v% y; `& @" ?2 F$ E
for i=1 to 11 : g! t+ y$ }* S% M1 N; G+ w4 E
win=false 1 C4 L6 j5 m" V1 w+ Q/ ?2 b9 {6 G! q
loss=false
) E7 {" J$ H6 \- k- R4 Q" ]$ Tfive_me=0 3 `* v$ `+ ~' T4 j9 E& O
five_he=0
) _) c/ V# X1 P2 h& T* v3 Efor j=12-i to 15 ( w& K3 T( k6 K; x
if application("color" & session("class") & "_" & cstr(13-i-j) & "_" 4 F/ s& ^2 y- Y
& cstr(j))=m then + o% s3 o2 Q1 }( n5 \- `! U; ]/ {+ H
five_me=five_me+1
$ W9 U" Y0 k6 i& d9 c& nfive_he=0
' @, C5 T5 q2 W8 w2 }+ qelseif application("color" & session("class") & "_" & cstr(13-i-j)
" r, H; p. G% i$ l+ G7 p& "_" & cstr(j))=h then 6 t3 W( w" E% m0 z: i& [& p+ y" d
five_me=0 6 b( I4 h6 E  Q8 i
five_he=five_he+1
% G& n/ t6 I7 D4 I$ p+ }# V/ eelse & G4 I* @8 k! M' D, K7 k
five_me=0   y! [; b( \& T4 p, S: f
five_he=0 : p- B  j5 j# k2 h% t, G6 c9 e
end if
* |0 ]* X; o& h5 cif five_me=5 then $ I4 l0 b2 t; I/ I# }. D) k
win=true
6 b; X& }1 a# }! N) ]+ xloss=false
, B* F8 B8 u4 t. c; i1 hexit for
+ n* B2 a3 ~0 b2 \elseif five_he=5 then 7 e) d# a" O/ U! X5 u( {* k
win=false ( j5 g5 F2 n: }
loss=true % w  t  ~1 N; t& z5 [
exit for
+ t8 p  w% f! g' N# f/ Oend if % n6 V: ]; X( G+ w, u& H- I
next 7 B$ h7 c1 z, s" F4 C
if win or loss then exit for
& V3 L0 ?$ ]  N# I: _- x6 Mnext
' H/ s* J4 d/ G! _, U( v5 B" dif win then
  ^7 W: b# r) ~2 n! r% o6 eresponse.write "你赢了!"
9 P; }1 G5 O3 L+ p5 vapplication(application("first" & session("class")))=false
4 W9 }  ~; [  N- F- `1 Aapplication(application("second" & session("class")))=false
  |0 S, H% v% F6 F+ g* B2 Fend if
' c0 s4 I; }8 ~% Nif loss then
4 x" w" b: P9 P6 k  Eresponse.write "对不起,你输了!"
  o6 q/ D( P/ Happlication(application("first" & session("class")))=false
, U& q; J% W: Zapplication(application("second" & session("class")))=false
5 W  f/ S- h3 P" {end if 6 J- {' e+ |  N/ r5 t! U4 S' G" W
%> ; f/ F8 j  [1 s8 x& [9 j* t# T
</body>
& d( \! r' G  }; v8 [</html>
2 n6 b9 i+ ]" [2 B如果某点没有棋子,则加上一个超连接,根据擂主与攻擂手的区别放上一个不同颜色的棋子。最后的一段是用来判断输与赢,分为横,列和两个斜线方向。具体内容看一下就可以明白。 ( R# F0 Z4 V+ D1 w6 a6 L  z
最后要说的一点就是global.asa ,这是站点上的一个核心文件,为了在退出棋局后,将位置留给别人,需要在sesison_onend中加入代码进行处理,如下:

4 I& w1 J( t+ L- n: Q% g0 ~<script language=vbscript runat = server> ! u/ ]' J+ r) [8 k9 {$ W0 j
sub application_onstart
( f2 p2 t0 v9 t! O& i( P1 l/ r" q2 Wsession.timeout=1
3 D; C. P* ~& U2 h) c( c$ Dend sub 3 n  _: _9 H+ I  ~8 r" P
sub session_onstart
' A: X: V2 N$ c; _$ `3 q; k# fif application("num")="" then
+ I0 @# x3 V" G' @( r+ \( Napplication("num")=0 7 i: [6 f- V  M' Z( a
end if
( {  C. [4 N) [# Aapplication("num")=application("num")+1
" v! K$ _) r7 J& mend sub 8 ?. v9 b$ I' j* O( T( M, t
</script> & t% c9 T% I" d1 K- p
 
9 R' a( a; b, L" h, \0 _: {3 E<script language=vbscript runat = server>
! }0 H8 D1 Y% @5 fsub session_onend
0 ?/ S- H) _8 A  }0 U2 b7 jif application("num")="" then " ^; f  {; ^: d: e4 @( G
application("num")=0
' J) \, i$ \9 R/ ~3 `' j5 Eend if ) _, I2 d9 z' j. N, N" @
application("num")=application("num")-1
. C9 v- x9 I; J! D  ' |2 f$ E9 B1 z; N& V, A
if application("first1")=session("nice") then 0 R, x6 I2 n! N' V
application("first1")=""
; Y" k# F3 \( Y, S) ^  t; l' i5 velseif application("second1")=session("nice") then
5 `+ x/ v+ S9 n4 d! f/ ]application("second1")=""
; R" h( j) j' c- X2 e 
, L* `9 o# F8 k6 m5 h" Q+ G# Celseif application("first2")=session("nice") then
. q( r3 e8 E# f5 Aapplication("first2")=""
. H/ {! a5 Y4 R: j5 jelseif application("second2")=session("nice") then
( `. Y! y; `' F4 n  ^4 mapplication("second2")="" 8 \8 d( ^0 W( k) k
 
+ ~) D0 @) G3 N, F& Z6 Belseif application("first3")=session("nice") then
, ?. m$ t( p' A/ K( v8 [0 g8 gapplication("first3")=""
8 X! n7 F  \/ g' `+ g, jelseif application("second3")=session("nice") then . e% c! {! p8 P  H% d
application("second3")=""
5 I$ t9 z1 u3 u  - |) K% |( i  X$ k9 \
elseif application("first4")=session("nice") then
7 I/ M) z7 c3 O$ o3 b) y6 K% k; n3 l( ~application("first4")="" ) D- x7 v4 n6 g; F$ h/ o* U7 }8 Y; C
elseif application("second4")=session("nice") then
9 _5 X: G& n" [3 z9 i6 zapplication("second4")="" % q1 D6 M- Z. X3 @( L) _, o* G9 u
 
$ e+ |4 `# h' c( ]9 A* Relseif application("first5")=session("nice") then   M  W1 s: ]0 [
application("first5")=""
% `8 m" @! O/ @$ |- Uelseif application("second5")=session("nice") then 6 R7 e; q: B9 N6 p+ ]! r1 u
application("second5")="" , g! l, u/ Q6 x/ ?# u8 R5 A& f
end if " m* R# |3 e; T! J. \
for i=1 to 15 " q8 p& D# L8 s% _% k
for j=1 to 15 3 E, K8 _$ k( w7 X# K2 d
application("color" & session("class") & "_" & cstr(i) & "_" & cstr
$ g( E) f( C, f3 X$ _(J))=""
/ Z$ g) g6 o6 O9 b6 J1 n/ A( b: iapplication("pos" & session("class") & cstr(i) & "_" & cstr(j))=""
+ I4 Z4 l+ T+ k# L8 u! i- I* B2 s4 mnext
$ U6 Q5 v. N3 y& Z' A5 Tnext
6 H& r7 u8 y6 X% ^& dapplication(session("nice"))=""
6 A* C, k  K: E) F, l5 ~( ^( S( Tend sub
7 f1 ~+ H) ?$ P  V! h! Z</script>
' V( I  N! c: l, n! W( g& q- B$ w8 a以上就是几个主要的文件,大家可以一试。什么,想做围棋?把棋盘改一下就可以了。 0 m; _. A. s/ _3 U% ?7 r
祝大家成功!

TOP

发新话题