taizhimin лет назад: 4
Родитель
Сommit
618c2b33fa
5 измененных файлов с 195 добавлено и 774 удалено
  1. 0 383
      five-chess.html
  2. 156 54
      five-line-canvas.html
  3. 0 337
      five-line.html
  4. 22 0
      houses.html
  5. 17 0
      index.html

+ 0 - 383
five-chess.html

@@ -1,383 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <meta charset="UTF-8">
-    <title>五子棋</title>
-    <style type="text/css">
-        canvas {
-            display: block;
-            margin: 50px auto;
-            box-shadow: -2px -2px 2px #EFEFEF, 5px 5px 5px #B9B9B9;
-            cursor: pointer;
-        }
-        .btn-wrap {
-            display: flex;
-            flex-direction: row;
-            justify-content: center;
-        }
-        .btn-wrap div {
-            margin: 0 10px;
-        }
-        div>span {
-            display: inline-block;
-            padding: 10px 20px;
-            color: #FFFFFF;
-            background-color: #EE82EE;
-            border-radius: 5px;
-            cursor: pointer;
-        }
-        div.unable span {
-            background: #D6D6D4;
-            color: #ADACAA;
-        }
-        #result-wrap {
-            text-align: center;
-        }
-    </style>
-
-
-</head>
-<body>
-<h3 id="result-wrap">--益智五子棋--</h3>
-<canvas id="chess" width="450px" height="450px"></canvas>
-<div id="btn-wrap">
-    <div id="restart" class="restart">
-        <span>重新开始</span>
-    </div>
-    <div id="goback" class="goback unable">
-        <span>悔棋</span>
-    </div>
-    <div id="return" class="return unable">
-        <span>撤销悔棋</span>
-    </div>
-</div>
-<script type="text/javascript">
-    var over = false;
-    var me = true;	//我
-    var _nowi = 0, _nowj = 0; //记录自己下棋的坐标
-    var _compi = 0, _compj = 0; //记录计算机当前下棋的坐标
-    var _myWin = [], _compWin = []; //记录我,计算机赢的情况
-    var backAble = false, returnAble = false;
-    var resultTxt = document.getElementById("result-wrap");
-    var chressBord = []; //棋盘
-    for (var i = 0; i < 15; i++) {
-        chressBord[i] = [];
-        for (var j = 0; j < 15; j++) {
-            chressBord[i][j] = 0;
-        }
-    }
-    //赢法的统计数组
-    var myWin = [];
-    var computerWin = [];
-    //赢法数组
-    var wins = [];
-    for (var i = 0; i < 15; i++) {
-        wins[i] = [];
-        for (var j = 0; j < 15; j++) {
-            wins[i][j] = [];
-        }
-    }
-    var count = 0; //赢法总数
-    //横线赢法
-    for (var i = 0; i < 15; i++) {
-        for (var j = 0; j <11; j++) {
-            for (var k = 0; k < 5; k++) {
-                wins[i][j+k][count] = true;
-            }
-            count++;
-        }
-    }
-    //竖线赢法
-    for (var i = 0; i < 15; i++) {
-        for (var j = 0; j <11; j++) {
-            for (var k = 0; k < 5; k++) {
-                wins[j+k][i][count] = true;
-            }
-            count++;
-        }
-    }
-    //正斜线赢法
-    for (var i = 0; i < 11; i++) {
-        for (var j = 0; j <11; j++) {
-            for (var k = 0; k < 5; k++) {
-                wins[i+k][j+k][count] = true;
-            }
-            count++;
-        }
-    }
-    //反斜线赢法
-    for (var i = 0; i < 11; i++) {
-        for (var j = 14; j > 3; j--) {
-            for (var k = 0; k < 5; k++) {
-                wins[i+k][j-k][count] = true;
-            }
-            count++;
-        }
-    }
-    // debugger;
-    for (var i = 0; i < count; i++) {
-        myWin[i] = 0;
-        _myWin[i] = 0;
-        computerWin[i] = 0;
-        _compWin[i] = 0;
-    }
-    var chess = document.getElementById("chess");
-    var context = chess.getContext('2d');
-    context.strokeStyle = '#bfbfbf';	//边框颜色
-    var backbtn = document.getElementById("goback");
-    var returnbtn = document.getElementById("return");
-    window.onload = function() {
-        drawChessBoard(); // 画棋盘
-    }
-    document.getElementById("restart").onclick = function(){
-        window.location.reload();
-    }
-    // 我,下棋
-    chess.onclick = function(e){
-        if(over){
-            return;
-        }
-        if(!me){
-            return;
-        }
-        // 悔棋功能可用
-        backbtn.className = backbtn.className.replace(new
-        RegExp("(\\s|^)unable(\\s|$)")," ");
-        var x = e.offsetX;
-        var y = e.offsetY;
-        var i = Math.floor(x / 30);
-        var j = Math.floor(y / 30);
-        _nowi = i;
-        _nowj = j;
-        if(chressBord[i][j] == 0){
-            oneStep(i,j,me);
-            chressBord[i][j] = 1; //我,已占位置
-
-            for (var k = 0; k < count; k++) { // 将可能赢的情况都加1
-                if(wins[i][j][k]){
-                    // debugger;
-                    myWin[k]++;
-                    _compWin[k] = computerWin[k];
-                    computerWin[k] = 6; //这个位置对方不可能赢了
-                    if(myWin[k] == 5){
-                        // window.alert('你赢了');
-                        resultTxt.innerHTML = '恭喜,你赢了!';
-                        over = true;
-                    }
-                }
-            }
-            if(!over){
-                me = !me;
-                computerAI();
-            }
-        }
-    }
-    // 悔棋
-    backbtn.onclick = function(e){
-        if(!backAble) { return;}
-        over = false;
-        me = true;
-        // resultTxt.innerHTML = 'o(╯□╰)o,悔棋中';
-        // 撤销悔棋功能可用
-        returnbtn.className = returnbtn.className.replace( new
-        RegExp("(\\s|^)unable(\\s|$)")," ");
-        // 我,悔
-        chressBord[_nowi][_nowj] = 0; //我,已占位置 还原
-        minusStep(_nowi, _nowj); //销毁棋子
-
-        for (var k = 0; k < count; k++) { // 将可能赢的情况都减1
-            if(wins[_nowi][_nowj][k]){
-                myWin[k]--;
-                computerWin[k] = _compWin[k]; //这个位置对方可能赢
-            }
-        }
-        // 计算机相应的悔棋
-        chressBord[_compi][_compj] = 0; //计算机,已占位置 还原
-        minusStep(_compi, _compj);//销毁棋子
-
-        for (var k = 0; k < count; k++) {// 将可能赢的情况都减1
-            if(wins[_compi][_compj][k]){
-                computerWin[k]--;
-                myWin[k] = _myWin[i];//这个位置对方可能赢
-            }
-        }
-        resultTxt.innerHTML = '--益智五子棋--';
-        returnAble = true;
-        backAble = false;
-    }
-    // 撤销悔棋
-    returnbtn.onclick = function(e){
-        if(!returnAble){ return;}
-        // 我,撤销悔棋
-        chressBord[_nowi][_nowj] = 1;//我,已占位置
-        oneStep(_nowi,_nowj,me);
-        for (var k = 0; k < count; k++) {
-            if(wins[_nowi][_nowj][k]){
-                myWin[k]++;
-                _compWin[k] = computerWin[k];
-                computerWin[k] = 6;//这个位置对方不可能赢
-            }
-            if(myWin[k] == 5){
-                resultTxt.innerHTML = '恭喜,你赢了!';
-                over = true;
-            }
-        }
-        // 计算机撤销相应的悔棋
-        chressBord[_compi][_compj] = 2;//计算机,已占位置
-        oneStep(_compi,_compj,false);
-        for (var k = 0; k < count; k++) {// 将可能赢的情况都减1
-            if(wins[_compi][_compj][k]){
-                computerWin[k]++;
-                _myWin[k] = myWin[k];
-                myWin[k] = 6;//这个位置对方不可能赢
-            }
-            if(computerWin[k] == 5){
-                resultTxt.innerHTML = 'o(╯□╰)o,计算机赢了,继续加油哦!';
-                over = true;
-            }
-        }
-        returnbtn.className += '' + 'unable';
-        returnAble = false;
-        backAble = true;
-    }
-
-    // 计算机下棋
-    var computerAI = function(){
-        var myScore = [];
-        var computerScore = [];
-        var max = 0;
-        var u =0, v = 0;
-        for (var i = 0; i < 15; i++) {
-            myScore[i] = [];
-            computerScore[i] = [];
-            for (var j = 0; j < 15; j++) {
-                myScore[i][j] = 0;
-                computerScore[i][j] = 0;
-            }
-        }
-        for (var i = 0; i < 15; i++) {
-            for (var j = 0; j < 15; j++) {
-                if(chressBord[i][j] == 0){
-                    for (var k = 0; k < count; k++) {
-                        if(wins[i][j][k]){
-                            if(myWin[k] == 1){
-                                myScore[i][j] += 200;
-                            }else if(myWin[k] == 2){
-                                myScore[i][j] += 400;
-                            }
-                            else if(myWin[k] == 3){
-                                myScore[i][j] += 2000;
-                            }
-                            else if(myWin[k] == 4){
-                                myScore[i][j] += 10000;
-                            }
-
-                            if(computerWin[k] == 1){
-                                computerScore[i][j] += 220;
-                            }else if(computerWin[k] == 2){
-                                computerScore[i][j] += 420;
-                            }
-                            else if(computerWin[k] == 3){
-                                computerScore[i][j] += 2100;
-                            }
-                            else if(computerWin[k] == 4){
-                                computerScore[i][j] += 20000;
-                            }
-                        }
-                    }
-
-                    if(myScore[i][j] > max){
-                        max = myScore[i][j];
-                        u = i;
-                        v = j;
-                    }else if(myScore[i][j] == max){
-                        if(computerScore[i][j]>computerScore[u][v]){
-                            u = i;
-                            v = j;
-                        }
-                    }
-
-                    if(computerScore[i][j] > max){
-                        max = computerScore[i][j];
-                        u = i;
-                        v = j;
-                    }else if(computerScore[i][j] == max){
-                        if(myScore[i][j]>myScore[u][v]){
-                            u = i;
-                            v = j;
-                        }
-                    }
-                }
-            }
-        }
-        _compi = u;
-        _compj = v;
-        oneStep(u,v,false);chressBord[u][v] = 2; //计算机占据位置
-        for (var k = 0; k < count; k++) {
-            if(wins[u][v][k]){
-                computerWin[k]++;
-                _myWin[k] = myWin[k];
-                myWin[k] = 6; //这个位置对方不可能赢了
-                if(computerWin[k] == 5){
-                    resultTxt.innerHTML = 'o(╯□╰)o,计算机赢了,继续加油哦!';
-                    over = true;
-                }
-            }
-        }
-        if(!over){
-            me = !me;
-        }
-        backAble = true;
-        returnAble = false;
-        var hasClass = new RegExp('unable').test('' +
-            returnbtn.className + '');
-        if(hasClass) {
-            returnbtn.className += '' + 'unable';
-        }
-    }
-    //绘画棋盘
-    var drawChessBoard = function(){
-        for (var i = 0; i < 15; i++) {
-            context.moveTo(15 + i * 30 , 15);
-            context.lineTo(15 + i * 30 , 435);
-            context.stroke();
-            context.moveTo(15 , 15 + i * 30);
-            context.lineTo(435 , 15 + i * 30);
-            context.stroke();
-        }
-    }
-    //画棋子
-    var oneStep = function(i,j,me) {
-        context.beginPath();
-        context.arc(15 +i * 30, 15 + j * 30, 13, 0, 2 * Math.PI);// 画圆
-        context.closePath();
-        //渐变
-        var gradient = context.createRadialGradient(15 + i * 30
-            + 2, 15 + j * 30 - 2, 13, 15 + i * 30 + 2, 15 + j * 30 -
-            2, 0);
-        if(me){
-            gradient.addColorStop(0,'#0a0a0a');
-            gradient.addColorStop(1,'#636766');
-        }else{
-            gradient.addColorStop(0,'#d1d1d1');
-            gradient.addColorStop(1,'#f9f9f9')
-        }
-        context.fillStyle = gradient;
-        context.fill();
-    }
-    //销毁棋子
-    var minusStep = function(i,j){
-        //擦除该圆
-        context.clearRect((i) * 30, (j) * 30, 30, 30);
-        // 重画该圆周围的格子
-        context.beginPath();
-        context.moveTo(15+i*30, j*30);
-        context.lineTo(15+i*30, j*30 + 30);
-        context.moveTo(i*30, j*30+15);
-        context.lineTo((i+1)*30, j*30+15);
-
-        context.stroke();
-    }
-</script>
-</body>
-</html>

+ 156 - 54
five-line-canvas.html

@@ -1,5 +1,6 @@
 <!DOCTYPE html>
-<html lang="en">
+<html>
+
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
@@ -17,27 +18,29 @@
         }
     </style>
 </head>
+
 <body>
 
-<canvas id="chess" width="500px" height="500px">
-</canvas>
-<div id="round" style="margin: 50px auto;"></div>
+    <canvas id="chess" width="500px" height="500px">
+    </canvas>
+    <div style="margin: 50px auto;"><span>准备</span> <span>开始</span> <span>悔棋</span></div>
+    <div id="round" style="margin: 50px auto;"></div>
 </body>
 <script>
-    var chess = document.getElementById("chess");
-    var context = chess.getContext('2d');
-    var rect = chess.getBoundingClientRect();
+    let chess = document.getElementById("chess");
+    let context = chess.getContext('2d');
+    let rect = chess.getBoundingClientRect();
     context.strokeStyle = '#bfbfbf';	//边框颜色
-    var chressBord = []; //棋盘
-    var whitechress = 10;
-    var blackchress = 20;
-    var whiteactive = 11;
-    var blackactive = 21;
-    var nochress = 0;
-    var offset = 50;
-    var lineSpace = 100;
-    var chressSize = 30;
-    var round = {};
+    let chressBord = []; //棋盘
+    const whitechress = 10;
+    const blackchress = 20;
+    const whiteactive = 11;
+    const blackactive = 21;
+    const nochress = 0;
+    const offset = 50;
+    const lineSpace = 100;
+    const chressSize = 30;
+    let round = {};
     Object.defineProperties(round, {
         isWhite: {
             configurable: true,
@@ -51,13 +54,13 @@
         }
     });
     round.isWhite = true;
-    var activeChress = false;
-    var ax;
-    var ay;
-    var ac;
-    for (var x = 0; x < 5; x++) {
+    let activeChress = false;
+    let ax;
+    let ay;
+    let ac;
+    for (let x = 0; x < 5; x++) {
         chressBord[x] = [];
-        for (var y = 0; y < 5; y++) {
+        for (let y = 0; y < 5; y++) {
             if (y == 0) {
                 chressBord[x][y] = whitechress;
             } else if (y == 4) {
@@ -102,7 +105,6 @@
                 ax = xx;
                 ay = yy;
             } else {
-                console.info(round.isWhite);
                 if (round.isWhite ^ (ac === whitechress)) {
                     //走棋  一次只能走一步
                     if (Math.abs(ax - xx) + Math.abs(ay - yy) === 1) {
@@ -111,6 +113,7 @@
                         activeChress = false;
                         round.isWhite = !round.isWhite;
                         horizontalEat(xx, yy);
+                        verticalEat(xx, yy);
                     } else {
                         alert("一次只能走一步");
                     }
@@ -121,7 +124,7 @@
         } else {
             //如果没有棋子选中,那么说明现在在选棋子
             //如果选中黑棋
-            if (chressBord[xx][yy] == blackchress) {
+            if (chressBord[xx][yy] === blackchress) {
                 chressBord[xx][yy] = blackactive;
                 activeChress = true;
                 ac = blackchress;
@@ -140,7 +143,7 @@
         clearCanvas();
         drawChessBoard();
         drawChress();
-    };
+    }
     //绘画棋盘
     var drawChessBoard = function () {
         for (var i = 0; i < 5; i++) {
@@ -154,8 +157,8 @@
     }
 
     function drawChress() {
-        for (var x = 0; x < 5; x++) {
-            for (var y = 0; y < 5; y++) {
+        for (let x = 0; x < 5; x++) {
+            for (let y = 0; y < 5; y++) {
                 if (chressBord[x][y] == whitechress) {
                     oneStep(x, y, true, false);
                 }
@@ -178,9 +181,9 @@
         context.arc(offset + i * lineSpace, offset + j * lineSpace, chressSize, 0, 2 * Math.PI);// 画圆
         context.closePath();
         //渐变
-        var gradient = context.createRadialGradient(offset + i * lineSpace
+        let gradient = context.createRadialGradient(offset + i * lineSpace
             + 2, offset + j * lineSpace - 2, chressSize, offset + i * lineSpace + 2, offset + j * lineSpace -
-            2, 0);
+        2, 0);
         if (isWhite) {
             gradient.addColorStop(0, '#0a0a0a');
             gradient.addColorStop(1, '#636766');
@@ -210,34 +213,133 @@
         context.restore();
     }
 
-    //检测横向吃子
+    function rule() {
+        whiteCount = 0;
+        blackCount = 0;
+        for (let i = 0; i <= 4; i++) {
+            for (let j = 0; j <= 4; j++) {
+                if (chressBord[i][j] == blackchress || chressBord[i][j] == blackactive) {
+                    blackCount++;
+                }
+                if (chressBord[i][j] == whitechress || chressBord[i][j] == whiteactive) {
+                    whiteCount++;
+                }
+            }
+        }
+        if (whiteCount < 2) {
+            alert("黑棋赢");
+            //location.reload();
+        }
+        if (blackCount < 2) {
+            alert("白棋赢");
+            //location.reload();
+        }
+    }
+    //检测横向吃子,y固定
     function horizontalEat(x, y) {
-        if (chressBord[x][y] == whitechress) {
-            let t1 = [0, 0, 10, 10, 20];
-            let t2 = [0, 10, 10, 20, 0];
-            let t3 = [10, 10, 20, 0, 0];
-            let t4 = [20, 10, 10, 0, 0];
-            let t5 = [0, 20, 10, 10, 0];
-            let t6 = [0, 0, 20, 10, 10];
-            if (chressBord[x] == t1) {
-                console.log("ok");
-            }
-            //吃子状态
-            //00 00 10 10 20
-            //00 10 10 20 00
-            //10 10 20 00 00
-            //20 10 10 00 00
-            //00 20 10 10 00
-            //00 00 20 10 10
-
-        } else if (chressBord[x][y] == blackchress) {
-
+        let blackCount = 0;
+        let whiteCount = 0;
+        let min = -1;
+        let max = -1;
+        let whiteX = -1;
+        let blackX = -1;
+        for (let i = 0; i <= 4; i++) {
+            if (chressBord[i][y] == nochress) {
+                continue;
+            }
+            if (chressBord[i][y] == blackchress) {
+                blackCount++;
+                if (min == -1) {
+                    min = i;
+                }
+                if (max < i) {
+                    max = i;
+                }
+                blackX = i;
+            }
+            if (chressBord[i][y] == whitechress) {
+                whiteCount++;
+                if (min == -1) {
+                    min = i;
+                }
+                if (max < i) {
+                    max = i;
+                }
+                whiteX = i;
+            }
+        }
+        if (chressBord[min][y] == chressBord[max][y]) {
+            return;
+        }
+        if (min + 2 != max) {
+            return;
+        }
+        if ((blackCount + whiteCount != 3) || (blackCount * whiteCount != 2)) {
+            return;
+        }
+        if (blackCount > whiteCount) {
+            if (!round.isWhite) {
+                chressBord[whiteX][y] = nochress
+            }
+        } else {
+            if (round.isWhite) {
+                chressBord[blackX][y] = nochress
+            }
         }
     }
 
-    //检测纵向吃子
+    //检测纵向吃子 x固定
     function verticalEat(x, y) {
-
+        let blackCount = 0;
+        let whiteCount = 0;
+        let min = -1;
+        let max = -1;
+        let whiteY = -1;
+        let blackY = -1;
+        for (let i = 0; i <= 4; i++) {
+            if (chressBord[x][i] == nochress) {
+                continue;
+            }
+            if (chressBord[x][i] == blackchress) {
+                blackCount++;
+                if (min == -1) {
+                    min = i;
+                }
+                if (max < i) {
+                    max = i;
+                }
+                blackY = i;
+            }
+            if (chressBord[x][i] == whitechress) {
+                whiteCount++;
+                if (min == -1) {
+                    min = i;
+                }
+                if (max < i) {
+                    max = i;
+                }
+                whiteY = i;
+            }
+        }
+        if (chressBord[x][min] == chressBord[x][max]) {
+            return;
+        }
+        if (min + 2 != max) {
+            return;
+        }
+        if ((blackCount + whiteCount != 3) || (blackCount * whiteCount != 2)) {
+            return;
+        }
+        if (blackCount > whiteCount) {
+            if (!round.isWhite) {
+                chressBord[x][whiteY] = nochress
+            }
+        } else {
+            if (round.isWhite) {
+                chressBord[x][blackY] = nochress
+            }
+        }
     }
 </script>
-</html>
+
+</html>

+ 0 - 337
five-line.html

@@ -1,337 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
-    <title>五道</title>
-    <style>
-        body {
-            background-color: transparent;
-        }
-
-        table {
-            border-spacing: 0px;
-        }
-
-        tr, td {
-            width: 100px;
-            height: 100px;
-        }
-
-        .ca {
-            background-color: aliceblue;
-        }
-
-        .cb {
-            background-color: navajowhite;
-        }
-
-        .qizihei {
-            background-image: radial-gradient(#917d7d, #292828, #270a0a);
-        }
-
-        .qizibai {
-            background-image: radial-gradient(white, #6d5454);
-        }
-
-        .qizi {
-            position: absolute;
-            width: 50px;
-            height: 50px;
-            display: block;
-            border-radius: 50%
-        }
-
-        .qizibaiActive {
-            background-image: radial-gradient(white, #cccccc);
-        }
-
-        .qiziheiActive {
-            background-image: radial-gradient(black, #cccccc);
-        }
-
-        .cx1 {
-            left: 75px;
-        }
-
-        .cx2 {
-            left: 175px;
-        }
-
-        .cx3 {
-            left: 275px;
-        }
-
-        .cx4 {
-            left: 375px;
-        }
-
-        .cx5 {
-            left: 475px;
-        }
-
-        .cy1 {
-            top: 75px;
-        }
-
-        .cy2 {
-            top: 50px;
-        }
-
-        .cy3 {
-            top: 100px;
-        }
-
-        .cy4 {
-            top: 150px;
-        }
-
-        .cy5 {
-            top: 475px;
-        }
-
-        ul {
-            margin: auto;
-            list-style: none;
-        }
-
-        li {
-            margin: 10px;
-            display: inline;
-            line-height: 40px;
-            float: left
-        }
-        .btn{
-            background-color: #6d5454;
-            border-radius: 45%;
-            padding: auto;
-            width: 100px;
-            text-align: center;
-            color: white;
-            cursor: pointer;
-            user-select:none;
-        }
-    </style>
-    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
-</head>
-<body>
-<div style="margin:100px 90px">
-    <table>
-        <div class="qizi qizihei cx1 cy5">
-        </div>
-        <div class="qizi qizihei cx2 cy5">
-        </div>
-        <div class="qizi qizihei cx3 cy5">
-        </div>
-        <div class="qizi qizihei cx4 cy5">
-        </div>
-        <div class="qizi qizihei cx5 cy5">
-        </div>
-        <div class="qizi qizibai cx1 cy1">
-        </div>
-        <div class="qizi qizibai cx2 cy1">
-        </div>
-        <div class="qizi qizibai cx3 cy1">
-        </div>
-        <div class="qizi qizibai cx4 cy1">
-        </div>
-        <div class="qizi qizibai cx5 cy1">
-        </div>
-        <tr>
-            <td class="ca">
-            </td>
-            <td class="cb">
-            </td>
-            <td class="ca">
-            </td>
-            <td class="cb">
-            </td>
-        </tr>
-        <tr>
-            <td class="cb"></td>
-            <td class="ca"></td>
-            <td class="cb"></td>
-            <td class="ca"></td>
-        </tr>
-        <tr>
-            <td class="ca"></td>
-            <td class="cb"></td>
-            <td class="ca"></td>
-            <td class="cb"></td>
-        </tr>
-        <tr>
-            <td class="cb"></td>
-            <td class="ca"></td>
-            <td class="cb"></td>
-            <td class="ca"></td>
-        </tr>
-    </table>
-    <div style="height: 50px"></div>
-    <ul>
-        <li class="btn">开始游戏</li>
-        <li class="btn">重新开始</li>
-        <li class="btn"> 悔 棋 </li>
-    </ul>
-</div>
-<canvas id="chess" width="450px" height="450px"></canvas>
-
-<script>
-    var qipan = {};
-    var baiqi = 1;
-    var heiqi = 0;
-    var max = 475;
-    var min = 75;
-    var token = true;
-    for (var i = 75; i <= 475; i += 100) {
-        for (var j = 75; j <= 475; j += 100) {
-            if (j == 75) {
-                qipan[i + "h,v" + j] = baiqi;
-            } else if (j == 475) {
-                qipan[i + "h,v" + j] = heiqi;
-            } else {
-                qipan[i + "h,v" + j] = -1;
-            }
-
-        }
-    }
-    var activeQizi;
-    $(".qizi").on("click", function (event) {
-        event.stopPropagation();
-        if ($(this).hasClass("qizihei")) {
-            $(this).toggleClass("qiziheiActive");
-        } else {
-            $(this).toggleClass("qizibaiActive");
-        }
-        if ($(this).hasClass("qiziheiActive") || $(this).hasClass("qizibaiActive")) {
-            activeQizi = this;
-        } else {
-            activeQizi = null;
-        }
-        init(this);
-    });
-
-    $("html").on("click", function (e) {
-        if (activeQizi) {
-            var top = $(activeQizi).css("top").split("px")[0];
-            var left = $(activeQizi).css("left").split("px")[0];
-            if (Math.abs(e.pageY - top) > Math.abs(e.pageX - left)) {
-                if (e.pageY > top) {
-                    toDown();//下
-                } else {
-                    toUp();//上
-                }
-            } else {
-                if (e.pageX > left) {
-                    toRight();//右
-                } else {
-                    toLeft();//左
-                }
-            }
-            //TODO 发送后台
-        }
-        activeQizi = null;
-        init();
-    });
-
-    function init(_this) {
-        $(".qizi").each(function (index, value) {
-            if (this != _this && $(this).hasClass("qiziheiActive")) {
-                $(this).toggleClass("qiziheiActive");
-            } else if (this != _this && $(this).hasClass("qizibaiActive")) {
-                $(this).toggleClass("qizibaiActive");
-            }
-        });
-    }
-
-    function eat(_this) {
-
-    }
-
-    function move(direction) {
-        if (!token) {
-            return;
-        }
-        if ('left,right,up,down'.indexOf(direction) == -1) {
-            console.error('api调用错误,没有' + direction + '方法');
-            return;
-        }
-        //将操作符 上下左右 转化为  left +- top+-操作
-        let subtraction = true;
-        if (direction === 'left') {
-            subtraction = true;
-            direction = 'left';
-        }
-        if (direction === 'right') {
-            subtraction = false;
-            direction = 'left';
-        }
-        if (direction === 'up') {
-            subtraction = true;
-            direction = 'top';
-        }
-        if (direction === 'down') {
-            subtraction = false;
-            direction = 'top';
-        }
-        let directionVar = $(activeQizi).css(direction).split("px")[0];
-
-
-        let oldX = $(activeQizi).css('left').split("px")[0];
-        let oldY = $(activeQizi).css('top').split("px")[0];
-
-        if ((subtraction && directionVar == min) || (!subtraction && directionVar == max)) {
-            alert("出界!");
-            return;
-        }
-        if (subtraction) {
-            directionVar = directionVar * 1 - 100;
-        } else {
-            directionVar = directionVar * 1 + 100;
-        }
-
-        if (direction === 'left') {
-            let directionVarAn = $(activeQizi).css('top').split("px")[0];
-            if (qipan[directionVar + "h,v" + directionVarAn] != -1) {
-                alert("此处有棋子");
-                return;
-            }
-            if ($(activeQizi).hasClass('qizibai')) {
-                qipan[directionVar+"h,v"+directionVarAn] = 1;
-            }else{
-                qipan[directionVar+"h,v"+directionVarAn] = 0;
-            }
-        } else {
-            let directionVarAn = $(activeQizi).css('left').split("px")[0];
-            if (qipan[directionVarAn + "h,v" + directionVar] != -1) {
-                alert("此处有棋子");
-                return;
-            }
-            if ($(activeQizi).hasClass('qizibai')) {
-                qipan[directionVar+"h,v"+directionVarAn] = 1;
-            }else{
-                qipan[directionVar+"h,v"+directionVarAn] = 0;
-            }
-
-        }
-        qipan[oldY+"h,v"+oldX] = -1;
-        $(activeQizi).css(direction, directionVar + "px");
-    }
-
-    function toLeft() {
-        move('left');
-    }
-
-    function toRight() {
-        move('right');
-    }
-
-    function toUp() {
-        move('up');
-    }
-
-    function toDown() {
-        move('down');
-    }
-</script>
-</body>
-</html>

+ 22 - 0
houses.html

@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
+    <title>蒙古小游戏-五道</title>
+</head>
+
+<body>
+    <a href="five-line-canvas.html">创建房间</a>
+    <h1>选择房间</h1>
+    <ul>
+        <li><a>房间1</a></li>
+        <li><a>房间2</a></li>
+        <li><a>房间3</a></li>
+        <li><a>房间4</a></li>
+        <li><a>房间5</a></li>
+    </ul>
+</body>
+
+</html>

+ 17 - 0
index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
+    <title>蒙古小游戏</title>
+</head>
+
+<body>
+    <h1>选择游戏</h1>
+    <ul>
+        <li><a href="houses.html">五道</a></li>
+    </ul>
+</body>
+
+</html>