<!--#include file="./conn.asp"-->
<!-- #include file="./inc/const.asp" -->
<!--#include file=./chkuser.asp-->
<!-- #include file="./inc/char.asp" -->
<!--#include file="./inc/theme.asp"-->
<%dim j,sel,cc,k,cpass,pp,ii,jj,hpass,human,com,re,rq,Pick_Greeting
	Response.Buffer=True 
  call nav()
        stats="文化广场--黑白棋"
		call headline(1)
		%>

<% 
dim ptime,username
Response.Expires=0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Pragma","No-Cache"
Response.AddHeader "Cache-Control","Private"
Response.CacheControl = "No-Cache"

session("username")=request.cookies("aspsky")("username")
if session("username")="" then
%>
<script language=vbscript>
MsgBox "您还没有登陆，不能进入"
location.href = "javascript:history.back()"
</script>
<%
else
xz=request("xz")
na=request("na")
dz=request("dz")
	dim na
		dim dz,xz
	'下注
  if request("action") = "1" then
  dz=1
   xz=1
  na="无邪"
  elseif request("action") = "2" then
  dz=2
  xz=1
  na="金刚"
  elseif request("action") = "3" then
  dz=3
   xz=1
   na="莫名"
  elseif request("action") = "4" then
  dz=4
   xz=1
   na="潘多"
  elseif request("action") = "5" then
  dz=5
   xz=1
   na="柳丰"
  elseif request("action") = "6" then
  dz=6
   xz=1
   na="大蘅"
  elseif request("action") = "7" then
  dz=7
  na="贝拉"
   xz=1
  elseif request("action") = "8" then
  dz=8
  na="虚梅"
   xz=1
  elseif request("action") = "9" then
  dz=9
  na="斯强"
   xz=1
  elseif request("action") = "0" then
  dz=10
  na="小意思"
   xz=1
  end if
	%>

<%
if xz=1 then
%>
<center>你已经选好<%=na%>作为自己的对手！	
<% 
    
	
xz=1
	dim p(8,8),b(8,8),x(8,8)
	p(1,1) = 7 : p(8,1) = 7 : p(8,8) = 7 : p(1,8) = 7 : p(3,3) = 6 : p(3,4) = 6
	p(3,5) = 6 : p(3,6) = 6 : p(4,3) = 6 : p(4,6) = 6 : p(5,3) = 6 : p(5,4) = 6
	p(6,3) = 6 : p(6,4) = 6 : p(6,5) = 6 : p(6,6) = 6 : p(1,3) = 5 : p(1,6) = 5
	p(3,1) = 5 : p(3,8) = 5 : p(6,1) = 5 : p(6,8) = 5 : p(8,3) = 5 : p(8,6) = 5 
	p(1,4) = 4 : p(1,5) = 4 : p(4,1) = 4 : p(4,8) = 4 : p(5,1) = 4 : p(5,8) = 4
	p(8,4) = 4 : p(8,5) = 4 : p(2,3) = 3 : p(2,4) = 3 : p(2,5) = 3 : p(2,6) = 3
	p(3,2) = 3 : p(3,7) = 3 : p(4,2) = 3 : p(4,7) = 3 : p(3,2) = 3 : p(3,7) = 3
	p(4,2) = 3 : p(4,7) = 3 : p(5,2) = 3 : p(5,7) = 3 : p(6,2) = 3 : p(6,7) = 3
	p(7,3) = 3 : p(7,4) = 3 : p(7,5) = 3 : p(7,6) = 3 : p(1,2) = 2 : p(1,7) = 2
	p(2,1) = 2 : p(2,8) = 2 : p(7,1) = 2 : p(7,8) = 2 : p(8,2) = 2 : p(8,7) = 2
	p(2,2) = 1 : p(2,7) = 1 : p(7,2) = 1 : p(7,7) = 1

	for i = 1 to 8
	  for j = 1 to 8
	    b(i,j) = cint(request("b" & i & j))
	  next
	next
	sel = request("sel")

	select case sel

	case 0						' init
	  for i=1 to 8
	    for j=1 to 8
	      b(i,j) = 0
	    next
	  next
	  b(4,4) = 1 : b(5,5) = 1 : b(4,5) = 2 : b(5,4) = 2

	case 1						' human put
	  for i=1 to 8
	    for j=1 to 8
	      if request("n" & i & j & ".x") <> "" then call put(i,j,1)
	    next
	  next
	
	case 2
	  call mark(2)					' com mark
	  cpass = 0
	  for i=1 to 8
	    for j=1 to 8
	      if x(i,j) <> 0 then cpass = 1
	    next
	  next
	  if cpass <> 0 then
	    for i=1 to 8
	      for j=1 to 8
	        if x(i,j) = 1 then
		   if pp < p(i,j) then
		     pp = p(i,j)
		     ii = i
		     jj = j
		    end if
		 end if
	      next
	    next
	    call put(ii,jj,2)
	  end if
	  call mark(1)					' human mark
	  hpass = 0
	  for i=1 to 8
	    for j=1 to 8
	      if x(i,j) <> 0 then hpass = 1
	    next
	  next
	  if cpass <> 0 and hpass = 0 then sel = 1 	' com again
	  if cpass = 0 and hpass = 0 then sel = 3 	' end

	end select
%>
  <script language="vbscript" runat=server>

sub mark(c)
	for i=1 to 8
	  for j=1 to 8
	    if (( c1(i,j,c) = 1 or c2(i,j,c) = 1 or c3(i,j,c) = 1 or _
	          c4(i,j,c) = 1 or c5(i,j,c) = 1 or c6(i,j,c) = 1 or _
	          c7(i,j,c) = 1 or c8(i,j,c) = 1 ) and b(i,j) = 0 ) then
	      x(i,j) = 1
	    else
	      x(i,j) = 0
	    end if
	  next
	next
end sub

function c1(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( j-k < 1 ) then c1 = 0 : exit function
	  if ( k = 1 and b(i,j-k) <> cc ) then c1 = 0 : exit function
	  if ( k > 1 and b(i,j-k) = 0 ) then c1 = 0 : exit function
	  if ( k > 1 and b(i,j-k) = c ) then c1 = 1 : exit function
	next
end function

function c2(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( i+k > 8 ) then c2 = 0 : exit function
	  if ( k = 1 and b(i+k,j) <> cc ) then c2 = 0 : exit function
	  if ( k > 1 and b(i+k,j) = 0 ) then c2 = 0 : exit function
	  if ( k > 1 and b(i+k,j) = c ) then c2 = 1 : exit function
	next
end function

function c3(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( j+k > 8 ) then c3 = 0 : exit function
	  if ( k = 1 and b(i,j+k) <> cc ) then c3 = 0 : exit function
	  if ( k > 1 and b(i,j+k) = 0 ) then c3 = 0 : exit function
	  if ( k > 1 and b(i,j+k) = c ) then c3 = 1 : exit function
	next
end function

function c4(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( i-k < 1 ) then c4 = 0 : exit function
	  if ( k = 1 and b(i-k,j) <> cc ) then c4 = 0 : exit function
	  if ( k > 1 and b(i-k,j) = 0 ) then c4 = 0 : exit function
	  if ( k > 1 and b(i-k,j) = c ) then c4 = 1 : exit function
	next
end function

function c5(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( i+k > 8 or j-k < 1 ) then c5 = 0 : exit function
	  if ( k = 1 and b(i+k,j-k) <> cc ) then c5 = 0 : exit function
	  if ( k > 1 and b(i+k,j-k) = 0 ) then c5 = 0 : exit function
	  if ( k > 1 and b(i+k,j-k) = c ) then c5 = 1 : exit function
	next
end function

function c6(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( i+k > 8 or j+k > 8 ) then c6 = 0 : exit function
	  if ( k = 1 and b(i+k,j+k) <> cc ) then c6 = 0 : exit function
	  if ( k > 1 and b(i+k,j+k) = 0 ) then c6 = 0 : exit function
	  if ( k > 1 and b(i+k,j+k) = c ) then c6 = 1 : exit function
	next
end function

function c7(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( i-k < 1 or j+k > 8 ) then c7 = 0 : exit function
	  if ( k = 1 and b(i-k,j+k) <> cc ) then c7 = 0 : exit function
	  if ( k > 1 and b(i-k,j+k) = 0 ) then c7 = 0 : exit function
	  if ( k > 1 and b(i-k,j+k) = c ) then c7 = 1 : exit function
	next
end function

function c8(i,j,c)
	if c = 1 then cc = 2
	if c = 2 then cc = 1
	for k=1 to 8
	  if ( i-k < 1 or j-k < 1 ) then c8 = 0 : exit function
	  if ( k = 1 and b(i-k,j-k) <> cc ) then c8 = 0 : exit function
	  if ( k > 1 and b(i-k,j-k) = 0 ) then c8 = 0 : exit function
	  if ( k > 1 and b(i-k,j-k) = c ) then c8 = 1 : exit function
	next
end function

sub put(i,j,c)
	b(i,j) = c
	if c = 1 then cc = 2
	if c = 2 then cc = 1

	if c1(i,j,c) = 1 then
	  k = 1
	  do while b(i,j-k) = cc
	    b(i,j-k) = c
	    k = k + 1
	  loop
	end if

	if c2(i,j,c) = 1 then
	  k = 1
	  do while b(i+k,j) = cc
	    b(i+k,j) = c
	    k = k + 1
	  loop
	end if

	if c3(i,j,c) = 1 then
	  k = 1
	  do while b(i,j+k) = cc
	    b(i,j+k) = c
	    k = k + 1
	  loop
	end if

	if c4(i,j,c) = 1 then
	  k = 1
	  do while b(i-k,j) = cc
	    b(i-k,j) = c
	    k = k + 1
	  loop
	end if

	if c5(i,j,c) = 1 then
	  k = 1
	  do while b(i+k,j-k) = cc
	    b(i+k,j-k) = c
	    k = k + 1
	  loop
	end if

	if c6(i,j,c) = 1 then
	  k = 1
	  do while b(i+k,j+k) = cc
	    b(i+k,j+k) = c
	    k = k + 1
	  loop
	end if

	if c7(i,j,c) = 1 then
	  k = 1
	  do while b(i-k,j+k) = cc
	    b(i-k,j+k) = c
	    k = k + 1
	  loop
	end if

	if c8(i,j,c) = 1 then
	  k = 1
	  do while b(i-k,j-k) = cc
	    b(i-k,j-k) = c
	    k = k + 1
	  loop
	end if
end sub

</script>
<FORM METHOD=POST ACTION=othello.asp?xz=1&na=<%=na%>&dz=<%=dz%>>
<center>
  <table width=31 border="0" height="50">
    <tr>
      <td align=center width="10%"> 
        <%
select case  na
case "无邪"
%>
        <img src="PIC/Image130.gif" border="0" alt="无邪正在紧张思考"> 
        <%
case "金刚"
%>
        <img src="PIC/IMAGE112.GIF" border="0" alt="金刚正在紧张思考"> 
        <%
case "莫名"
%>
        <img src="PIC/IMAGE117.GIF" border="0" alt="莫名正在紧张思考"> 
        <%
case "潘多"
%>
        <img src="PIC/IMAGE118.GIF" border="0" alt="潘多正在紧张思考"> 
        <%
case "柳丰"
%>
        <img src="PIC/Image128.gif" border="0" alt="柳丰正在紧张思考"> 
        <%
case "大蘅"
%>
        <img src="PIC/IMAGE115.GIF"  border="0" alt="大蘅正在紧张思考"> 
        <%
case "贝拉"
%>
        <img src="PIC/Image120.gif" width="80" height="95" border="0" alt="贝拉正在紧张思考"> 
        <%
case "虚梅"
%>
        <img src="PIC/Image124.gif" width="85" height="90" border="0" alt="虚梅正在紧张思考"> 
        <%
case "斯强"
%>
        <img src="PIC/Image126.gif" width="82" height="90" border="0" alt="斯强正在紧张思考"> 
        <%
case "小意思"
%>
        <img src="PIC/Image122.gif" width="95" height="95" border="0" alt="小意思也在紧张思考"> 
        <%
end select
%>
      </td>
      <td align=center width="20%"> 
        <TABLE BORDER=1 bordercolor="#0000FF">
          <%
		  	for j=1 to 8
	  response.write "<tr>"
	  for i=1 to 8
	    response.write "<td align=center>"
	    response.write "<input type=hidden name=b" & i & j & " value=" & b(i,j) & ">"

	    select case b(i,j)

	    case 0
	      if x(i,j) = 1 then
	      	response.write "<input type=image src=""move.gif""  border=0 name=n" & i & j & ">"
	      else
	      	response.write "<img src=""none.gif"" width=20 height=20 border=0>"
	      end if

	    case 1
	      response.write "<img src=""white.gif"" width=20 height=20 border=0>"

	    case 2
	      response.write "<img src=""black.gif"" width=20 height=20 border=0>"

	    end select
	    response.write "</td>"
	  next
	  response.write "</tr>"
	next
	response.write "</table><p>"

	select case sel
	case 0,1
	  response.write "<input type=hidden name=sel value=2>"
	  %>
          
            <input type=submit TITLE=点一下这里 value=<%=na%>下了>
            <%
	  xz=1

	case 2
	  response.write "<input type=hidden name=sel value=1>"
	  response.write "轮到你下了！选择一个方块！"

	case 3
	  for i=1 to 8
	    for j=1 to 8
	      if b(i,j) = 1 then human = human + 1
	      if b(i,j) = 2 then com = com + 1
	    next
	  next
	'Added by Alex98
	
dim rs1,sql1,a
session.contents("username")=request.cookies("aspsky")("username")
set rs1=server.createobject("adodb.recordset")
	 IF com = human THEN 
	 %>
	 <script language=vbscript>
	 msgbox "曾经有一段和棋放在我面前，我没有去珍惜！若让我再选一次，就重来吧！",0,"旗鼓相当嘛！"
	 location.href = "othello.asp"
	 </script>
	 <%
	 end if
	IF com > human THEN
response.write "<FONT SIZE=5><B>你输了!</B></FONT><BR>"
   re="输"
   a=dz*(com-human)
        RANDOMIZE
        Pick_Greeting=INT((2+1)*RND)
        SELECT CASE Pick_Greeting
       CASE 0
       rq="回去练练吧！"
      CASE 1
       rq="看样子我又骗到手了！"
      CASE 2
      rq="就你这样还跟我下？！"
      END SELECT
	  %>
            共计<%=a%>块大洋
            <%
    sql1="update [user] set userwealth=userwealth-"&a&" where username='"&session.contents("username")&"'"
	ELSE
	a=dz*(human-com)
	response.write "<FONT SIZE=5><B>你赢了:</B></FONT>"
	re="赢"
	RANDOMIZE
        Pick_Greeting=INT((2+1)*RND)
        SELECT CASE Pick_Greeting
       CASE 0
       rq="你好厉害啊！"
      CASE 1
       rq="看样子我要多练练！"
      CASE 2
      rq="我要逃了！"
      END SELECT
	%>
            共计<%=a%>块大洋!<BR>
            <%
	sql1="update [user] set userwealth=userwealth+"&a&" where username='"&session.contents("username")&"'"
	end if
	 conn.Execute(sql1)
     conn.close
     set conn=nothing
	%>
	
            <B>得分:</B><BR>
            <%=na%><%=com%>点<BR>
            你<%=human%>点
            <%  
	  response.write "<BR><A HREF=""othello.asp"">再下一盘.</A>"
	  response.write "<BR><A HREF=""index.asp"">输不起了.</A>"
	  response.write "<BR><BR><hr NOSHADE><B>规则</B><BR>"
	  %>
	  <script language=vbscript>
	result="哈哈！你<%=re%>了<%=a%>块大洋！<%=rq%>请问您还要不要下？"
	
	sa=msgbox (result,36,"<%=session.contents("username")%><%=re%>啰！")
 
   if sa=vbyes then 
   location.href = "othello.asp"
   else
   location.href = "index.asp"
   end if

	</script>>
	<%
end select
%>
          </div>
        </TABLE></td> 
      <td align=center width="10%"> 
        
          <div align="left">
            
              <div align="left">
                
                  <div align="left">
                    <pre><b><font size="3" color="#FF0000">               庆祝活力社区黑白棋棋室开张
</font>1.棋室特聘10位高手,你现在正与<%=na%>对决!
2.本棋室由活力人生俱乐部--活力论坛掌门小意思操刀制作,希望能与你们网站做连接或联盟论坛
3.黑白棋着法:
    横竖斜将对方子夹住即可吃掉对方(变成我方子),每次电脑提示你能走的方格!以全部布满为止,
计算谁的子多,根据你选的棋手分别加倍送(扣)钱!</b></pre>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </td>
  </tr>
</table>
<!--#include file="footer.asp"-->
</form>

  <%else%>
  
<p align="center">请你选择活力社区黑白棋棋室高手!</p>

<table width="<%=TableWidth%>" cellpadding=6 cellspacing=0 align=center bordercolor="<%=Tablebackcolor%>" border=1>    <tr> 
      <td align=center bgColor=<%=Tablebodycolor%>  >
        <a href="othello.asp?action=1"><img src="PIC/Image130.gif" border="0" alt="和无邪下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> >
        <a href="othello.asp?action=2"><img src="PIC/IMAGE112.GIF" border="0" alt="和金刚下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> >
        <a href="othello.asp?action=3"><img src="PIC/IMAGE117.GIF" border="0" alt="和莫名下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> >
        <a href="othello.asp?action=4"><img src="PIC/IMAGE118.GIF" border="0" alt="和潘多下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> >
        <a href="othello.asp?action=5"><img src="PIC/Image128.gif" border="0" alt="和柳丰下"></a>
      </td>
    </tr>
    <tr> 
      <td align=center bgColor=<%=Tablebodycolor%> >小女刚刚学会，多多包涵！</td>
      <td align=center bgColor=<%=Tablebodycolor%> >我和你来比一比！</td>
      <td align=center bgColor=<%=Tablebodycolor%> >要下就下呗,不要磨蹭!</td>
      <td align=center bgColor=<%=Tablebodycolor%> >哈哈!来者不拒!</td>
      <td align=center bgColor=<%=Tablebodycolor%> >我欢迎你!</td>
    </tr>
    <tr> 
      <td align=center height="7" colspan="5">&nbsp;</td>
    </tr>
    <tr> 
      <td align=center bgColor=<%=Tablebodycolor%>  > 
        <a href="othello.asp?action=6"><img src="PIC/IMAGE115.GIF"  border="0" alt="和大蘅下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> > 
        <a href="othello.asp?action=7"><img src="PIC/Image120.gif"   border="0" alt="和贝拉下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> > 
        <a href="othello.asp?action=8"><img src="PIC/Image124.gif"   border="0" alt="和虚梅下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> > 
        <a href="othello.asp?action=9"><img src="PIC/Image126.gif"   border="0" alt="和斯强下"></a>
      </td>
      <td align=center bgColor=<%=Tablebodycolor%> > 
        <a href="othello.asp?action=0"><img src="PIC/Image122.gif"   border="0" alt="和小意思下"></a>
      </td>
    </tr>
    <tr> 
      <td align=center bgColor=<%=Tablebodycolor%>  >不要出声,随我来!</td>
      <td align=center bgColor=<%=Tablebodycolor%> >好啊好啊,就和我吧!</td>
      <td align=center bgColor=<%=Tablebodycolor%> >我可不见得输给你哦!</td>
      <td align=center bgColor=<%=Tablebodycolor%> >想好了再来哦!输会很惨的!</td>
      <td align=center bgColor=<%=Tablebodycolor%> >小意思是您的朋友,来一局吧!</td>
    </tr>
  </table>
  <br><br><br>
</div>
<%end if
end if
%>
<!--#include File="footer.asp"-->