⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 用asp网上“五子棋"大.htm

📁 较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
💻 HTM
📖 第 1 页 / 共 3 页
字号:
            <BR><BR>&lt;td&gt; <BR><BR>&lt;% <BR><BR>if application("first4")="" 
            then <BR><BR>%&gt; <BR><BR>&lt;form action=index0.asp?flag=First4 
            method=post&gt; <BR><BR>&lt;INPUT id=text1 name=txtFirst4 
            size=10&gt;&lt;INPUT id=submit1 name=submit1 <BR>type=submit 
            value=进入&gt; <BR><BR>&lt;/form&gt; <BR><BR>&lt;% <BR><BR>else 
            <BR><BR>response.write application("first4") <BR><BR>end if 
            <BR><BR>%&gt; <BR><BR>&lt;/td&gt; <BR><BR>&lt;td&gt;大战&lt;/td&gt; 
            <BR><BR>&lt;td&gt; <BR><BR>&lt;% <BR><BR>if 
            application("second4")="" then <BR><BR>%&gt; <BR><BR>  
            <BR><BR>&lt;form action=index0.asp?flag=second4 method=post&gt; 
            <BR><BR>&lt;INPUT id=text1 name=txtSecond4 size=10&gt;&lt;INPUT 
            id=submit1 <BR>name=submit1 type=submit value=进入&gt; 
            <BR><BR>&lt;/form&gt; <BR><BR>&lt;% <BR><BR>else 
            <BR><BR>response.write application("Second4") <BR><BR>end if 
            <BR><BR>%&gt; <BR><BR>&lt;/td&gt; <BR><BR>&lt;/tr&gt; <BR><BR>  
            <BR><BR>&lt;tr&gt; <BR><BR>&lt;td&gt;金星&lt;/td&gt; 
            <BR><BR>&lt;td&gt; <BR><BR>&lt;% <BR><BR>if application("first5")="" 
            then <BR><BR>%&gt; <BR><BR>&lt;form action=index0.asp?flag=First5 
            method=post&gt; <BR><BR>&lt;INPUT id=text1 name=txtFirst5 
            size=10&gt;&lt;INPUT id=submit1 name=submit1 <BR>type=submit 
            value=进入&gt; <BR><BR>&lt;/form&gt; <BR><BR>&lt;% <BR><BR>else 
            <BR><BR>response.write application("first5") <BR><BR>end if 
            <BR><BR>%&gt; <BR><BR>&lt;/td&gt; <BR><BR>&lt;td&gt;大战&lt;/td&gt; 
            <BR><BR>&lt;td&gt; <BR><BR>&lt;% <BR><BR>if 
            application("second5")="" then <BR><BR>%&gt; <BR><BR>  
            <BR><BR>&lt;form action=index0.asp?flag=second5 method=post&gt; 
            <BR><BR>&lt;INPUT id=text1 name=txtSecond5 size=10&gt;&lt;INPUT 
            id=submit1 <BR>name=submit1 type=submit value=进入&gt; 
            <BR><BR>&lt;/form&gt; <BR><BR>&lt;% <BR><BR>else 
            <BR><BR>response.write application("Second5") <BR><BR>end if 
            <BR><BR>%&gt; <BR><BR>&lt;/td&gt; <BR><BR>&lt;/tr&gt; <BR><BR>  
            <BR><BR>&lt;/table&gt; <BR><BR>  <BR><BR>  <BR><BR>&lt;/BODY&gt; 
            <BR><BR>&lt;/HTML&gt; 
            <BR><BR>&nbsp;这个文件不用做过多的说明,就是一个大的表格,大家可以从那里进入,如果某个位置已经被使用,则它会变成该大 
            侠的名字,不允许重复登录。在登录后进入 
            <BR>index0.asp,这是一个中间交换文件,在里面进行一些变量的处理及赋值,然后再进入match.asp,进行正式的比赛。我们来看一下index0.asp的内容: 
            <BR><BR>&lt;%@ Language=VBScript %&gt; <BR><BR>&lt;% <BR><BR>if 
            Request.Form("txt" &amp; request.querystring("flag"))&lt;&gt;"" then 
            <BR><BR>'response.write "in!" &amp; "&lt;Br&gt;" 
            <BR><BR>session("nice")=Request.Form("txt" &amp; 
            request.querystring("flag")) <BR><BR>'response.write session("nice") 
            &amp; "&lt;Br&gt;" <BR><BR>'response.write 
            application(request.querystring("flag")) <BR><BR>if 
            application(request.querystring("flag"))="" then 
            <BR><BR>application(request.querystring("flag"))=session("nice") 
            <BR><BR>session("class")=right(request.querystring("flag"),1) 
            <BR><BR>if left(request.querystring("flag"),1)="f" then 
            <BR><BR>application(session("nice"))=false <BR><BR>elseif 
            left(request.querystring("flag"),1)="s" then 
            <BR><BR>application(session("nice"))=false 
            <BR><BR>application(application("first" &amp; 
            session("class")))=true <BR><BR>end if <BR><BR>Response.Redirect 
            "match.asp" <BR><BR>end if <BR><BR>  <BR><BR>  <BR><BR>end if 
            <BR><BR>  <BR><BR>%&gt; <BR><BR>&lt;HTML&gt; <BR><BR>&lt;/HTML&gt; 
            <BR><BR>&nbsp; 
            &nbsp;该程序中,用session(“nice”)来记录您登录的大名,以后的处理中,很多都要用到它,用它来区分很多的用户。如果您是从擂主的位置进入,则您的权利是 
            <BR>first,否则是second,用session("class")来记录位于哪个战场场,“金”“木” 
            <BR>“水”“火”“土”分别表示为1、2、3、4、5,因为有多个战场可能同时开战,如果不能正确地区分开,则可能导致一片混乱。application(session("nice"))是一个逻辑型变量,用真假来表示您是否可以出棋,如果是假,您要等待一个,如果是真,您就可以下棋了。只有一个战场上的两个人都进入了以后,擂主方可以下棋,而且只有当擂主出子以后,攻擂手才可以下棋。准备好以后,下面就进入赛场,请看文件match.asp 
            <BR><BR>&lt;html&gt; <BR><BR>&lt;head&gt; <BR><BR>&lt;meta 
            http-equiv="Content-Type" content="text/html; charset=gb2312"&gt; 
            <BR><BR>&lt;meta name="GENERATOR" content="Microsoft FrontPage 
            4.0"&gt; <BR><BR>&lt;meta name="ProgId" 
            content="FrontPage.Editor.Document"&gt; <BR><BR>&lt;META 
            http-equiv=refresh content=3&gt; 
            <BR><BR>&lt;title&gt;连珠大赛...&lt;/title&gt; <BR><BR>&lt;/head&gt; 
            <BR><BR>&lt;% <BR><BR>Response.Write "擂主:" &amp; application("first" 
            &amp; session("class")) <BR>&amp; " &nbsp; &nbsp;攻擂:" &amp; 
            application("second" &amp; session <BR>("class")) <BR><BR>if 
            Request.QueryString("pos")&lt;&gt;"" then <BR><BR>application("pos" 
            &amp; session("class") &amp; Request.QueryString("pos")) <BR>=true 
            <BR><BR>end if <BR><BR>%&gt; <BR><BR>&lt;body&gt; <BR><BR>&lt;% 
            <BR><BR>'Response.Write application("aaa") <BR><BR>if 
            application("first" &amp; session("class"))=session("nice") then 
            <BR><BR>color="black" <BR><BR>if 
            Request.QueryString("pos")&lt;&gt;"" then <BR><BR>if 
            session("last")="" then session("last")="abc" <BR><BR>if 
            session("last")&lt;&gt; Request.QueryString("pos") then 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>if application("second" &amp; 
            session("class"))&lt;&gt;"" then application 
            <BR>(application("second" &amp; session("class")))=true 
            <BR><BR>session("last")=Request.QueryString("pos") <BR><BR>END IF 
            <BR><BR>end if <BR><BR>else <BR><BR>if application("second" &amp; 
            session("class"))=session("nice") then <BR><BR>color="white" 
            <BR><BR>if Request.QueryString("pos")&lt;&gt;"" then <BR><BR>'if 
            session("last")="" then session("last")="abc" <BR><BR>if 
            session("last")&lt;&gt; Request.QueryString("pos") then 
            <BR><BR>application(application("first" &amp; 
            session("class")))=true <BR><BR>application(application("second" 
            &amp; session("class")))=false 
            <BR><BR>session("last")=Request.QueryString("pos") <BR><BR>END IF 
            <BR><BR>end if <BR><BR>else <BR><BR>if application("second" &amp; 
            session("class"))="" then <BR><BR>application("second" &amp; 
            session("class"))=session("nice") <BR><BR>color="white" <BR><BR>if 
            Request.QueryString("pos")&lt;&gt;"" then <BR><BR>if 
            session("last")="" then session("last")="abc" <BR><BR>if 
            session("last")&lt;&gt; Request.QueryString("pos") then 
            <BR><BR>application(application("first" &amp; 
            session("class")))=true <BR><BR>application(application("second" 
            &amp; session("class")))=false 
            <BR><BR>session("last")=Request.QueryString("pos") <BR><BR>END IF 
            <BR><BR>end if <BR><BR>else <BR><BR>color="" <BR><BR>end if 
            <BR><BR>end if <BR><BR>end if <BR><BR>Response.Write "&lt;table 
            width=400 height=400 border=0 cellspacing=0 <BR>cellpadding=0&gt;" 
            <BR><BR>for i=1 to 16 <BR><BR>Response.Write "&lt;tr&gt;" 
            <BR><BR>for j=1 to 16 <BR><BR>if application("pos" &amp; 
            session("class") &amp; cstr(i) &amp; "_" &amp; cstr(j))="" <BR>then 
            <BR><BR>application("color" &amp; session("class") &amp; "_" &amp; 
            Request.QueryString <BR>("pos"))=color <BR><BR>Response.Write 
            "&lt;td width=25 height=25&gt;" <BR><BR>'response.write 
            application(application("first" &amp; session("class"))) <BR><BR>if 
            application(session("nice"))=true then <BR><BR>response.write "&lt;a 
            href=match.asp?pos=" &amp; cstr(i) &amp; "_" &amp; cstr(j) <BR>&amp; 
            "&gt;&lt;img border=0 src=back0.jpg width=25 
            height=25&gt;&lt;/a&gt;" <BR><BR>else <BR><BR>response.write 
            "&lt;img border=0 src=back0.jpg width=25 height=25&gt;" <BR><BR>end 
            if <BR><BR>response.write "&lt;/td&gt;" <BR><BR>else 
            <BR><BR>Response.Write "&lt;td width=25 height=25&gt;&lt;img 
            border=0 src=" &amp; <BR>application("color" &amp; session("class") 
            &amp; "_" &amp; cstr(i) &amp; "_" &amp; cstr <BR>(j)) &amp; "0.jpg 
            width=25 height=25&gt;&lt;/td&gt;" &amp; chr(13) <BR><BR>end if 
            <BR><BR>next <BR><BR>Response.Write "&lt;/tr&gt;" <BR><BR>next 
            <BR><BR>Response.Write "&lt;/table&gt;" <BR><BR>'判断输赢 <BR><BR>if 
            application("first" &amp; session("class"))=session("nice") then 
            <BR><BR>m="black" <BR><BR>h="white" <BR><BR>else <BR><BR>h="black" 
            <BR><BR>m="white" <BR><BR>end if <BR><BR>'横向判断"-" <BR><BR>for i=1 to 
            15 <BR><BR>win=false <BR><BR>loss=false <BR><BR>five_me=0 
            <BR><BR>five_he=0 <BR><BR>for j=1 to 15 <BR><BR>if 
            application("color" &amp; session("class") &amp; "_" &amp; cstr(i) 
            &amp; "_" &amp; cstr <BR>(j))=m then <BR><BR>five_me=five_me+1 
            <BR><BR>five_he=0 <BR><BR>elseif application("color" &amp; 
            session("class") &amp; "_" &amp; cstr(i) &amp; "_" &amp; 
            <BR>cstr(j))=h then <BR><BR>five_me=0 <BR><BR>five_he=five_he+1 
            <BR><BR>else <BR><BR>five_me=0 <BR><BR>five_he=0 <BR><BR>end if 
            <BR><BR>if five_me=5 then <BR><BR>win=true <BR><BR>loss=false 
            <BR><BR>exit for <BR><BR>elseif five_he=5 then <BR><BR>win=false 
            <BR><BR>loss=true <BR><BR>exit for <BR><BR>end if <BR><BR>next 
            <BR><BR>if win or loss then exit for <BR><BR>next <BR><BR>if win 
            then <BR><BR>response.write "你赢了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>if loss then 
            <BR><BR>response.write "对不起,你输了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>  
            <BR><BR>'列向判断"|" <BR><BR>for j=1 to 15 <BR><BR>win=false 
            <BR><BR>loss=false <BR><BR>five_me=0 <BR><BR>five_he=0 <BR><BR>for 
            i=1 to 15 <BR><BR>if application("color" &amp; session("class") 
            &amp; "_" &amp; cstr(i) &amp; "_" &amp; cstr <BR>(j))=m then 
            <BR><BR>five_me=five_me+1 <BR><BR>five_he=0 <BR><BR>elseif 
            application("color" &amp; session("class") &amp; "_" &amp; cstr(i) 
            &amp; "_" &amp; <BR>cstr(j))=h then <BR><BR>five_me=0 
            <BR><BR>five_he=five_he+1 <BR><BR>else <BR><BR>five_me=0 
            <BR><BR>five_he=0 <BR><BR>end if <BR><BR>if five_me=5 then 
            <BR><BR>win=true <BR><BR>loss=false <BR><BR>exit for <BR><BR>elseif 
            five_he=5 then <BR><BR>win=false <BR><BR>loss=true <BR><BR>exit for 
            <BR><BR>end if <BR><BR>next <BR><BR>if win or loss then exit for 
            <BR><BR>next <BR><BR>if win then <BR><BR>response.write "你赢了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>if loss then 
            <BR><BR>response.write "对不起,你输了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>  
            <BR><BR>'斜向判断"/" <BR><BR>for i=1 to 11 <BR><BR>win=false 
            <BR><BR>loss=false <BR><BR>five_me=0 <BR><BR>five_he=0 <BR><BR>for 
            j=i+4 to 1 step -1 <BR><BR>if application("color" &amp; 
            session("class") &amp; "_" &amp; cstr(j) &amp; "_" &amp; cstr 
            <BR>(i+5-j))=m then <BR><BR>five_me=five_me+1 <BR><BR>five_he=0 
            <BR><BR>elseif application("color" &amp; session("class") &amp; "_" 
            &amp; cstr(j) &amp; "_" &amp; <BR>cstr(i+5-j))=h then 
            <BR><BR>five_me=0 <BR><BR>five_he=five_he+1 <BR><BR>else 
            <BR><BR>five_me=0 <BR><BR>five_he=0 <BR><BR>end if <BR><BR>if 
            five_me=5 then <BR><BR>win=true <BR><BR>loss=false <BR><BR>exit for 
            <BR><BR>elseif five_he=5 then <BR><BR>win=false <BR><BR>loss=true 
            <BR><BR>exit for <BR><BR>end if <BR><BR>next <BR><BR>if win or loss 
            then exit for <BR><BR>next <BR><BR>if win then 
            <BR><BR>response.write "你赢了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>if loss then 
            <BR><BR>response.write "对不起,你输了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>  
            <BR><BR>'斜向判断"\" <BR><BR>for i=1 to 11 <BR><BR>win=false 
            <BR><BR>loss=false <BR><BR>five_me=0 <BR><BR>five_he=0 <BR><BR>for 
            j=12-i to 15 <BR><BR>if application("color" &amp; session("class") 
            &amp; "_" &amp; cstr(13-i-j) &amp; "_" <BR>&amp; cstr(j))=m then 
            <BR><BR>five_me=five_me+1 <BR><BR>five_he=0 <BR><BR>elseif 
            application("color" &amp; session("class") &amp; "_" &amp; 
            cstr(13-i-j) <BR>&amp; "_" &amp; cstr(j))=h then <BR><BR>five_me=0 
            <BR><BR>five_he=five_he+1 <BR><BR>else <BR><BR>five_me=0 
            <BR><BR>five_he=0 <BR><BR>end if <BR><BR>if five_me=5 then 
            <BR><BR>win=true <BR><BR>loss=false <BR><BR>exit for <BR><BR>elseif 
            five_he=5 then <BR><BR>win=false <BR><BR>loss=true <BR><BR>exit for 
            <BR><BR>end if <BR><BR>next <BR><BR>if win or loss then exit for 
            <BR><BR>next <BR><BR>if win then <BR><BR>response.write "你赢了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>if loss then 
            <BR><BR>response.write "对不起,你输了!" 
            <BR><BR>application(application("first" &amp; 
            session("class")))=false <BR><BR>application(application("second" 
            &amp; session("class")))=false <BR><BR>end if <BR><BR>%&gt; 
            <BR><BR>&lt;/body&gt; <BR><BR>&lt;/html&gt; <BR><BR>&nbsp; 
            &nbsp;如果某点没有棋子,则加上一个超连接,根据擂主与攻擂手的区别放上一个不同颜色的棋子。最后的一段是用来判断输与赢,分为横,列和两个斜线方向。具体内容看一下就可以明白。 
            <BR><BR>&nbsp; &nbsp;最后要说的一点就是global.asa 
            ,这是站点上的一个核心文件,为了在退出棋局后,将位置留给别人,需要在sesison_onend中加入代码进行处理,如下: 
            <BR><BR>&lt;script language=vbscript runat = server&gt; <BR><BR>sub 
            application_onstart <BR><BR>session.timeout=1 <BR><BR>end sub 
            <BR><BR>sub session_onstart <BR><BR>if application("num")="" then 
            <BR><BR>application("num")=0 <BR><BR>end if 
            <BR><BR>application("num")=application("num")+1 <BR><BR>end sub 
            <BR><BR>&lt;/script&gt; <BR><BR>  <BR><BR>&lt;script 
            language=vbscript runat = server&gt; <BR><BR>sub session_onend 
            <BR><BR>if application("num")="" then <BR><BR>application("num")=0 
            <BR><BR>end if <BR><BR>application("num")=application("num")-1 
            <BR><BR>  <BR><BR>if application("first1")=session("nice") then 
            <BR><BR>application("first1")="" <BR><BR>elseif 
            application("second1")=session("nice") then 
            <BR><BR>application("second1")="" <BR><BR>  <BR><BR>elseif 
            application("first2")=session("nice") then 
            <BR><BR>application("first2")="" <BR><BR>elseif 
            application("second2")=session("nice") then 
            <BR><BR>application("second2")="" <BR><BR>  <BR><BR>elseif 
            application("first3")=session("nice") then 
            <BR><BR>application("first3")="" <BR><BR>elseif 
            application("second3")=session("nice") then 
            <BR><BR>application("second3")="" <BR><BR>  <BR><BR>elseif 
            application("first4")=session("nice") then 
            <BR>application("first4")="" <BR>elseif 
            application("second4")=session("nice") then 
            <BR>application("second4")="" <BR>  <BR><BR>elseif 
            application("first5")=session("nice") then 
            <BR><BR>application("first5")="" <BR><BR>elseif 
            application("second5")=session("nice") then 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -