├── static └── .gitkeep ├── .eslintignore ├── config ├── prod.env.js ├── dev.env.js └── index.js ├── src ├── assets │ ├── board.png │ ├── logo.png │ └── pieces │ │ ├── 1 │ │ ├── j.png │ │ ├── k.png │ │ ├── m.png │ │ ├── p.png │ │ ├── s.png │ │ ├── x.png │ │ └── z.png │ │ └── -1 │ │ ├── j.png │ │ ├── k.png │ │ ├── m.png │ │ ├── p.png │ │ ├── s.png │ │ ├── x.png │ │ └── z.png ├── game │ ├── utils.js │ ├── piece.js │ ├── index.js │ ├── robot.js │ └── rule.js ├── router │ └── index.js ├── main.js ├── App.vue ├── components │ └── HelloWorld.vue └── pages │ └── index.vue ├── .editorconfig ├── .gitignore ├── .babelrc ├── .postcssrc.js ├── index.html ├── README.md ├── dist ├── index.html └── static │ └── js │ ├── manifest.3ad1d5771e9b13dbdad2.js │ ├── manifest.3ad1d5771e9b13dbdad2.js.map │ ├── app.1706df7922e4f82bbd59.js │ └── app.1706df7922e4f82bbd59.js.map ├── .eslintrc.js └── package.json /static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /config/ 3 | /dist/ 4 | /*.js 5 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /src/assets/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/board.png -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /src/assets/pieces/1/j.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/1/j.png -------------------------------------------------------------------------------- /src/assets/pieces/1/k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/1/k.png -------------------------------------------------------------------------------- /src/assets/pieces/1/m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/1/m.png -------------------------------------------------------------------------------- /src/assets/pieces/1/p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/1/p.png -------------------------------------------------------------------------------- /src/assets/pieces/1/s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/1/s.png -------------------------------------------------------------------------------- /src/assets/pieces/1/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/1/x.png -------------------------------------------------------------------------------- /src/assets/pieces/1/z.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/1/z.png -------------------------------------------------------------------------------- /src/assets/pieces/-1/j.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/-1/j.png -------------------------------------------------------------------------------- /src/assets/pieces/-1/k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/-1/k.png -------------------------------------------------------------------------------- /src/assets/pieces/-1/m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/-1/m.png -------------------------------------------------------------------------------- /src/assets/pieces/-1/p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/-1/p.png -------------------------------------------------------------------------------- /src/assets/pieces/-1/s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/-1/s.png -------------------------------------------------------------------------------- /src/assets/pieces/-1/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/-1/x.png -------------------------------------------------------------------------------- /src/assets/pieces/-1/z.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodyWang1994/chinese-chess/HEAD/src/assets/pieces/-1/z.png -------------------------------------------------------------------------------- /src/game/utils.js: -------------------------------------------------------------------------------- 1 | // 检查两个数组有没有相同的值 2 | export function checkSameItem (arr1, arr2) { 3 | return !!arr1.find(i => { 4 | return arr2.indexOf(i) > -1 5 | }) 6 | } 7 | -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log* 4 | yarn-debug.log* 5 | yarn-error.log* 6 | 7 | # Editor directories and files 8 | .idea 9 | .vscode 10 | *.suo 11 | *.ntvs* 12 | *.njsproj 13 | *.sln 14 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins": ["transform-vue-jsx", "transform-runtime"] 12 | } 13 | -------------------------------------------------------------------------------- /.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Index from '@/pages/index' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'Index', 12 | component: Index 13 | } 14 | ] 15 | }) 16 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | chinese-chess 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import App from './App' 5 | import router from './router' 6 | 7 | Vue.config.productionTip = false 8 | 9 | /* eslint-disable no-new */ 10 | new Vue({ 11 | el: '#app', 12 | router, 13 | components: { App }, 14 | template: '' 15 | }) 16 | -------------------------------------------------------------------------------- /src/game/piece.js: -------------------------------------------------------------------------------- 1 | class Piece { 2 | constructor (name, position, camp) { 3 | // camp: 阵营,-1黑,1红,0空白 4 | this.name = name 5 | this.position = position 6 | this.camp = camp || 0 7 | this.died = 0 8 | } 9 | } 10 | 11 | Piece.prototype.moveTo = function (newPos) { 12 | this.position = newPos 13 | } 14 | 15 | Piece.prototype.copy = function () { 16 | return new Piece(this.name, this.position, this.camp) 17 | } 18 | 19 | export default Piece 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chinese-chess 2 | 3 | > 中国象棋 4 | 5 | ## 介绍 6 | 7 | ``` bash 8 | 目前仅支持双人对战,后续有时间会加入人机对战 9 | ``` 10 | 11 | ## 预览 12 | 13 | https://kodywang1994.github.io/chinese-chess/dist/index.html 14 | 15 | ## Task List 16 | 17 | - ~~增加规则~~ 18 | - ~~增加悔棋~~ 19 | - 增加人机对战(开发中) 20 | - 增加下一步建议 21 | - ... 22 | 23 | ## 更多游戏 24 | 25 | https://kodywang1994.github.io/game-box/dist/index.html 26 | 27 | https://github.com/kodyWang1994/game-box 28 | 29 | https://github.com/kodyWang1994/game-box-mp 30 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | chinese-chess
-------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 28 | 29 | 36 | -------------------------------------------------------------------------------- /dist/static/js/manifest.3ad1d5771e9b13dbdad2.js: -------------------------------------------------------------------------------- 1 | !function(r){var n=window.webpackJsonp;window.webpackJsonp=function(e,u,c){for(var f,i,p,a=0,l=[];a", 6 | "private": true, 7 | "scripts": { 8 | "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", 9 | "start": "npm run dev", 10 | "lint": "eslint --ext .js,.vue src", 11 | "build": "node build/build.js" 12 | }, 13 | "dependencies": { 14 | "underscore": "^1.12.0", 15 | "vue": "^2.5.2", 16 | "vue-router": "^3.0.1" 17 | }, 18 | "devDependencies": { 19 | "autoprefixer": "^7.1.2", 20 | "babel-core": "^6.22.1", 21 | "babel-eslint": "^8.2.1", 22 | "babel-helper-vue-jsx-merge-props": "^2.0.3", 23 | "babel-loader": "^7.1.1", 24 | "babel-plugin-syntax-jsx": "^6.18.0", 25 | "babel-plugin-transform-runtime": "^6.22.0", 26 | "babel-plugin-transform-vue-jsx": "^3.5.0", 27 | "babel-preset-env": "^1.3.2", 28 | "babel-preset-stage-2": "^6.22.0", 29 | "chalk": "^2.0.1", 30 | "copy-webpack-plugin": "^4.0.1", 31 | "css-loader": "^0.28.0", 32 | "eslint": "^4.15.0", 33 | "eslint-config-standard": "^10.2.1", 34 | "eslint-friendly-formatter": "^3.0.0", 35 | "eslint-loader": "^1.7.1", 36 | "eslint-plugin-import": "^2.7.0", 37 | "eslint-plugin-node": "^5.2.0", 38 | "eslint-plugin-promise": "^3.4.0", 39 | "eslint-plugin-standard": "^3.0.1", 40 | "eslint-plugin-vue": "^4.0.0", 41 | "extract-text-webpack-plugin": "^3.0.0", 42 | "file-loader": "^1.1.4", 43 | "friendly-errors-webpack-plugin": "^1.6.1", 44 | "html-webpack-plugin": "^2.30.1", 45 | "node-notifier": "^5.1.2", 46 | "optimize-css-assets-webpack-plugin": "^3.2.0", 47 | "ora": "^1.2.0", 48 | "portfinder": "^1.0.13", 49 | "postcss-import": "^11.0.0", 50 | "postcss-loader": "^2.0.8", 51 | "postcss-url": "^7.2.1", 52 | "rimraf": "^2.6.0", 53 | "semver": "^5.3.0", 54 | "shelljs": "^0.7.6", 55 | "uglifyjs-webpack-plugin": "^1.1.1", 56 | "url-loader": "^0.5.8", 57 | "vue-loader": "^13.3.0", 58 | "vue-style-loader": "^3.0.1", 59 | "vue-template-compiler": "^2.5.2", 60 | "webpack": "^3.6.0", 61 | "webpack-bundle-analyzer": "^2.9.0", 62 | "webpack-dev-server": "^2.9.1", 63 | "webpack-merge": "^4.1.0" 64 | }, 65 | "engines": { 66 | "node": ">= 6.0.0", 67 | "npm": ">= 3.0.0" 68 | }, 69 | "browserslist": [ 70 | "> 1%", 71 | "last 2 versions", 72 | "not ie <= 8" 73 | ] 74 | } 75 | -------------------------------------------------------------------------------- /src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 85 | 86 | 96 | 97 | 98 | 114 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.3.1 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | 10 | // Paths 11 | assetsSubDirectory: 'static', 12 | assetsPublicPath: '/', 13 | proxyTable: {}, 14 | 15 | // Various Dev Server settings 16 | host: 'localhost', // can be overwritten by process.env.HOST 17 | port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 18 | autoOpenBrowser: false, 19 | errorOverlay: true, 20 | notifyOnErrors: true, 21 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 22 | 23 | // Use Eslint Loader? 24 | // If true, your code will be linted during bundling and 25 | // linting errors and warnings will be shown in the console. 26 | useEslint: true, 27 | // If true, eslint errors and warnings will also be shown in the error overlay 28 | // in the browser. 29 | showEslintErrorsInOverlay: false, 30 | 31 | /** 32 | * Source Maps 33 | */ 34 | 35 | // https://webpack.js.org/configuration/devtool/#development 36 | devtool: 'cheap-module-eval-source-map', 37 | 38 | // If you have problems debugging vue-files in devtools, 39 | // set this to false - it *may* help 40 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 41 | cacheBusting: true, 42 | 43 | cssSourceMap: true 44 | }, 45 | 46 | build: { 47 | // Template for index.html 48 | index: path.resolve(__dirname, '../dist/index.html'), 49 | 50 | // Paths 51 | assetsRoot: path.resolve(__dirname, '../dist'), 52 | assetsSubDirectory: 'static', 53 | assetsPublicPath: './', 54 | 55 | /** 56 | * Source Maps 57 | */ 58 | 59 | productionSourceMap: true, 60 | // https://webpack.js.org/configuration/devtool/#production 61 | devtool: '#source-map', 62 | 63 | // Gzip off by default as many popular static hosts such as 64 | // Surge or Netlify already gzip all static assets for you. 65 | // Before setting to `true`, make sure to: 66 | // npm install --save-dev compression-webpack-plugin 67 | productionGzip: false, 68 | productionGzipExtensions: ['js', 'css'], 69 | 70 | // Run the build command with an extra argument to 71 | // View the bundle analyzer report after build finishes: 72 | // `npm run build --report` 73 | // Set to `true` or `false` to always turn it on or off 74 | bundleAnalyzerReport: process.env.npm_config_report 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/game/index.js: -------------------------------------------------------------------------------- 1 | import Piece from './piece' 2 | 3 | class Game { 4 | constructor () { 5 | console.log('constructor') 6 | this.blankMap = [] 7 | this.redPieces = [] 8 | this.blackPieces = [] 9 | } 10 | 11 | initGame () { 12 | console.log('init') 13 | this.blankMap = this.initBlankMap() 14 | this.redPieces = this.initRedPieces() 15 | this.blackPieces = this.initBlackPieces() 16 | } 17 | 18 | getBlankMap () { 19 | return this.blankMap 20 | } 21 | 22 | getRedPieces () { 23 | return this.redPieces 24 | } 25 | 26 | getBlackPieces () { 27 | return this.blackPieces 28 | } 29 | 30 | getAllPieces () { 31 | return [...this.redPieces, ...this.blackPieces] 32 | } 33 | 34 | // 获取位置上的棋子 35 | getPieceByPosition (position) { 36 | const allPieces = this.getAllPieces() 37 | const piece = allPieces.find(piece => { 38 | return piece.position.toString() === position.toString() 39 | }) 40 | if (piece) return piece 41 | return this.getBlankMap().find(piece => { 42 | return piece.position.toString() === position.toString() 43 | }) 44 | } 45 | 46 | initBlankMap = function () { 47 | const map = [] 48 | 49 | for (let x = 1; x <= 9; x++) { 50 | for (let y = 10; y > 0; y--) { 51 | // 生成空白棋盘 52 | map.push(new Piece('', [x, y], 0)) 53 | } 54 | } 55 | return map 56 | } 57 | 58 | initRedPieces = function () { 59 | return [ 60 | new Piece('j1', [1, 1], 1), // 车 61 | new Piece('j2', [9, 1], 1), // 车 62 | new Piece('p1', [2, 3], 1), // 炮 63 | new Piece('p2', [8, 3], 1), // 炮 64 | new Piece('m1', [2, 1], 1), // 马 65 | new Piece('m2', [8, 1], 1), // 马 66 | new Piece('x1', [3, 1], 1), // 相 67 | new Piece('x2', [7, 1], 1), // 相 68 | new Piece('s1', [4, 1], 1), // 士 69 | new Piece('s2', [6, 1], 1), // 士 70 | new Piece('z1', [1, 4], 1), // 兵 71 | new Piece('z2', [3, 4], 1), // 兵 72 | new Piece('z3', [5, 4], 1), // 兵 73 | new Piece('z4', [7, 4], 1), // 兵 74 | new Piece('z5', [9, 4], 1), // 兵 75 | new Piece('k', [5, 1], 1) // 帅 76 | ] 77 | } 78 | 79 | initBlackPieces = function () { 80 | return [ 81 | new Piece('j1', [1, 10], -1), 82 | new Piece('j2', [9, 10], -1), 83 | new Piece('p1', [2, 8], -1), 84 | new Piece('p2', [8, 8], -1), 85 | new Piece('m1', [2, 10], -1), 86 | new Piece('m2', [8, 10], -1), 87 | new Piece('x1', [3, 10], -1), 88 | new Piece('x2', [7, 10], -1), 89 | new Piece('s1', [4, 10], -1), 90 | new Piece('s2', [6, 10], -1), 91 | new Piece('z1', [1, 7], -1), 92 | new Piece('z2', [3, 7], -1), 93 | new Piece('z3', [5, 7], -1), 94 | new Piece('z4', [7, 7], -1), 95 | new Piece('z5', [9, 7], -1), 96 | new Piece('k', [5, 10], -1) 97 | ] 98 | } 99 | } 100 | 101 | export default new Game() 102 | -------------------------------------------------------------------------------- /dist/static/js/manifest.3ad1d5771e9b13dbdad2.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap 1bb5b4cb54263c15ef72"],"names":["parentJsonpFunction","window","chunkIds","moreModules","executeModules","moduleId","chunkId","result","i","resolves","length","installedChunks","push","Object","prototype","hasOwnProperty","call","modules","shift","__webpack_require__","s","installedModules","2","exports","module","l","m","c","d","name","getter","o","defineProperty","configurable","enumerable","get","n","__esModule","object","property","p","oe","err","console","error"],"mappings":"aACA,IAAAA,EAAAC,OAAA,aACAA,OAAA,sBAAAC,EAAAC,EAAAC,GAIA,IADA,IAAAC,EAAAC,EAAAC,EAAAC,EAAA,EAAAC,KACQD,EAAAN,EAAAQ,OAAoBF,IAC5BF,EAAAJ,EAAAM,GACAG,EAAAL,IACAG,EAAAG,KAAAD,EAAAL,GAAA,IAEAK,EAAAL,GAAA,EAEA,IAAAD,KAAAF,EACAU,OAAAC,UAAAC,eAAAC,KAAAb,EAAAE,KACAY,EAAAZ,GAAAF,EAAAE,IAIA,IADAL,KAAAE,EAAAC,EAAAC,GACAK,EAAAC,QACAD,EAAAS,OAAAT,GAEA,GAAAL,EACA,IAAAI,EAAA,EAAYA,EAAAJ,EAAAM,OAA2BF,IACvCD,EAAAY,IAAAC,EAAAhB,EAAAI,IAGA,OAAAD,GAIA,IAAAc,KAGAV,GACAW,EAAA,GAIA,SAAAH,EAAAd,GAGA,GAAAgB,EAAAhB,GACA,OAAAgB,EAAAhB,GAAAkB,QAGA,IAAAC,EAAAH,EAAAhB,IACAG,EAAAH,EACAoB,GAAA,EACAF,YAUA,OANAN,EAAAZ,GAAAW,KAAAQ,EAAAD,QAAAC,IAAAD,QAAAJ,GAGAK,EAAAC,GAAA,EAGAD,EAAAD,QAKAJ,EAAAO,EAAAT,EAGAE,EAAAQ,EAAAN,EAGAF,EAAAS,EAAA,SAAAL,EAAAM,EAAAC,GACAX,EAAAY,EAAAR,EAAAM,IACAhB,OAAAmB,eAAAT,EAAAM,GACAI,cAAA,EACAC,YAAA,EACAC,IAAAL,KAMAX,EAAAiB,EAAA,SAAAZ,GACA,IAAAM,EAAAN,KAAAa,WACA,WAA2B,OAAAb,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,OADAL,EAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAO,EAAAC,GAAsD,OAAA1B,OAAAC,UAAAC,eAAAC,KAAAsB,EAAAC,IAGtDpB,EAAAqB,EAAA,KAGArB,EAAAsB,GAAA,SAAAC,GAA8D,MAApBC,QAAAC,MAAAF,GAAoBA","file":"static/js/manifest.3ad1d5771e9b13dbdad2.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t2: 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"./\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 1bb5b4cb54263c15ef72"],"sourceRoot":""} -------------------------------------------------------------------------------- /src/game/robot.js: -------------------------------------------------------------------------------- 1 | import Game from './index' 2 | import Rule from './rule' 3 | import _ from 'underscore' 4 | import { checkSameItem } from './utils' 5 | window._ = _ 6 | // 人机对战 7 | 8 | // 获取到我方每一个棋子可以行动的位置,优先走可以消除对方的棋子的,其次是可以保护我方棋子的 9 | 10 | // Tips 11 | // 解析棋盘局势,得到我方每个棋子的以下属性: 12 | // 可以走的位置,可以杀的棋子,可以保护的棋子,受保护的情况 13 | 14 | /** 15 | * 获取最佳可移动的棋子 16 | * @param {当前阵营} currentCamp 17 | * @return { 18 | needMovePiece: 需要移动的棋子 19 | targetPiece: 需要移动到的位置,可能为敌方的棋子 20 | canMovePositions: 可以移动的所有位置坐标,需要提供给棋盘进行可移动判定 21 | } 22 | */ 23 | export const getBestMovePiece = function (currentCamp) { 24 | // 获取到我方可以移动的棋子 25 | return getCampCanMovePiece(currentCamp) 26 | } 27 | 28 | /** 29 | * 获取对应阵营可以移动的棋子,优先进攻帅,其次是可以消除敌方的棋子 30 | * @param {当前阵营} currentCamp 31 | * @returns { 32 | canMovePositions: 所有可移动的坐标, 33 | needMovePiece: 当前可移动的棋子, 34 | targetPiece: 需要移动到的位置,可能为敌方棋子 35 | } 36 | */ 37 | function getCampCanMovePiece (currentCamp) { 38 | // 获取到敌方可能移动的棋子 39 | const enemyList = getCampCanMovePieceList(-currentCamp) 40 | // 敌方保护的棋子 41 | const enemySavePiecesPosition = _.flatten(_.pluck(enemyList.canMoveList, 'canSavePiecePositions')) 42 | // 敌方可以消除我方的棋子 43 | const enemyRemovePiecesPosition = _.flatten(_.pluck(enemyList.canMoveList, 'canRemovePiecePositions')) 44 | // 敌方可以移动的所有坐标 45 | const enemyCanMovePositions = _.flatten(_.pluck(enemyList.canMoveList, 'canMovePositions')) 46 | 47 | // 获取我方可移动的棋子 48 | const ownerList = getCampCanMovePieceList(currentCamp) 49 | // 我方保护的棋子 50 | const ownerSavePiecesPosition = _.flatten(_.pluck(ownerList.canMoveList, 'canSavePiecePositions')) 51 | // 我方可以消除敌方的棋子 52 | // const ownerRemovePiecesPosition = _.flatten(_.pluck(ownerList.canMoveList, 'canRemovePiecePositions')) 53 | // 如果可以杀帅,直接执行 54 | if (ownerList.king) return ownerList.king 55 | if (enemyList.king) { 56 | // 如果敌方将军,我们需要进行保护 TODO 57 | } 58 | const canMoveList = ownerList.canMoveList 59 | // 移动可以消除敌方的棋子, 排除被敌方保护的 60 | let canRemovePiece = null 61 | canMoveList.find(item => { 62 | // 如果我方当前棋子可以保护我方将要被消除的棋子,则不动 63 | if (checkSameItem(item.canSavePiecePositions, enemyRemovePiecesPosition)) return false 64 | return item.canRemovePieces.find(i => { 65 | // 敌方受保护的棋子不杀 66 | if (enemySavePiecesPosition.indexOf(i.position.toString()) === -1) { 67 | canRemovePiece = { 68 | canMovePositions: item.canMovePositions, 69 | ownerPiece: item.ownerPiece, 70 | canRemovePiece: i 71 | } 72 | return true 73 | } 74 | }) 75 | }) 76 | if (canRemovePiece) { 77 | return { 78 | canMovePositions: canRemovePiece.canMovePositions, 79 | needMovePiece: canRemovePiece.ownerPiece, 80 | targetPiece: canRemovePiece.canRemovePiece 81 | } 82 | } 83 | let canSavePiece = null 84 | // 移动我方棋子来保护即将被杀死的棋子 85 | enemyRemovePiecesPosition.find(position => { 86 | if (ownerSavePiecesPosition.indexOf(position) > -1) return false // 判断该位置是否受保护,如是,则无需处理 87 | // 如不受保护,则需要移动相应棋子保护该位置 88 | return canMoveList.find(item => { 89 | // 如果我方当前棋子可以保护我方将要被消除的棋子,则不动 90 | if (checkSameItem(item.canSavePiecePositions, enemyRemovePiecesPosition)) return false 91 | const nextPiece = getCanSavePiecePosition(item.ownerPiece, item.canMoveBlankPieces, position, enemyCanMovePositions) 92 | if (nextPiece) { 93 | canSavePiece = { 94 | canMovePositions: item.canMovePositions, 95 | ownerPiece: item.ownerPiece, 96 | canMovePiece: nextPiece 97 | } 98 | return true 99 | } 100 | }) 101 | }) 102 | if (canSavePiece) { 103 | return { 104 | canMovePositions: canSavePiece.canMovePositions, 105 | needMovePiece: canSavePiece.ownerPiece, 106 | targetPiece: canSavePiece.canMovePiece 107 | } 108 | } 109 | // 移动我方棋子到空白位置上 110 | let canMovePiece = null 111 | canMoveList.find(item => { 112 | // 如果我方当前棋子可以保护我方将要被消除的棋子,则不动 113 | if (checkSameItem(item.canSavePiecePositions, enemyRemovePiecesPosition)) return false 114 | const nextPiece = getCanSavePiecePosition(item.ownerPiece, item.canMoveBlankPieces, '', enemyCanMovePositions) 115 | if (nextPiece) { 116 | canMovePiece = { 117 | canMovePositions: item.canMovePositions, 118 | ownerPiece: item.ownerPiece, 119 | canMovePiece: nextPiece 120 | } 121 | return true 122 | } 123 | }) 124 | if (canMovePiece) { 125 | return { 126 | canMovePositions: canMovePiece.canMovePositions, 127 | needMovePiece: canMovePiece.ownerPiece, 128 | targetPiece: canMovePiece.canMovePiece 129 | } 130 | } 131 | } 132 | 133 | // 获取对应阵营所有可以移动的棋子列表 134 | function getCampCanMovePieceList (currentCamp) { 135 | const ownerPieces = currentCamp === 1 ? Game.getRedPieces() : Game.getBlackPieces() 136 | // const otherPieces = currentCamp === 1 ? Game.getBlackPieces() : Game.getRedPieces() 137 | let king = null 138 | const canMoveList = [] 139 | for (const ownerPiece of ownerPieces) { 140 | const canMovePositions = Rule.getMoveLine(ownerPiece) 141 | const canMovePieces = handlePosition(canMovePositions, currentCamp) 142 | if (canMovePieces.king) { 143 | // 如果有帅,直接return 144 | king = { 145 | canMovePositions, 146 | needMovePiece: ownerPiece, 147 | targetPiece: canMovePieces.king 148 | } 149 | } else { 150 | // 如果没有帅可以吃,就先把可以吃掉的棋子和可以移动的位置放入数组,等待循环结束后判定吃哪一个 151 | canMoveList.push({ 152 | ownerPiece, // 当前可以移动的棋子 153 | canRemovePieces: canMovePieces.others, // 可以消除敌方的棋子 154 | canMoveBlankPieces: canMovePieces.blanks, // 可以移动的空白位置 155 | canSavePieces: canMovePieces.owners, // 可以保护的我方棋子 156 | canMovePositions: canMovePositions, // 所有可以移动的坐标 157 | // 保护的棋子位置 158 | canSavePiecePositions: canMovePieces.owners.map((item) => item && item.position ? item.position.toString() : ''), 159 | // 可以消除的棋子位置 160 | canRemovePiecePositions: canMovePieces.others.map((item) => item && item.position ? item.position.toString() : ''), 161 | // 受保护的棋子 162 | savedByPieces: [] 163 | }) 164 | } 165 | } 166 | handleSavedByPieces(canMoveList) 167 | return { 168 | king, 169 | canMoveList 170 | } 171 | } 172 | 173 | // 组装数据,获取受保护的情况 174 | function handleSavedByPieces (canMoveList) { 175 | canMoveList.forEach(item => { 176 | for (const item2 of canMoveList) { 177 | if (item2.canSavePiecePositions.indexOf(item.ownerPiece.position.toString()) > -1) { 178 | item.savedByPieces.push(item2.ownerPiece) 179 | } 180 | } 181 | }) 182 | return canMoveList 183 | } 184 | 185 | // 获取移动后可以将军或保护其他棋子的位置 186 | function getCanSavePiecePosition (ownerPiece, canMoveBlankPieces, needSavePosition, enemyCanMovePositions) { 187 | return canMoveBlankPieces.find(item => { 188 | if (enemyCanMovePositions.indexOf(item.position.toString()) > -1) return false // 如果下一步有危险,则不行动 189 | const tempPiece = ownerPiece.copy() 190 | tempPiece.position = item.position // 模拟棋子移动下一步,获取下一步后可以行动的位置信息 191 | const canMovePositions = Rule.getMoveLine(tempPiece) 192 | const canMovePieces = handlePosition(canMovePositions, tempPiece.camp) 193 | if (canMovePieces.king) return true 194 | if (needSavePosition) { 195 | // 保护的棋子位置 196 | const canSavePiecePositions = canMovePieces.owners.map((item) => item && item.position ? item.position.toString() : '') 197 | if (canSavePiecePositions.indexOf(needSavePosition) > -1) return true 198 | } else { 199 | // 可以消除的棋子位置 200 | return canMovePieces.others.length > 0 201 | } 202 | }) 203 | } 204 | 205 | /** 206 | * 获取可以消除的对方棋子, 优先进攻帅 207 | * @param {所有可以移动的位置坐标} canMovePosition 208 | * @param {当前阵营} currentCamp 209 | * @returns { 210 | * king: null, // 帅 211 | * others: [], // 其他可以消除的棋子 212 | * owners: [], // 我方可以被保护的棋子 213 | * blanks: [] // 其他空白的棋子 214 | * } 215 | */ 216 | function handlePosition (canMovePosition, currentCamp) { 217 | let canMovePieces = { 218 | king: null, // 帅 219 | others: [], // 其他可以消除的棋子 220 | owners: [], // 我方可以被保护的棋子 221 | blanks: [] // 其他空白的棋子 222 | } 223 | for (const position of canMovePosition) { 224 | const piece = Game.getPieceByPosition(position) 225 | if (piece.camp === 0) { // 空白 226 | canMovePieces.blanks.push(piece) 227 | } else if (currentCamp !== piece.camp) { // 敌方阵营 228 | if (piece.name === 'k') { 229 | canMovePieces.king = piece // 帅 230 | } else { 231 | canMovePieces.others.push(piece) 232 | } 233 | } else if (currentCamp === piece.camp) { // 我方阵营 234 | canMovePieces.owners.push(piece) 235 | } 236 | } 237 | return canMovePieces 238 | } 239 | -------------------------------------------------------------------------------- /src/pages/index.vue: -------------------------------------------------------------------------------- 1 | 47 | 48 | 193 | 194 | 372 | -------------------------------------------------------------------------------- /src/game/rule.js: -------------------------------------------------------------------------------- 1 | import Game from '../game' 2 | import _ from 'underscore' 3 | 4 | // j1, j2 // 车 5 | // p1, p2 // 炮 6 | // m1, m2 // 马 7 | // x1, x2 // 相 8 | // s1, s2 // 士 9 | // z1, z2, z3, z4, z5 // 兵 10 | // k // 帅 11 | 12 | const getRuleTypeByName = function (name) { 13 | if (name.length > 1) { 14 | return name.substring(0, 1) 15 | } else { 16 | return name 17 | } 18 | } 19 | 20 | const getMoveLine = function (piece) { 21 | const ruleType = getRuleTypeByName(piece.name) 22 | let moveLine = [] 23 | switch (ruleType) { 24 | case 'z': // 兵 25 | moveLine = getZMoveLine(piece) 26 | break 27 | case 's': // 士 28 | moveLine = getSMoveLine(piece) 29 | break 30 | case 'k': // 帅 31 | moveLine = getKMoveLine(piece) 32 | break 33 | case 'j': // 军 34 | moveLine = getJMoveLine(piece) 35 | break 36 | case 'p': // 炮 37 | moveLine = getPMoveLine(piece) 38 | break 39 | case 'x': // 相 40 | moveLine = getXMoveLine(piece) 41 | break 42 | case 'm': // 马 43 | moveLine = getMMoveLine(piece) 44 | break 45 | } 46 | return moveLine 47 | } 48 | 49 | const canMove = function (piece, targetPiece, canMovePoint) { 50 | if (!canMovePoint || canMovePoint.length < 1) { 51 | // 如果还没有可移动的列表,则return 52 | return false 53 | } 54 | const positionStr = targetPiece.position.toString() 55 | for (const point of canMovePoint) { 56 | if (point.toString() === positionStr) { 57 | return true 58 | } 59 | } 60 | return false 61 | } 62 | 63 | // 兵的可移动路线 64 | const getZMoveLine = function (piece) { 65 | const position = piece.position 66 | const x = position[0] 67 | const y = position[1] 68 | const line = [] 69 | if (piece.camp === 1) { // 红方,棋盘在下方 70 | if (y <= 5) { 71 | line.push([x, y + 1]) // 只能前进一步 72 | } else { 73 | if (y !== 10) { 74 | // 可以前进一步 75 | line.push([x, y + 1]) 76 | } 77 | if (x !== 1) { 78 | // 可以左移一步 79 | line.push([x - 1, y]) 80 | } 81 | if (x !== 9) { 82 | // 可以右移一步 83 | line.push([x + 1, y]) 84 | } 85 | } 86 | } else { // 黑方,棋盘在上方 87 | if (y > 5) { 88 | line.push([x, y - 1]) // 只能前进一步 89 | } else { 90 | if (y !== 1) { 91 | // 可以前进一步 92 | line.push([x, y - 1]) 93 | } 94 | if (x !== 1) { 95 | // 可以左移一步 96 | line.push([x - 1, y]) 97 | } 98 | if (x !== 9) { 99 | // 可以右移一步 100 | line.push([x + 1, y]) 101 | } 102 | } 103 | } 104 | return line 105 | } 106 | 107 | // 士的可移动路线 108 | const getSMoveLine = function (piece) { 109 | const position = piece.position 110 | const x = position[0] 111 | const y = position[1] 112 | const line = [] 113 | if (piece.camp === 1) { // 红方,棋盘在下方 114 | if (x !== 4) { 115 | if (y !== 1) { 116 | line.push([x - 1, y - 1]) 117 | } 118 | if (y !== 3) { 119 | line.push([x - 1, y + 1]) 120 | } 121 | } 122 | if (x !== 6) { 123 | if (y !== 1) { 124 | line.push([x + 1, y - 1]) 125 | } 126 | if (y !== 3) { 127 | line.push([x + 1, y + 1]) 128 | } 129 | } 130 | } else { // 黑方,棋盘在上方 131 | if (x !== 4) { 132 | if (y !== 8) { 133 | line.push([x - 1, y - 1]) 134 | } 135 | if (y !== 10) { 136 | line.push([x - 1, y + 1]) 137 | } 138 | } 139 | if (x !== 6) { 140 | if (y !== 8) { 141 | line.push([x + 1, y - 1]) 142 | } 143 | if (y !== 10) { 144 | line.push([x + 1, y + 1]) 145 | } 146 | } 147 | } 148 | return line 149 | } 150 | 151 | // 将的可移动路线 152 | const getKMoveLine = function (piece) { 153 | const position = piece.position 154 | const x = position[0] 155 | const y = position[1] 156 | const line = [] 157 | if (piece.camp === 1) { // 红方,棋盘在下方 158 | if (y !== 3) { 159 | // 可以前进一步 160 | line.push([x, y + 1]) 161 | } 162 | if (y !== 1) { 163 | // 可以后退一步 164 | line.push([x, y - 1]) 165 | } 166 | if (x !== 4) { 167 | // 可以左移一步 168 | line.push([x - 1, y]) 169 | } 170 | if (x !== 6) { 171 | // 可以右移一步 172 | line.push([x + 1, y]) 173 | } 174 | } else { // 黑方,棋盘在上方 175 | if (y !== 10) { 176 | // 可以前进一步 177 | line.push([x, y + 1]) 178 | } 179 | if (y !== 8) { 180 | // 可以后退一步 181 | line.push([x, y - 1]) 182 | } 183 | if (x !== 4) { 184 | // 可以左移一步 185 | line.push([x - 1, y]) 186 | } 187 | if (x !== 6) { 188 | // 可以右移一步 189 | line.push([x + 1, y]) 190 | } 191 | } 192 | return line 193 | } 194 | 195 | // 相的可移动路线 196 | const getXMoveLine = function (piece) { 197 | const position = piece.position 198 | const x = position[0] 199 | const y = position[1] 200 | const line = [] 201 | 202 | // 获取所有棋子的位置 203 | const positionStrArr = getAllPiecePosition() 204 | 205 | if (piece.camp === 1) { // 红方,棋盘在下方 206 | if (x !== 1) { 207 | if (y !== 1 && positionStrArr.indexOf([x - 1, y - 1].toString()) < 0) { 208 | line.push([x - 2, y - 2]) 209 | } 210 | if (y !== 5 && positionStrArr.indexOf([x - 1, y + 1].toString()) < 0) { 211 | line.push([x - 2, y + 2]) 212 | } 213 | } 214 | if (x !== 9) { 215 | if (y !== 1 && positionStrArr.indexOf([x + 1, y - 1].toString()) < 0) { 216 | line.push([x + 2, y - 2]) 217 | } 218 | if (y !== 5 && positionStrArr.indexOf([x + 1, y + 1].toString()) < 0) { 219 | line.push([x + 2, y + 2]) 220 | } 221 | } 222 | } else { // 黑方,棋盘在上方 223 | if (x !== 1) { 224 | if (y !== 6 && positionStrArr.indexOf([x - 1, y - 1].toString()) < 0) { 225 | line.push([x - 2, y - 2]) 226 | } 227 | if (y !== 10 && positionStrArr.indexOf([x - 1, y + 1].toString()) < 0) { 228 | line.push([x - 2, y + 2]) 229 | } 230 | } 231 | if (x !== 9) { 232 | if (y !== 6 && positionStrArr.indexOf([x + 1, y - 1].toString()) < 0) { 233 | line.push([x + 2, y - 2]) 234 | } 235 | if (y !== 10 && positionStrArr.indexOf([x + 1, y + 1].toString()) < 0) { 236 | line.push([x + 2, y + 2]) 237 | } 238 | } 239 | } 240 | return line 241 | } 242 | 243 | // 军的可移动路线 244 | const getJMoveLine = function (piece) { 245 | const position = piece.position 246 | const x = position[0] 247 | const y = position[1] 248 | const line = [] 249 | 250 | // 获取所有棋子的位置 251 | const positionStrArr = getAllPiecePosition() 252 | // const piecesArr = Game.getAllPieces() 253 | 254 | if (x !== 9) { 255 | for (let xIndex = x + 1; xIndex <= 9; xIndex++) { 256 | const positionIndex = positionStrArr.indexOf([xIndex, y].toString()) 257 | if (positionIndex > -1) { 258 | // if (piecesArr[positionIndex].camp !== piece.camp) { 259 | line.push([xIndex, y]) 260 | // } 261 | break 262 | } 263 | line.push([xIndex, y]) 264 | } 265 | } 266 | if (x !== 1) { 267 | for (let xIndex = x - 1; xIndex >= 1; xIndex--) { 268 | const positionIndex = positionStrArr.indexOf([xIndex, y].toString()) 269 | if (positionIndex > -1) { 270 | // if (piecesArr[positionIndex].camp !== piece.camp) { 271 | line.push([xIndex, y]) 272 | // } 273 | break 274 | } 275 | line.push([xIndex, y]) 276 | } 277 | } 278 | if (y !== 10) { 279 | for (let yIndex = y + 1; yIndex <= 10; yIndex++) { 280 | const positionIndex = positionStrArr.indexOf([x, yIndex].toString()) 281 | if (positionIndex > -1) { 282 | // if (piecesArr[positionIndex].camp !== piece.camp) { 283 | line.push([x, yIndex]) 284 | // } 285 | break 286 | } 287 | line.push([x, yIndex]) 288 | } 289 | } 290 | if (y !== 1) { 291 | for (let yIndex = y - 1; yIndex >= 1; yIndex--) { 292 | const positionIndex = positionStrArr.indexOf([x, yIndex].toString()) 293 | if (positionIndex > -1) { 294 | // if (piecesArr[positionIndex].camp !== piece.camp) { 295 | line.push([x, yIndex]) 296 | // } 297 | break 298 | } 299 | line.push([x, yIndex]) 300 | } 301 | } 302 | return line 303 | } 304 | 305 | // 马的可移动路线 306 | const getMMoveLine = function (piece) { 307 | const position = piece.position 308 | const x = position[0] 309 | const y = position[1] 310 | const line = [] 311 | 312 | // 获取所有棋子的位置 313 | const positionStrArr = getAllPiecePosition() 314 | 315 | /* 316 | 八种可能 317 | x + 1, y + 2 318 | x + 1, y - 2 319 | x - 1, y + 2 320 | x - 1, y - 2 321 | x + 2, y + 1 322 | x - 2, y + 1 323 | x + 2, y - 1 324 | x - 2, y - 1 325 | */ 326 | 327 | if (x !== 1) { 328 | if (y > 2 && positionStrArr.indexOf([x, y - 1].toString()) < 0) { 329 | line.push([x - 1, y - 2]) 330 | } 331 | if (y < 9 && positionStrArr.indexOf([x, y + 1].toString()) < 0) { 332 | line.push([x - 1, y + 2]) 333 | } 334 | } 335 | if (x !== 9) { 336 | if (y > 2 && positionStrArr.indexOf([x, y - 1].toString()) < 0) { 337 | line.push([x + 1, y - 2]) 338 | } 339 | if (y < 9 && positionStrArr.indexOf([x, y + 1].toString()) < 0) { 340 | line.push([x + 1, y + 2]) 341 | } 342 | } 343 | if (y !== 1) { 344 | if (x > 2 && positionStrArr.indexOf([x - 1, y].toString()) < 0) { 345 | line.push([x - 2, y - 1]) 346 | } 347 | if (x < 8 && positionStrArr.indexOf([x + 1, y].toString()) < 0) { 348 | line.push([x + 2, y - 1]) 349 | } 350 | } 351 | if (y !== 10) { 352 | if (x > 2 && positionStrArr.indexOf([x - 1, y].toString()) < 0) { 353 | line.push([x - 2, y + 1]) 354 | } 355 | if (x < 8 && positionStrArr.indexOf([x + 1, y].toString()) < 0) { 356 | line.push([x + 2, y + 1]) 357 | } 358 | } 359 | 360 | return line 361 | } 362 | 363 | // 炮的可移动路线 364 | const getPMoveLine = function (piece) { 365 | const position = piece.position 366 | const x = position[0] 367 | const y = position[1] 368 | const line = [] 369 | 370 | // 获取所有棋子的位置 371 | const positionStrArr = getAllPiecePosition() 372 | // const piecesArr = Game.getAllPieces() 373 | 374 | if (x !== 9) { 375 | let hasFulcrum = false // 是否有支点 376 | for (let xIndex = x + 1; xIndex <= 9; xIndex++) { 377 | const positionIndex = positionStrArr.indexOf([xIndex, y].toString()) 378 | if (hasFulcrum) { 379 | if (positionIndex > -1) { 380 | // if (piecesArr[positionIndex].camp !== piece.camp) { 381 | line.push([xIndex, y]) 382 | // } 383 | break 384 | } 385 | } else { 386 | if (positionIndex > -1) { 387 | hasFulcrum = true 388 | continue 389 | } 390 | line.push([xIndex, y]) 391 | } 392 | } 393 | } 394 | if (x !== 1) { 395 | let hasFulcrum = false // 是否有支点 396 | for (let xIndex = x - 1; xIndex >= 1; xIndex--) { 397 | const positionIndex = positionStrArr.indexOf([xIndex, y].toString()) 398 | if (hasFulcrum) { 399 | if (positionIndex > -1) { 400 | // if (piecesArr[positionIndex].camp !== piece.camp) { 401 | line.push([xIndex, y]) 402 | // } 403 | break 404 | } 405 | } else { 406 | if (positionIndex > -1) { 407 | hasFulcrum = true 408 | continue 409 | } 410 | line.push([xIndex, y]) 411 | } 412 | } 413 | } 414 | if (y !== 10) { 415 | let hasFulcrum = false // 是否有支点 416 | for (let yIndex = y + 1; yIndex <= 10; yIndex++) { 417 | const positionIndex = positionStrArr.indexOf([x, yIndex].toString()) 418 | if (hasFulcrum) { 419 | if (positionIndex > -1) { 420 | // if (piecesArr[positionIndex].camp !== piece.camp) { 421 | line.push([x, yIndex]) 422 | // } 423 | break 424 | } 425 | } else { 426 | if (positionIndex > -1) { 427 | hasFulcrum = true 428 | continue 429 | } 430 | line.push([x, yIndex]) 431 | } 432 | } 433 | } 434 | if (y !== 1) { 435 | let hasFulcrum = false // 是否有支点 436 | for (let yIndex = y - 1; yIndex >= 1; yIndex--) { 437 | const positionIndex = positionStrArr.indexOf([x, yIndex].toString()) 438 | if (hasFulcrum) { 439 | if (positionIndex > -1) { 440 | // if (piecesArr[positionIndex].camp !== piece.camp) { 441 | line.push([x, yIndex]) 442 | // } 443 | break 444 | } 445 | } else { 446 | if (positionIndex > -1) { 447 | hasFulcrum = true 448 | continue 449 | } 450 | line.push([x, yIndex]) 451 | } 452 | } 453 | } 454 | return line 455 | } 456 | 457 | const getAllPiecePosition = function () { 458 | const piecesArr = Game.getAllPieces() 459 | const positionArr = _.pluck(piecesArr, 'position') 460 | 461 | const strArr = [] 462 | for (const position of positionArr) { 463 | strArr.push(position.toString()) 464 | } 465 | return strArr 466 | } 467 | 468 | export default { 469 | getMoveLine, 470 | canMove 471 | } 472 | -------------------------------------------------------------------------------- /dist/static/js/app.1706df7922e4f82bbd59.js: -------------------------------------------------------------------------------- 1 | webpackJsonp([1],{NHnr:function(e,i,n){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var t=n("7+uW"),o={name:"App",created:function(){this.resize(),document.body.onresize=this.resize},methods:{resize:function(){var e=document.body.clientWidth/750*100;e>100?e=100:e<32&&(e=32),document.querySelector("html").style.fontSize=e+"px"}}},r={render:function(){var e=this.$createElement,i=this._self._c||e;return i("div",{attrs:{id:"app"}},[i("router-view")],1)},staticRenderFns:[]};var s=n("VU/8")(o,r,!1,function(e){n("wec9")},null,null).exports,c=n("/ocq"),a=n("BO1k"),u=n.n(a),h=n("Gu7T"),v=n.n(h),f=n("Zrlr"),p=n.n(f),l=n("wxAW"),d=n.n(l),P=function e(i,n,t){p()(this,e),this.name=i,this.position=n,this.camp=t||0,this.died=0};P.prototype.moveTo=function(e){this.position=e},P.prototype.copy=function(){return new P(this.name,this.position,this.camp)};var g=P,m=new(function(){function e(){p()(this,e),this.initBlankMap=function(){for(var e=[],i=1;i<=9;i++)for(var n=10;n>0;n--)e.push(new g("",[i,n],0));return e},this.initRedPieces=function(){return[new g("j1",[1,1],1),new g("j2",[9,1],1),new g("p1",[2,3],1),new g("p2",[8,3],1),new g("m1",[2,1],1),new g("m2",[8,1],1),new g("x1",[3,1],1),new g("x2",[7,1],1),new g("s1",[4,1],1),new g("s2",[6,1],1),new g("z1",[1,4],1),new g("z2",[3,4],1),new g("z3",[5,4],1),new g("z4",[7,4],1),new g("z5",[9,4],1),new g("k",[5,1],1)]},this.initBlackPieces=function(){return[new g("j1",[1,10],-1),new g("j2",[9,10],-1),new g("p1",[2,8],-1),new g("p2",[8,8],-1),new g("m1",[2,10],-1),new g("m2",[8,10],-1),new g("x1",[3,10],-1),new g("x2",[7,10],-1),new g("s1",[4,10],-1),new g("s2",[6,10],-1),new g("z1",[1,7],-1),new g("z2",[3,7],-1),new g("z3",[5,7],-1),new g("z4",[7,7],-1),new g("z5",[9,7],-1),new g("k",[5,10],-1)]},console.log("constructor"),this.blankMap=[],this.redPieces=[],this.blackPieces=[]}return d()(e,[{key:"initGame",value:function(){console.log("init"),this.blankMap=this.initBlankMap(),this.redPieces=this.initRedPieces(),this.blackPieces=this.initBlackPieces()}},{key:"getBlankMap",value:function(){return this.blankMap}},{key:"getRedPieces",value:function(){return this.redPieces}},{key:"getBlackPieces",value:function(){return this.blackPieces}},{key:"getAllPieces",value:function(){return[].concat(v()(this.redPieces),v()(this.blackPieces))}},{key:"getPieceByPosition",value:function(e){var i=this.getAllPieces().find(function(i){return i.position.toString()===e.toString()});return i||this.getBlankMap().find(function(i){return i.position.toString()===e.toString()})}}]),e}()),k=n("44pt"),w=function(e){var i=e.position,n=i[0],t=i[1],o=[];return 1===e.camp?t<=5?o.push([n,t+1]):(10!==t&&o.push([n,t+1]),1!==n&&o.push([n-1,t]),9!==n&&o.push([n+1,t])):t>5?o.push([n,t-1]):(1!==t&&o.push([n,t-1]),1!==n&&o.push([n-1,t]),9!==n&&o.push([n+1,t])),o},M=function(e){var i=e.position,n=i[0],t=i[1],o=[];return 1===e.camp?(4!==n&&(1!==t&&o.push([n-1,t-1]),3!==t&&o.push([n-1,t+1])),6!==n&&(1!==t&&o.push([n+1,t-1]),3!==t&&o.push([n+1,t+1]))):(4!==n&&(8!==t&&o.push([n-1,t-1]),10!==t&&o.push([n-1,t+1])),6!==n&&(8!==t&&o.push([n+1,t-1]),10!==t&&o.push([n+1,t+1]))),o},x=function(e){var i=e.position,n=i[0],t=i[1],o=[];return 1===e.camp?(3!==t&&o.push([n,t+1]),1!==t&&o.push([n,t-1]),4!==n&&o.push([n-1,t]),6!==n&&o.push([n+1,t])):(10!==t&&o.push([n,t+1]),8!==t&&o.push([n,t-1]),4!==n&&o.push([n-1,t]),6!==n&&o.push([n+1,t])),o},y=function(e){var i=e.position,n=i[0],t=i[1],o=[],r=L();return 1===e.camp?(1!==n&&(1!==t&&r.indexOf([n-1,t-1].toString())<0&&o.push([n-2,t-2]),5!==t&&r.indexOf([n-1,t+1].toString())<0&&o.push([n-2,t+2])),9!==n&&(1!==t&&r.indexOf([n+1,t-1].toString())<0&&o.push([n+2,t-2]),5!==t&&r.indexOf([n+1,t+1].toString())<0&&o.push([n+2,t+2]))):(1!==n&&(6!==t&&r.indexOf([n-1,t-1].toString())<0&&o.push([n-2,t-2]),10!==t&&r.indexOf([n-1,t+1].toString())<0&&o.push([n-2,t+2])),9!==n&&(6!==t&&r.indexOf([n+1,t-1].toString())<0&&o.push([n+2,t-2]),10!==t&&r.indexOf([n+1,t+1].toString())<0&&o.push([n+2,t+2]))),o},b=function(e){var i=e.position,n=i[0],t=i[1],o=[],r=L();if(9!==n)for(var s=n+1;s<=9;s++){if(r.indexOf([s,t].toString())>-1){o.push([s,t]);break}o.push([s,t])}if(1!==n)for(var c=n-1;c>=1;c--){if(r.indexOf([c,t].toString())>-1){o.push([c,t]);break}o.push([c,t])}if(10!==t)for(var a=t+1;a<=10;a++){if(r.indexOf([n,a].toString())>-1){o.push([n,a]);break}o.push([n,a])}if(1!==t)for(var u=t-1;u>=1;u--){if(r.indexOf([n,u].toString())>-1){o.push([n,u]);break}o.push([n,u])}return o},S=function(e){var i=e.position,n=i[0],t=i[1],o=[],r=L();return 1!==n&&(t>2&&r.indexOf([n,t-1].toString())<0&&o.push([n-1,t-2]),t<9&&r.indexOf([n,t+1].toString())<0&&o.push([n-1,t+2])),9!==n&&(t>2&&r.indexOf([n,t-1].toString())<0&&o.push([n+1,t-2]),t<9&&r.indexOf([n,t+1].toString())<0&&o.push([n+1,t+2])),1!==t&&(n>2&&r.indexOf([n-1,t].toString())<0&&o.push([n-2,t-1]),n<8&&r.indexOf([n+1,t].toString())<0&&o.push([n+2,t-1])),10!==t&&(n>2&&r.indexOf([n-1,t].toString())<0&&o.push([n-2,t+1]),n<8&&r.indexOf([n+1,t].toString())<0&&o.push([n+2,t+1])),o},O=function(e){var i=e.position,n=i[0],t=i[1],o=[],r=L();if(9!==n)for(var s=!1,c=n+1;c<=9;c++){var a=r.indexOf([c,t].toString());if(s){if(a>-1){o.push([c,t]);break}}else{if(a>-1){s=!0;continue}o.push([c,t])}}if(1!==n)for(var u=!1,h=n-1;h>=1;h--){var v=r.indexOf([h,t].toString());if(u){if(v>-1){o.push([h,t]);break}}else{if(v>-1){u=!0;continue}o.push([h,t])}}if(10!==t)for(var f=!1,p=t+1;p<=10;p++){var l=r.indexOf([n,p].toString());if(f){if(l>-1){o.push([n,p]);break}}else{if(l>-1){f=!0;continue}o.push([n,p])}}if(1!==t)for(var d=!1,P=t-1;P>=1;P--){var g=r.indexOf([n,P].toString());if(d){if(g>-1){o.push([n,P]);break}}else{if(g>-1){d=!0;continue}o.push([n,P])}}return o},L=function(){var e=m.getAllPieces(),i=k.a.pluck(e,"position"),n=[],t=!0,o=!1,r=void 0;try{for(var s,c=u()(i);!(t=(s=c.next()).done);t=!0){var a=s.value;n.push(a.toString())}}catch(e){o=!0,r=e}finally{try{!t&&c.return&&c.return()}finally{if(o)throw r}}return n},C={getMoveLine:function(e){var i,n=[];switch((i=e.name).length>1?i.substring(0,1):i){case"z":n=w(e);break;case"s":n=M(e);break;case"k":n=x(e);break;case"j":n=b(e);break;case"p":n=O(e);break;case"x":n=y(e);break;case"m":n=S(e)}return n},canMove:function(e,i,n){if(!n||n.length<1)return!1;var t=i.position.toString(),o=!0,r=!1,s=void 0;try{for(var c,a=u()(n);!(o=(c=a.next()).done);o=!0)if(c.value.toString()===t)return!0}catch(e){r=!0,s=e}finally{try{!o&&a.return&&a.return()}finally{if(r)throw s}}return!1}};function _(e,i){return!!e.find(function(e){return i.indexOf(e)>-1})}window._=k.a;var B=function(e){return function(e){var i=z(-e),n=k.a.flatten(k.a.pluck(i.canMoveList,"canSavePiecePositions")),t=k.a.flatten(k.a.pluck(i.canMoveList,"canRemovePiecePositions")),o=k.a.flatten(k.a.pluck(i.canMoveList,"canMovePositions")),r=z(e),s=k.a.flatten(k.a.pluck(r.canMoveList,"canSavePiecePositions"));if(r.king)return r.king;i.king;var c=r.canMoveList,a=null;if(c.find(function(e){return!_(e.canSavePiecePositions,t)&&e.canRemovePieces.find(function(i){if(-1===n.indexOf(i.position.toString()))return a={canMovePositions:e.canMovePositions,ownerPiece:e.ownerPiece,canRemovePiece:i},!0})}),a)return{canMovePositions:a.canMovePositions,needMovePiece:a.ownerPiece,targetPiece:a.canRemovePiece};var u=null;if(t.find(function(e){return!(s.indexOf(e)>-1)&&c.find(function(i){if(_(i.canSavePiecePositions,t))return!1;var n=R(i.ownerPiece,i.canMoveBlankPieces,e,o);return n?(u={canMovePositions:i.canMovePositions,ownerPiece:i.ownerPiece,canMovePiece:n},!0):void 0})}),u)return{canMovePositions:u.canMovePositions,needMovePiece:u.ownerPiece,targetPiece:u.canMovePiece};var h=null;if(c.find(function(e){if(_(e.canSavePiecePositions,t))return!1;var i=R(e.ownerPiece,e.canMoveBlankPieces,"",o);return i?(h={canMovePositions:e.canMovePositions,ownerPiece:e.ownerPiece,canMovePiece:i},!0):void 0}),h)return{canMovePositions:h.canMovePositions,needMovePiece:h.ownerPiece,targetPiece:h.canMovePiece}}(e)};function z(e){var i=1===e?m.getRedPieces():m.getBlackPieces(),n=null,t=[],o=!0,r=!1,s=void 0;try{for(var c,a=u()(i);!(o=(c=a.next()).done);o=!0){var h=c.value,v=C.getMoveLine(h),f=A(v,e);f.king?n={canMovePositions:v,needMovePiece:h,targetPiece:f.king}:t.push({ownerPiece:h,canRemovePieces:f.others,canMoveBlankPieces:f.blanks,canSavePieces:f.owners,canMovePositions:v,canSavePiecePositions:f.owners.map(function(e){return e&&e.position?e.position.toString():""}),canRemovePiecePositions:f.others.map(function(e){return e&&e.position?e.position.toString():""}),savedByPieces:[]})}}catch(e){r=!0,s=e}finally{try{!o&&a.return&&a.return()}finally{if(r)throw s}}return function(e){e.forEach(function(i){var n=!0,t=!1,o=void 0;try{for(var r,s=u()(e);!(n=(r=s.next()).done);n=!0){var c=r.value;c.canSavePiecePositions.indexOf(i.ownerPiece.position.toString())>-1&&i.savedByPieces.push(c.ownerPiece)}}catch(e){t=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(t)throw o}}})}(t),{king:n,canMoveList:t}}function R(e,i,n,t){return i.find(function(i){if(t.indexOf(i.position.toString())>-1)return!1;var o=e.copy();o.position=i.position;var r=A(C.getMoveLine(o),o.camp);return!!r.king||(n?r.owners.map(function(e){return e&&e.position?e.position.toString():""}).indexOf(n)>-1||void 0:r.others.length>0)})}function A(e,i){var n={king:null,others:[],owners:[],blanks:[]},t=!0,o=!1,r=void 0;try{for(var s,c=u()(e);!(t=(s=c.next()).done);t=!0){var a=s.value,h=m.getPieceByPosition(a);0===h.camp?n.blanks.push(h):i!==h.camp?"k"===h.name?n.king=h:n.others.push(h):i===h.camp&&n.owners.push(h)}}catch(e){o=!0,r=e}finally{try{!t&&c.return&&c.return()}finally{if(o)throw r}}return n}var H={data:function(){return{nextCamp:1,winCamp:0,over:!1,blankMap:[],redPieces:[],blackPieces:[],needMovePiece:null,highLightPoint:[],movedPointList:[]}},created:function(){this.begin()},methods:{begin:function(){this.nextCamp=this.winCamp?-this.winCamp:1,this.winCamp=0,this.over=!1,m.initGame(),this.blankMap=m.getBlankMap(),this.blackPieces=m.getBlackPieces(),this.redPieces=m.getRedPieces()},moreGame:function(){window.location.href="https://kodywang1994.github.io/game-box/dist/index.html#/"},gameOver:function(e){this.winCamp=e,this.over=!0},robot:function(){var e=B(this.nextCamp);if(!e)return console.warn("人机计算失败");this.highLightPoint=e.canMovePositions,this.moveToAnim(e.needMovePiece,e.targetPiece)},backStep:function(){var e=this.movedPointList.pop()||null;e&&(this.removePiece(e.movedPiece),this.addPiece(e.beforeMovePiece),this.addPiece(e.removedPiece),this.nextCamp=-this.nextCamp)},addPiece:function(e){e&&(1===e.camp?this.redPieces.push(e):this.blackPieces.push(e))},clickPiece:function(e){this.needMovePiece&&this.needMovePiece.camp!==e.camp?(this.moveToAnim(this.needMovePiece,e),this.needMovePiece=null,this.highLightPoint=[]):e.camp&&e.camp===this.nextCamp&&(this.needMovePiece=e,this.highLightPoint=C.getMoveLine(this.needMovePiece))},moveToAnim:function(e,i){if(C.canMove(e,i,this.highLightPoint)){var n=null,t=e.copy();i.camp&&i.camp!==e.camp&&(n=i,this.removePiece(i)),e.moveTo(i.position);var o=e.copy();this.nextCamp=-this.nextCamp,this.needMovePiece=null,this.highLightPoint=[],this.movedPointList.push({beforeMovePiece:t,movedPiece:o,removedPiece:n})}},removePiece:function(e){if("k"===e.name&&this.gameOver(-e.camp),1===e.camp){var i=this.getPieceIndexByName(this.redPieces,e);this.redPieces.splice(i,1)}else{var n=this.getPieceIndexByName(this.blackPieces,e);this.blackPieces.splice(n,1)}},getPieceIndexByName:function(e,i){for(var n in e)if(e[n].name===i.name)return n},handlePosition:function(e){var i=e[0],n=e[1];return"left:"+(i=.68*(i-1)-.34)+"rem;bottom:"+(n=.68*(n-1)-.34)+"rem;"},handleHighLight:function(e){var i=e.position.toString(),n=!0,t=!1,o=void 0;try{for(var r,s=u()(this.highLightPoint);!(n=(r=s.next()).done);n=!0){if(r.value.toString()===i)return this.needMovePiece&&e.camp===this.needMovePiece.camp?(this.removeHighLightItem(e),""):"active"}}catch(e){t=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(t)throw o}}},removeHighLightItem:function(e){var i=[],n=!0,t=!1,o=void 0;try{for(var r,s=u()(this.highLightPoint);!(n=(r=s.next()).done);n=!0){var c=r.value;i.push(c.toString())}}catch(e){t=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(t)throw o}}var a=i.indexOf(e.position.toString());a>-1&&this.highLightPoint.splice(a,1)}}},T={render:function(){var e=this,i=e.$createElement,n=e._self._c||i;return n("div",[n("div",{staticClass:"status",class:e.nextCamp>0?"red":""},[e._v("\n "+e._s(e.nextCamp>0?"红棋":"黑棋")+"\n "),n("div",{staticClass:"options"},[n("div",{on:{click:e.backStep}},[e._v("悔棋")]),e._v(" "),n("div",{on:{click:e.robot}},[e._v("人机")])])]),e._v(" "),n("div",{staticClass:"board"},[n("div",{staticClass:"board-wrap"},[e._l(e.blankMap,function(i,t){return n("div",{key:"black"+t,staticClass:"piece blank-item",class:e.handleHighLight(i),style:e.handlePosition(i.position),on:{click:function(n){return e.clickPiece(i)}}})}),e._v(" "),e._l(e.blackPieces,function(i){return n("div",{key:"black"+i.name,staticClass:"piece",class:["black-"+i.name,e.handleHighLight(i)],style:e.handlePosition(i.position),on:{click:function(n){return e.clickPiece(i)}}})}),e._v(" "),e._l(e.redPieces,function(i){return n("div",{key:"red"+i.name,staticClass:"piece",class:["red-"+i.name,e.handleHighLight(i)],style:e.handlePosition(i.position),on:{click:function(n){return e.clickPiece(i)}}})})],2)]),e._v(" "),e.over?n("div",{staticClass:"success-panel"},[n("div",{staticClass:"success-title"},[e._v(e._s(e.winCamp>0?"红棋":"黑棋")+"赢了!")]),e._v(" "),n("div",{staticClass:"restart",on:{click:e.begin}},[e._v("再来一局")]),e._v(" "),n("div",{staticClass:"restart back",on:{click:e.moreGame}},[e._v("更多游戏")])]):e._e()])},staticRenderFns:[]};var j=n("VU/8")(H,T,!1,function(e){n("YXkV")},"data-v-ad26c7ec",null).exports;t.a.use(c.a);var I=new c.a({routes:[{path:"/",name:"Index",component:j}]});t.a.config.productionTip=!1,new t.a({el:"#app",router:I,components:{App:s},template:""})},YXkV:function(e,i){},wec9:function(e,i){}},["NHnr"]); 2 | //# sourceMappingURL=app.1706df7922e4f82bbd59.js.map -------------------------------------------------------------------------------- /dist/static/js/app.1706df7922e4f82bbd59.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///src/App.vue","webpack:///./src/App.vue?087f","webpack:///./src/App.vue","webpack:///./src/game/piece.js","webpack:///./src/game/index.js","webpack:///./src/game/rule.js","webpack:///./src/game/utils.js","webpack:///./src/game/robot.js","webpack:///src/pages/index.vue","webpack:///./src/pages/index.vue?33aa","webpack:///./src/pages/index.vue","webpack:///./src/router/index.js","webpack:///./src/main.js"],"names":["App","name","created","this","resize","document","body","onresize","methods","width","clientWidth","querySelector","style","fontSize","selectortype_template_index_0_src_App","render","_h","$createElement","_c","_self","attrs","id","staticRenderFns","src_App","__webpack_require__","normalizeComponent","ssrContext","Piece","position","camp","classCallCheck_default","died","prototype","moveTo","newPos","copy","game","Game","initBlankMap","map","x","y","push","initRedPieces","initBlackPieces","console","log","blankMap","redPieces","blackPieces","concat","toConsumableArray_default","piece","getAllPieces","find","toString","getBlankMap","getZMoveLine","line","getSMoveLine","getKMoveLine","getXMoveLine","positionStrArr","getAllPiecePosition","indexOf","getJMoveLine","xIndex","yIndex","getMMoveLine","getPMoveLine","hasFulcrum","positionIndex","piecesArr","positionArr","_","pluck","strArr","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","undefined","_step2","_iterator2","get_iterator_default","next","done","value","err","return","rule","getMoveLine","moveLine","length","substring","canMove","targetPiece","canMovePoint","positionStr","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_step","_iterator","checkSameItem","arr1","arr2","i","window","getBestMovePiece","currentCamp","enemyList","getCampCanMovePieceList","enemySavePiecesPosition","flatten","canMoveList","enemyRemovePiecesPosition","enemyCanMovePositions","ownerList","ownerSavePiecesPosition","king","canRemovePiece","item","canSavePiecePositions","canRemovePieces","canMovePositions","ownerPiece","needMovePiece","canSavePiece","nextPiece","getCanSavePiecePosition","canMoveBlankPieces","canMovePiece","getCampCanMovePiece","ownerPieces","getRedPieces","getBlackPieces","Rule","canMovePieces","handlePosition","others","blanks","canSavePieces","owners","canRemovePiecePositions","savedByPieces","forEach","item2","handleSavedByPieces","needSavePosition","tempPiece","canMovePosition","_iteratorNormalCompletion3","_didIteratorError3","_iteratorError3","_step3","_iterator3","getPieceByPosition","pages","data","nextCamp","winCamp","over","highLightPoint","movedPointList","begin","initGame","moreGame","location","href","gameOver","robot","robotMovePiece","warn","moveToAnim","backStep","step","pop","removePiece","movedPiece","addPiece","beforeMovePiece","removedPiece","clickPiece","index","getPieceIndexByName","splice","_index","pieces","pieceSize","handleHighLight","removeHighLightItem","point","selectortype_template_index_0_src_pages","_vm","staticClass","class","_v","_s","on","click","_l","key","$event","_e","src_pages","pages_normalizeComponent","Vue","use","Router","router","routes","path","component","Index","config","productionTip","el","components","template"],"mappings":"qHAOAA,GACAC,KAAA,MACAC,QAFA,WAGAC,KAAAC,SACAC,SAAAC,KAAAC,SAAAJ,KAAAC,QAEAI,SACAJ,OADA,WAEA,IACAK,EADAJ,SAAAC,KAAAI,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,EAAAvD,eAAAjB,EAAA7F,UAAA0K,IAAkJC,MAAA,SAAAG,GAAyB,OAAAT,EAAAX,WAAA7D,SAAgCwE,EAAAG,GAAA,KAAAH,EAAAO,GAAAP,EAAA,mBAAAxE,GAAoD,OAAAvG,EAAA,OAAiBuL,IAAA,MAAAhF,EAAAxH,KAAAiM,YAAA,QAAAC,OAAA,OAAA1E,EAAAxH,KAAAgM,EAAAJ,gBAAApE,IAAA7G,MAAAqL,EAAAvD,eAAAjB,EAAA7F,UAAA0K,IAA8IC,MAAA,SAAAG,GAAyB,OAAAT,EAAAX,WAAA7D,UAAgC,KAAAwE,EAAAG,GAAA,KAAAH,EAAA,KAAA/K,EAAA,OAAyCgL,YAAA,kBAA4BhL,EAAA,OAAYgL,YAAA,kBAA4BD,EAAAG,GAAAH,EAAAI,GAAAJ,EAAAjC,QAAA,sBAAAiC,EAAAG,GAAA,KAAAlL,EAAA,OAA8EgL,YAAA,UAAAI,IAA0BC,MAAAN,EAAA7B,SAAmB6B,EAAAG,GAAA,UAAAH,EAAAG,GAAA,KAAAlL,EAAA,OAAyCgL,YAAA,eAAAI,IAA+BC,MAAAN,EAAA3B,YAAsB2B,EAAAG,GAAA,YAAAH,EAAAU,QAEnhDrL,oBCChC,IAuBesL,EAvBUpL,EAAQ,OAcjBqL,CACdhD,EACAmC,GAT6B,EAV/B,SAAoBtK,GAClBF,EAAQ,SAaS,kBAEU,MAUG,QCtBhCsL,IAAIC,IAAIC,KAEO,IAAAC,EAAA,IAAID,KACjBE,SAEIC,KAAM,IACNlN,KAAM,QACNmN,UAAWC,MCLjBP,IAAIQ,OAAOC,eAAgB,EAG3B,IAAIT,KACFU,GAAI,OACJP,SACAQ,YAAczN,OACd0N,SAAU","file":"static/js/app.1706df7922e4f82bbd59.js","sourcesContent":["\r\n\r\n\r\n\r\n\r\n\n\n\n// WEBPACK FOOTER //\n// src/App.vue","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{\"id\":\"app\"}},[_c('router-view')],1)}\nvar staticRenderFns = []\nvar esExports = { render: render, staticRenderFns: staticRenderFns }\nexport default esExports\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/vue-loader/lib/template-compiler?{\"id\":\"data-v-71581021\",\"hasScoped\":false,\"transformToRequire\":{\"video\":[\"src\",\"poster\"],\"source\":\"src\",\"img\":\"src\",\"image\":\"xlink:href\"},\"buble\":{\"transforms\":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/App.vue\n// module id = null\n// module chunks = ","function injectStyle (ssrContext) {\n require(\"!!../node_modules/extract-text-webpack-plugin/dist/loader.js?{\\\"omit\\\":1,\\\"remove\\\":true}!vue-style-loader!css-loader?{\\\"sourceMap\\\":true}!../node_modules/vue-loader/lib/style-compiler/index?{\\\"vue\\\":true,\\\"id\\\":\\\"data-v-71581021\\\",\\\"scoped\\\":false,\\\"hasInlineConfig\\\":false}!../node_modules/vue-loader/lib/selector?type=styles&index=0!./App.vue\")\n}\nvar normalizeComponent = require(\"!../node_modules/vue-loader/lib/component-normalizer\")\n/* script */\nexport * from \"!!babel-loader!../node_modules/vue-loader/lib/selector?type=script&index=0!./App.vue\"\nimport __vue_script__ from \"!!babel-loader!../node_modules/vue-loader/lib/selector?type=script&index=0!./App.vue\"\n/* template */\nimport __vue_template__ from \"!!../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-71581021\\\",\\\"hasScoped\\\":false,\\\"transformToRequire\\\":{\\\"video\\\":[\\\"src\\\",\\\"poster\\\"],\\\"source\\\":\\\"src\\\",\\\"img\\\":\\\"src\\\",\\\"image\\\":\\\"xlink:href\\\"},\\\"buble\\\":{\\\"transforms\\\":{}}}!../node_modules/vue-loader/lib/selector?type=template&index=0!./App.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_template__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/App.vue\n// module id = null\n// module chunks = ","class Piece {\r\n constructor (name, position, camp) {\r\n // camp: 阵营,-1黑,1红,0空白\r\n this.name = name\r\n this.position = position\r\n this.camp = camp || 0\r\n this.died = 0\r\n }\r\n}\r\n\r\nPiece.prototype.moveTo = function (newPos) {\r\n this.position = newPos\r\n}\r\n\r\nPiece.prototype.copy = function () {\r\n return new Piece(this.name, this.position, this.camp)\r\n}\r\n\r\nexport default Piece\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/game/piece.js","import Piece from './piece'\r\n\r\nclass Game {\r\n constructor () {\r\n console.log('constructor')\r\n this.blankMap = []\r\n this.redPieces = []\r\n this.blackPieces = []\r\n }\r\n\r\n initGame () {\r\n console.log('init')\r\n this.blankMap = this.initBlankMap()\r\n this.redPieces = this.initRedPieces()\r\n this.blackPieces = this.initBlackPieces()\r\n }\r\n\r\n getBlankMap () {\r\n return this.blankMap\r\n }\r\n\r\n getRedPieces () {\r\n return this.redPieces\r\n }\r\n\r\n getBlackPieces () {\r\n return this.blackPieces\r\n }\r\n\r\n getAllPieces () {\r\n return [...this.redPieces, ...this.blackPieces]\r\n }\r\n\r\n // 获取位置上的棋子\r\n getPieceByPosition (position) {\r\n const allPieces = this.getAllPieces()\r\n const piece = allPieces.find(piece => {\r\n return piece.position.toString() === position.toString()\r\n })\r\n if (piece) return piece\r\n return this.getBlankMap().find(piece => {\r\n return piece.position.toString() === position.toString()\r\n })\r\n }\r\n\r\n initBlankMap = function () {\r\n const map = []\r\n\r\n for (let x = 1; x <= 9; x++) {\r\n for (let y = 10; y > 0; y--) {\r\n // 生成空白棋盘\r\n map.push(new Piece('', [x, y], 0))\r\n }\r\n }\r\n return map\r\n }\r\n\r\n initRedPieces = function () {\r\n return [\r\n new Piece('j1', [1, 1], 1), // 车\r\n new Piece('j2', [9, 1], 1), // 车\r\n new Piece('p1', [2, 3], 1), // 炮\r\n new Piece('p2', [8, 3], 1), // 炮\r\n new Piece('m1', [2, 1], 1), // 马\r\n new Piece('m2', [8, 1], 1), // 马\r\n new Piece('x1', [3, 1], 1), // 相\r\n new Piece('x2', [7, 1], 1), // 相\r\n new Piece('s1', [4, 1], 1), // 士\r\n new Piece('s2', [6, 1], 1), // 士\r\n new Piece('z1', [1, 4], 1), // 兵\r\n new Piece('z2', [3, 4], 1), // 兵\r\n new Piece('z3', [5, 4], 1), // 兵\r\n new Piece('z4', [7, 4], 1), // 兵\r\n new Piece('z5', [9, 4], 1), // 兵\r\n new Piece('k', [5, 1], 1) // 帅\r\n ]\r\n }\r\n\r\n initBlackPieces = function () {\r\n return [\r\n new Piece('j1', [1, 10], -1),\r\n new Piece('j2', [9, 10], -1),\r\n new Piece('p1', [2, 8], -1),\r\n new Piece('p2', [8, 8], -1),\r\n new Piece('m1', [2, 10], -1),\r\n new Piece('m2', [8, 10], -1),\r\n new Piece('x1', [3, 10], -1),\r\n new Piece('x2', [7, 10], -1),\r\n new Piece('s1', [4, 10], -1),\r\n new Piece('s2', [6, 10], -1),\r\n new Piece('z1', [1, 7], -1),\r\n new Piece('z2', [3, 7], -1),\r\n new Piece('z3', [5, 7], -1),\r\n new Piece('z4', [7, 7], -1),\r\n new Piece('z5', [9, 7], -1),\r\n new Piece('k', [5, 10], -1)\r\n ]\r\n }\r\n}\r\n\r\nexport default new Game()\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/game/index.js","import Game from '../game'\r\nimport _ from 'underscore'\r\n\r\n// j1, j2 // 车\r\n// p1, p2 // 炮\r\n// m1, m2 // 马\r\n// x1, x2 // 相\r\n// s1, s2 // 士\r\n// z1, z2, z3, z4, z5 // 兵\r\n// k // 帅\r\n\r\nconst getRuleTypeByName = function (name) {\r\n if (name.length > 1) {\r\n return name.substring(0, 1)\r\n } else {\r\n return name\r\n }\r\n}\r\n\r\nconst getMoveLine = function (piece) {\r\n const ruleType = getRuleTypeByName(piece.name)\r\n let moveLine = []\r\n switch (ruleType) {\r\n case 'z': // 兵\r\n moveLine = getZMoveLine(piece)\r\n break\r\n case 's': // 士\r\n moveLine = getSMoveLine(piece)\r\n break\r\n case 'k': // 帅\r\n moveLine = getKMoveLine(piece)\r\n break\r\n case 'j': // 军\r\n moveLine = getJMoveLine(piece)\r\n break\r\n case 'p': // 炮\r\n moveLine = getPMoveLine(piece)\r\n break\r\n case 'x': // 相\r\n moveLine = getXMoveLine(piece)\r\n break\r\n case 'm': // 马\r\n moveLine = getMMoveLine(piece)\r\n break\r\n }\r\n return moveLine\r\n}\r\n\r\nconst canMove = function (piece, targetPiece, canMovePoint) {\r\n if (!canMovePoint || canMovePoint.length < 1) {\r\n // 如果还没有可移动的列表,则return\r\n return false\r\n }\r\n const positionStr = targetPiece.position.toString()\r\n for (const point of canMovePoint) {\r\n if (point.toString() === positionStr) {\r\n return true\r\n }\r\n }\r\n return false\r\n}\r\n\r\n// 兵的可移动路线\r\nconst getZMoveLine = function (piece) {\r\n const position = piece.position\r\n const x = position[0]\r\n const y = position[1]\r\n const line = []\r\n if (piece.camp === 1) { // 红方,棋盘在下方\r\n if (y <= 5) {\r\n line.push([x, y + 1]) // 只能前进一步\r\n } else {\r\n if (y !== 10) {\r\n // 可以前进一步\r\n line.push([x, y + 1])\r\n }\r\n if (x !== 1) {\r\n // 可以左移一步\r\n line.push([x - 1, y])\r\n }\r\n if (x !== 9) {\r\n // 可以右移一步\r\n line.push([x + 1, y])\r\n }\r\n }\r\n } else { // 黑方,棋盘在上方\r\n if (y > 5) {\r\n line.push([x, y - 1]) // 只能前进一步\r\n } else {\r\n if (y !== 1) {\r\n // 可以前进一步\r\n line.push([x, y - 1])\r\n }\r\n if (x !== 1) {\r\n // 可以左移一步\r\n line.push([x - 1, y])\r\n }\r\n if (x !== 9) {\r\n // 可以右移一步\r\n line.push([x + 1, y])\r\n }\r\n }\r\n }\r\n return line\r\n}\r\n\r\n// 士的可移动路线\r\nconst getSMoveLine = function (piece) {\r\n const position = piece.position\r\n const x = position[0]\r\n const y = position[1]\r\n const line = []\r\n if (piece.camp === 1) { // 红方,棋盘在下方\r\n if (x !== 4) {\r\n if (y !== 1) {\r\n line.push([x - 1, y - 1])\r\n }\r\n if (y !== 3) {\r\n line.push([x - 1, y + 1])\r\n }\r\n }\r\n if (x !== 6) {\r\n if (y !== 1) {\r\n line.push([x + 1, y - 1])\r\n }\r\n if (y !== 3) {\r\n line.push([x + 1, y + 1])\r\n }\r\n }\r\n } else { // 黑方,棋盘在上方\r\n if (x !== 4) {\r\n if (y !== 8) {\r\n line.push([x - 1, y - 1])\r\n }\r\n if (y !== 10) {\r\n line.push([x - 1, y + 1])\r\n }\r\n }\r\n if (x !== 6) {\r\n if (y !== 8) {\r\n line.push([x + 1, y - 1])\r\n }\r\n if (y !== 10) {\r\n line.push([x + 1, y + 1])\r\n }\r\n }\r\n }\r\n return line\r\n}\r\n\r\n// 将的可移动路线\r\nconst getKMoveLine = function (piece) {\r\n const position = piece.position\r\n const x = position[0]\r\n const y = position[1]\r\n const line = []\r\n if (piece.camp === 1) { // 红方,棋盘在下方\r\n if (y !== 3) {\r\n // 可以前进一步\r\n line.push([x, y + 1])\r\n }\r\n if (y !== 1) {\r\n // 可以后退一步\r\n line.push([x, y - 1])\r\n }\r\n if (x !== 4) {\r\n // 可以左移一步\r\n line.push([x - 1, y])\r\n }\r\n if (x !== 6) {\r\n // 可以右移一步\r\n line.push([x + 1, y])\r\n }\r\n } else { // 黑方,棋盘在上方\r\n if (y !== 10) {\r\n // 可以前进一步\r\n line.push([x, y + 1])\r\n }\r\n if (y !== 8) {\r\n // 可以后退一步\r\n line.push([x, y - 1])\r\n }\r\n if (x !== 4) {\r\n // 可以左移一步\r\n line.push([x - 1, y])\r\n }\r\n if (x !== 6) {\r\n // 可以右移一步\r\n line.push([x + 1, y])\r\n }\r\n }\r\n return line\r\n}\r\n\r\n// 相的可移动路线\r\nconst getXMoveLine = function (piece) {\r\n const position = piece.position\r\n const x = position[0]\r\n const y = position[1]\r\n const line = []\r\n\r\n // 获取所有棋子的位置\r\n const positionStrArr = getAllPiecePosition()\r\n\r\n if (piece.camp === 1) { // 红方,棋盘在下方\r\n if (x !== 1) {\r\n if (y !== 1 && positionStrArr.indexOf([x - 1, y - 1].toString()) < 0) {\r\n line.push([x - 2, y - 2])\r\n }\r\n if (y !== 5 && positionStrArr.indexOf([x - 1, y + 1].toString()) < 0) {\r\n line.push([x - 2, y + 2])\r\n }\r\n }\r\n if (x !== 9) {\r\n if (y !== 1 && positionStrArr.indexOf([x + 1, y - 1].toString()) < 0) {\r\n line.push([x + 2, y - 2])\r\n }\r\n if (y !== 5 && positionStrArr.indexOf([x + 1, y + 1].toString()) < 0) {\r\n line.push([x + 2, y + 2])\r\n }\r\n }\r\n } else { // 黑方,棋盘在上方\r\n if (x !== 1) {\r\n if (y !== 6 && positionStrArr.indexOf([x - 1, y - 1].toString()) < 0) {\r\n line.push([x - 2, y - 2])\r\n }\r\n if (y !== 10 && positionStrArr.indexOf([x - 1, y + 1].toString()) < 0) {\r\n line.push([x - 2, y + 2])\r\n }\r\n }\r\n if (x !== 9) {\r\n if (y !== 6 && positionStrArr.indexOf([x + 1, y - 1].toString()) < 0) {\r\n line.push([x + 2, y - 2])\r\n }\r\n if (y !== 10 && positionStrArr.indexOf([x + 1, y + 1].toString()) < 0) {\r\n line.push([x + 2, y + 2])\r\n }\r\n }\r\n }\r\n return line\r\n}\r\n\r\n// 军的可移动路线\r\nconst getJMoveLine = function (piece) {\r\n const position = piece.position\r\n const x = position[0]\r\n const y = position[1]\r\n const line = []\r\n\r\n // 获取所有棋子的位置\r\n const positionStrArr = getAllPiecePosition()\r\n // const piecesArr = Game.getAllPieces()\r\n\r\n if (x !== 9) {\r\n for (let xIndex = x + 1; xIndex <= 9; xIndex++) {\r\n const positionIndex = positionStrArr.indexOf([xIndex, y].toString())\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([xIndex, y])\r\n // }\r\n break\r\n }\r\n line.push([xIndex, y])\r\n }\r\n }\r\n if (x !== 1) {\r\n for (let xIndex = x - 1; xIndex >= 1; xIndex--) {\r\n const positionIndex = positionStrArr.indexOf([xIndex, y].toString())\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([xIndex, y])\r\n // }\r\n break\r\n }\r\n line.push([xIndex, y])\r\n }\r\n }\r\n if (y !== 10) {\r\n for (let yIndex = y + 1; yIndex <= 10; yIndex++) {\r\n const positionIndex = positionStrArr.indexOf([x, yIndex].toString())\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([x, yIndex])\r\n // }\r\n break\r\n }\r\n line.push([x, yIndex])\r\n }\r\n }\r\n if (y !== 1) {\r\n for (let yIndex = y - 1; yIndex >= 1; yIndex--) {\r\n const positionIndex = positionStrArr.indexOf([x, yIndex].toString())\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([x, yIndex])\r\n // }\r\n break\r\n }\r\n line.push([x, yIndex])\r\n }\r\n }\r\n return line\r\n}\r\n\r\n// 马的可移动路线\r\nconst getMMoveLine = function (piece) {\r\n const position = piece.position\r\n const x = position[0]\r\n const y = position[1]\r\n const line = []\r\n\r\n // 获取所有棋子的位置\r\n const positionStrArr = getAllPiecePosition()\r\n\r\n /*\r\n 八种可能\r\n x + 1, y + 2\r\n x + 1, y - 2\r\n x - 1, y + 2\r\n x - 1, y - 2\r\n x + 2, y + 1\r\n x - 2, y + 1\r\n x + 2, y - 1\r\n x - 2, y - 1\r\n */\r\n\r\n if (x !== 1) {\r\n if (y > 2 && positionStrArr.indexOf([x, y - 1].toString()) < 0) {\r\n line.push([x - 1, y - 2])\r\n }\r\n if (y < 9 && positionStrArr.indexOf([x, y + 1].toString()) < 0) {\r\n line.push([x - 1, y + 2])\r\n }\r\n }\r\n if (x !== 9) {\r\n if (y > 2 && positionStrArr.indexOf([x, y - 1].toString()) < 0) {\r\n line.push([x + 1, y - 2])\r\n }\r\n if (y < 9 && positionStrArr.indexOf([x, y + 1].toString()) < 0) {\r\n line.push([x + 1, y + 2])\r\n }\r\n }\r\n if (y !== 1) {\r\n if (x > 2 && positionStrArr.indexOf([x - 1, y].toString()) < 0) {\r\n line.push([x - 2, y - 1])\r\n }\r\n if (x < 8 && positionStrArr.indexOf([x + 1, y].toString()) < 0) {\r\n line.push([x + 2, y - 1])\r\n }\r\n }\r\n if (y !== 10) {\r\n if (x > 2 && positionStrArr.indexOf([x - 1, y].toString()) < 0) {\r\n line.push([x - 2, y + 1])\r\n }\r\n if (x < 8 && positionStrArr.indexOf([x + 1, y].toString()) < 0) {\r\n line.push([x + 2, y + 1])\r\n }\r\n }\r\n\r\n return line\r\n}\r\n\r\n// 炮的可移动路线\r\nconst getPMoveLine = function (piece) {\r\n const position = piece.position\r\n const x = position[0]\r\n const y = position[1]\r\n const line = []\r\n\r\n // 获取所有棋子的位置\r\n const positionStrArr = getAllPiecePosition()\r\n // const piecesArr = Game.getAllPieces()\r\n\r\n if (x !== 9) {\r\n let hasFulcrum = false // 是否有支点\r\n for (let xIndex = x + 1; xIndex <= 9; xIndex++) {\r\n const positionIndex = positionStrArr.indexOf([xIndex, y].toString())\r\n if (hasFulcrum) {\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([xIndex, y])\r\n // }\r\n break\r\n }\r\n } else {\r\n if (positionIndex > -1) {\r\n hasFulcrum = true\r\n continue\r\n }\r\n line.push([xIndex, y])\r\n }\r\n }\r\n }\r\n if (x !== 1) {\r\n let hasFulcrum = false // 是否有支点\r\n for (let xIndex = x - 1; xIndex >= 1; xIndex--) {\r\n const positionIndex = positionStrArr.indexOf([xIndex, y].toString())\r\n if (hasFulcrum) {\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([xIndex, y])\r\n // }\r\n break\r\n }\r\n } else {\r\n if (positionIndex > -1) {\r\n hasFulcrum = true\r\n continue\r\n }\r\n line.push([xIndex, y])\r\n }\r\n }\r\n }\r\n if (y !== 10) {\r\n let hasFulcrum = false // 是否有支点\r\n for (let yIndex = y + 1; yIndex <= 10; yIndex++) {\r\n const positionIndex = positionStrArr.indexOf([x, yIndex].toString())\r\n if (hasFulcrum) {\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([x, yIndex])\r\n // }\r\n break\r\n }\r\n } else {\r\n if (positionIndex > -1) {\r\n hasFulcrum = true\r\n continue\r\n }\r\n line.push([x, yIndex])\r\n }\r\n }\r\n }\r\n if (y !== 1) {\r\n let hasFulcrum = false // 是否有支点\r\n for (let yIndex = y - 1; yIndex >= 1; yIndex--) {\r\n const positionIndex = positionStrArr.indexOf([x, yIndex].toString())\r\n if (hasFulcrum) {\r\n if (positionIndex > -1) {\r\n // if (piecesArr[positionIndex].camp !== piece.camp) {\r\n line.push([x, yIndex])\r\n // }\r\n break\r\n }\r\n } else {\r\n if (positionIndex > -1) {\r\n hasFulcrum = true\r\n continue\r\n }\r\n line.push([x, yIndex])\r\n }\r\n }\r\n }\r\n return line\r\n}\r\n\r\nconst getAllPiecePosition = function () {\r\n const piecesArr = Game.getAllPieces()\r\n const positionArr = _.pluck(piecesArr, 'position')\r\n\r\n const strArr = []\r\n for (const position of positionArr) {\r\n strArr.push(position.toString())\r\n }\r\n return strArr\r\n}\r\n\r\nexport default {\r\n getMoveLine,\r\n canMove\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/game/rule.js","// 检查两个数组有没有相同的值\r\nexport function checkSameItem (arr1, arr2) {\r\n return !!arr1.find(i => {\r\n return arr2.indexOf(i) > -1\r\n })\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/game/utils.js","import Game from './index'\r\nimport Rule from './rule'\r\nimport _ from 'underscore'\r\nimport { checkSameItem } from './utils'\r\nwindow._ = _\r\n// 人机对战\r\n\r\n// 获取到我方每一个棋子可以行动的位置,优先走可以消除对方的棋子的,其次是可以保护我方棋子的\r\n\r\n// Tips\r\n// 解析棋盘局势,得到我方每个棋子的以下属性:\r\n// 可以走的位置,可以杀的棋子,可以保护的棋子,受保护的情况\r\n\r\n/**\r\n * 获取最佳可移动的棋子\r\n * @param {当前阵营} currentCamp\r\n * @return {\r\n needMovePiece: 需要移动的棋子\r\n targetPiece: 需要移动到的位置,可能为敌方的棋子\r\n canMovePositions: 可以移动的所有位置坐标,需要提供给棋盘进行可移动判定\r\n }\r\n */\r\nexport const getBestMovePiece = function (currentCamp) {\r\n // 获取到我方可以移动的棋子\r\n return getCampCanMovePiece(currentCamp)\r\n}\r\n\r\n/**\r\n * 获取对应阵营可以移动的棋子,优先进攻帅,其次是可以消除敌方的棋子\r\n * @param {当前阵营} currentCamp\r\n * @returns {\r\n canMovePositions: 所有可移动的坐标,\r\n needMovePiece: 当前可移动的棋子,\r\n targetPiece: 需要移动到的位置,可能为敌方棋子\r\n }\r\n */\r\nfunction getCampCanMovePiece (currentCamp) {\r\n // 获取到敌方可能移动的棋子\r\n const enemyList = getCampCanMovePieceList(-currentCamp)\r\n // 敌方保护的棋子\r\n const enemySavePiecesPosition = _.flatten(_.pluck(enemyList.canMoveList, 'canSavePiecePositions'))\r\n // 敌方可以消除我方的棋子\r\n const enemyRemovePiecesPosition = _.flatten(_.pluck(enemyList.canMoveList, 'canRemovePiecePositions'))\r\n // 敌方可以移动的所有坐标\r\n const enemyCanMovePositions = _.flatten(_.pluck(enemyList.canMoveList, 'canMovePositions'))\r\n\r\n // 获取我方可移动的棋子\r\n const ownerList = getCampCanMovePieceList(currentCamp)\r\n // 我方保护的棋子\r\n const ownerSavePiecesPosition = _.flatten(_.pluck(ownerList.canMoveList, 'canSavePiecePositions'))\r\n // 我方可以消除敌方的棋子\r\n // const ownerRemovePiecesPosition = _.flatten(_.pluck(ownerList.canMoveList, 'canRemovePiecePositions'))\r\n // 如果可以杀帅,直接执行\r\n if (ownerList.king) return ownerList.king\r\n if (enemyList.king) {\r\n // 如果敌方将军,我们需要进行保护 TODO\r\n }\r\n const canMoveList = ownerList.canMoveList\r\n // 移动可以消除敌方的棋子, 排除被敌方保护的\r\n let canRemovePiece = null\r\n canMoveList.find(item => {\r\n // 如果我方当前棋子可以保护我方将要被消除的棋子,则不动\r\n if (checkSameItem(item.canSavePiecePositions, enemyRemovePiecesPosition)) return false\r\n return item.canRemovePieces.find(i => {\r\n // 敌方受保护的棋子不杀\r\n if (enemySavePiecesPosition.indexOf(i.position.toString()) === -1) {\r\n canRemovePiece = {\r\n canMovePositions: item.canMovePositions,\r\n ownerPiece: item.ownerPiece,\r\n canRemovePiece: i\r\n }\r\n return true\r\n }\r\n })\r\n })\r\n if (canRemovePiece) {\r\n return {\r\n canMovePositions: canRemovePiece.canMovePositions,\r\n needMovePiece: canRemovePiece.ownerPiece,\r\n targetPiece: canRemovePiece.canRemovePiece\r\n }\r\n }\r\n let canSavePiece = null\r\n // 移动我方棋子来保护即将被杀死的棋子\r\n enemyRemovePiecesPosition.find(position => {\r\n if (ownerSavePiecesPosition.indexOf(position) > -1) return false // 判断该位置是否受保护,如是,则无需处理\r\n // 如不受保护,则需要移动相应棋子保护该位置\r\n return canMoveList.find(item => {\r\n // 如果我方当前棋子可以保护我方将要被消除的棋子,则不动\r\n if (checkSameItem(item.canSavePiecePositions, enemyRemovePiecesPosition)) return false\r\n const nextPiece = getCanSavePiecePosition(item.ownerPiece, item.canMoveBlankPieces, position, enemyCanMovePositions)\r\n if (nextPiece) {\r\n canSavePiece = {\r\n canMovePositions: item.canMovePositions,\r\n ownerPiece: item.ownerPiece,\r\n canMovePiece: nextPiece\r\n }\r\n return true\r\n }\r\n })\r\n })\r\n if (canSavePiece) {\r\n return {\r\n canMovePositions: canSavePiece.canMovePositions,\r\n needMovePiece: canSavePiece.ownerPiece,\r\n targetPiece: canSavePiece.canMovePiece\r\n }\r\n }\r\n // 移动我方棋子到空白位置上\r\n let canMovePiece = null\r\n canMoveList.find(item => {\r\n // 如果我方当前棋子可以保护我方将要被消除的棋子,则不动\r\n if (checkSameItem(item.canSavePiecePositions, enemyRemovePiecesPosition)) return false\r\n const nextPiece = getCanSavePiecePosition(item.ownerPiece, item.canMoveBlankPieces, '', enemyCanMovePositions)\r\n if (nextPiece) {\r\n canMovePiece = {\r\n canMovePositions: item.canMovePositions,\r\n ownerPiece: item.ownerPiece,\r\n canMovePiece: nextPiece\r\n }\r\n return true\r\n }\r\n })\r\n if (canMovePiece) {\r\n return {\r\n canMovePositions: canMovePiece.canMovePositions,\r\n needMovePiece: canMovePiece.ownerPiece,\r\n targetPiece: canMovePiece.canMovePiece\r\n }\r\n }\r\n}\r\n\r\n// 获取对应阵营所有可以移动的棋子列表\r\nfunction getCampCanMovePieceList (currentCamp) {\r\n const ownerPieces = currentCamp === 1 ? Game.getRedPieces() : Game.getBlackPieces()\r\n // const otherPieces = currentCamp === 1 ? Game.getBlackPieces() : Game.getRedPieces()\r\n let king = null\r\n const canMoveList = []\r\n for (const ownerPiece of ownerPieces) {\r\n const canMovePositions = Rule.getMoveLine(ownerPiece)\r\n const canMovePieces = handlePosition(canMovePositions, currentCamp)\r\n if (canMovePieces.king) {\r\n // 如果有帅,直接return\r\n king = {\r\n canMovePositions,\r\n needMovePiece: ownerPiece,\r\n targetPiece: canMovePieces.king\r\n }\r\n } else {\r\n // 如果没有帅可以吃,就先把可以吃掉的棋子和可以移动的位置放入数组,等待循环结束后判定吃哪一个\r\n canMoveList.push({\r\n ownerPiece, // 当前可以移动的棋子\r\n canRemovePieces: canMovePieces.others, // 可以消除敌方的棋子\r\n canMoveBlankPieces: canMovePieces.blanks, // 可以移动的空白位置\r\n canSavePieces: canMovePieces.owners, // 可以保护的我方棋子\r\n canMovePositions: canMovePositions, // 所有可以移动的坐标\r\n // 保护的棋子位置\r\n canSavePiecePositions: canMovePieces.owners.map((item) => item && item.position ? item.position.toString() : ''),\r\n // 可以消除的棋子位置\r\n canRemovePiecePositions: canMovePieces.others.map((item) => item && item.position ? item.position.toString() : ''),\r\n // 受保护的棋子\r\n savedByPieces: []\r\n })\r\n }\r\n }\r\n handleSavedByPieces(canMoveList)\r\n return {\r\n king,\r\n canMoveList\r\n }\r\n}\r\n\r\n// 组装数据,获取受保护的情况\r\nfunction handleSavedByPieces (canMoveList) {\r\n canMoveList.forEach(item => {\r\n for (const item2 of canMoveList) {\r\n if (item2.canSavePiecePositions.indexOf(item.ownerPiece.position.toString()) > -1) {\r\n item.savedByPieces.push(item2.ownerPiece)\r\n }\r\n }\r\n })\r\n return canMoveList\r\n}\r\n\r\n// 获取移动后可以将军或保护其他棋子的位置\r\nfunction getCanSavePiecePosition (ownerPiece, canMoveBlankPieces, needSavePosition, enemyCanMovePositions) {\r\n return canMoveBlankPieces.find(item => {\r\n if (enemyCanMovePositions.indexOf(item.position.toString()) > -1) return false // 如果下一步有危险,则不行动\r\n const tempPiece = ownerPiece.copy()\r\n tempPiece.position = item.position // 模拟棋子移动下一步,获取下一步后可以行动的位置信息\r\n const canMovePositions = Rule.getMoveLine(tempPiece)\r\n const canMovePieces = handlePosition(canMovePositions, tempPiece.camp)\r\n if (canMovePieces.king) return true\r\n if (needSavePosition) {\r\n // 保护的棋子位置\r\n const canSavePiecePositions = canMovePieces.owners.map((item) => item && item.position ? item.position.toString() : '')\r\n if (canSavePiecePositions.indexOf(needSavePosition) > -1) return true\r\n } else {\r\n // 可以消除的棋子位置\r\n return canMovePieces.others.length > 0\r\n }\r\n })\r\n}\r\n\r\n/**\r\n * 获取可以消除的对方棋子, 优先进攻帅\r\n * @param {所有可以移动的位置坐标} canMovePosition\r\n * @param {当前阵营} currentCamp\r\n * @returns {\r\n * king: null, // 帅\r\n * others: [], // 其他可以消除的棋子\r\n * owners: [], // 我方可以被保护的棋子\r\n * blanks: [] // 其他空白的棋子\r\n * }\r\n */\r\nfunction handlePosition (canMovePosition, currentCamp) {\r\n let canMovePieces = {\r\n king: null, // 帅\r\n others: [], // 其他可以消除的棋子\r\n owners: [], // 我方可以被保护的棋子\r\n blanks: [] // 其他空白的棋子\r\n }\r\n for (const position of canMovePosition) {\r\n const piece = Game.getPieceByPosition(position)\r\n if (piece.camp === 0) { // 空白\r\n canMovePieces.blanks.push(piece)\r\n } else if (currentCamp !== piece.camp) { // 敌方阵营\r\n if (piece.name === 'k') {\r\n canMovePieces.king = piece // 帅\r\n } else {\r\n canMovePieces.others.push(piece)\r\n }\r\n } else if (currentCamp === piece.camp) { // 我方阵营\r\n canMovePieces.owners.push(piece)\r\n }\r\n }\r\n return canMovePieces\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/game/robot.js","\r\n\r\n\r\n\r\n\r\n\n\n\n// WEBPACK FOOTER //\n// src/pages/index.vue","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:\"status\",class:_vm.nextCamp > 0 ? 'red': ''},[_vm._v(\"\\n \"+_vm._s(_vm.nextCamp > 0 ? '红棋' : '黑棋')+\"\\n \"),_c('div',{staticClass:\"options\"},[_c('div',{on:{\"click\":_vm.backStep}},[_vm._v(\"悔棋\")]),_vm._v(\" \"),_c('div',{on:{\"click\":_vm.robot}},[_vm._v(\"人机\")])])]),_vm._v(\" \"),_c('div',{staticClass:\"board\"},[_c('div',{staticClass:\"board-wrap\"},[_vm._l((_vm.blankMap),function(item,index){return _c('div',{key:'black' + index,staticClass:\"piece blank-item\",class:_vm.handleHighLight(item),style:(_vm.handlePosition(item.position)),on:{\"click\":function($event){return _vm.clickPiece(item)}}})}),_vm._v(\" \"),_vm._l((_vm.blackPieces),function(item){return _c('div',{key:'black' + item.name,staticClass:\"piece\",class:['black-' + item.name, _vm.handleHighLight(item)],style:(_vm.handlePosition(item.position)),on:{\"click\":function($event){return _vm.clickPiece(item)}}})}),_vm._v(\" \"),_vm._l((_vm.redPieces),function(item){return _c('div',{key:'red' + item.name,staticClass:\"piece\",class:['red-' + item.name, _vm.handleHighLight(item)],style:(_vm.handlePosition(item.position)),on:{\"click\":function($event){return _vm.clickPiece(item)}}})})],2)]),_vm._v(\" \"),(_vm.over)?_c('div',{staticClass:\"success-panel\"},[_c('div',{staticClass:\"success-title\"},[_vm._v(_vm._s(_vm.winCamp > 0 ? '红棋' : '黑棋')+\"赢了!\")]),_vm._v(\" \"),_c('div',{staticClass:\"restart\",on:{\"click\":_vm.begin}},[_vm._v(\"再来一局\")]),_vm._v(\" \"),_c('div',{staticClass:\"restart back\",on:{\"click\":_vm.moreGame}},[_vm._v(\"更多游戏\")])]):_vm._e()])}\nvar staticRenderFns = []\nvar esExports = { render: render, staticRenderFns: staticRenderFns }\nexport default esExports\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/vue-loader/lib/template-compiler?{\"id\":\"data-v-ad26c7ec\",\"hasScoped\":true,\"transformToRequire\":{\"video\":[\"src\",\"poster\"],\"source\":\"src\",\"img\":\"src\",\"image\":\"xlink:href\"},\"buble\":{\"transforms\":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/pages/index.vue\n// module id = null\n// module chunks = ","function injectStyle (ssrContext) {\n require(\"!!../../node_modules/extract-text-webpack-plugin/dist/loader.js?{\\\"omit\\\":1,\\\"remove\\\":true}!vue-style-loader!css-loader?{\\\"sourceMap\\\":true}!../../node_modules/vue-loader/lib/style-compiler/index?{\\\"vue\\\":true,\\\"id\\\":\\\"data-v-ad26c7ec\\\",\\\"scoped\\\":true,\\\"hasInlineConfig\\\":false}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./index.vue\")\n}\nvar normalizeComponent = require(\"!../../node_modules/vue-loader/lib/component-normalizer\")\n/* script */\nexport * from \"!!babel-loader!../../node_modules/vue-loader/lib/selector?type=script&index=0!./index.vue\"\nimport __vue_script__ from \"!!babel-loader!../../node_modules/vue-loader/lib/selector?type=script&index=0!./index.vue\"\n/* template */\nimport __vue_template__ from \"!!../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-ad26c7ec\\\",\\\"hasScoped\\\":true,\\\"transformToRequire\\\":{\\\"video\\\":[\\\"src\\\",\\\"poster\\\"],\\\"source\\\":\\\"src\\\",\\\"img\\\":\\\"src\\\",\\\"image\\\":\\\"xlink:href\\\"},\\\"buble\\\":{\\\"transforms\\\":{}}}!../../node_modules/vue-loader/lib/selector?type=template&index=0!./index.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = \"data-v-ad26c7ec\"\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_template__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/index.vue\n// module id = null\n// module chunks = ","import Vue from 'vue'\r\nimport Router from 'vue-router'\r\nimport Index from '@/pages/index'\r\n\r\nVue.use(Router)\r\n\r\nexport default new Router({\r\n routes: [\r\n {\r\n path: '/',\r\n name: 'Index',\r\n component: Index\r\n }\r\n ]\r\n})\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/router/index.js","// The Vue build version to load with the `import` command\r\n// (runtime-only or standalone) has been set in webpack.base.conf with an alias.\r\nimport Vue from 'vue'\r\nimport App from './App'\r\nimport router from './router'\r\n\r\nVue.config.productionTip = false\r\n\r\n/* eslint-disable no-new */\r\nnew Vue({\r\n el: '#app',\r\n router,\r\n components: { App },\r\n template: ''\r\n})\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.js"],"sourceRoot":""} --------------------------------------------------------------------------------