diff --git a/babel.config.js b/babel.config.js index e9558405fdcc02f12d757acb308e02937a7444f1..3f453d445802728801d7a55ba414c26655784ef7 100644 --- a/babel.config.js +++ b/babel.config.js @@ -2,4 +2,4 @@ module.exports = { presets: [ '@vue/cli-plugin-babel/preset' ] -} +}; diff --git a/dist/index.html b/dist/index.html index 204e9851eecb034ff256d2c49073873b78d5bb8b..c2a508d3e2ab4c8a1539df954e04d1147b72f58a 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1 +1 @@ -Vue App
\ No newline at end of file +Vue App
\ No newline at end of file diff --git a/dist/js/app.44f54d0e.js b/dist/js/app.44f54d0e.js deleted file mode 100644 index f8334d1f6f0f02a6b8126319b45f348e614621a3..0000000000000000000000000000000000000000 --- a/dist/js/app.44f54d0e.js +++ /dev/null @@ -1,2 +0,0 @@ -(function(e){function t(t){for(var i,l,o=t[0],a=t[1],h=t[2],u=0,g=[];u=2&&a[a.length-1][0].number<=14&&a[0][0].number+a.length-1===a[a.length-1][0].number){if(t.length-3*a.length===a.length)return{type:"threeWithOneList",poker:t,list:a.map((function(e){return{three:e}}))};if(o.length===a.length)return{type:"threeWithTwoList",poker:t,list:a.map((function(e){return{three:e}}))}}return t.length>=5&&t[t.length-1].number<=14&&l.length===t.length&&t[0].number+t.length-1===t[t.length-1].number?{type:"oneList",poker:t,list:l.map((function(e){return{one:e}}))}:t.length>=6&&t[t.length-1].number<=14&&t.length%2===0&&o.length===t.length/2&&t[0].number+t.length/2-1===t[t.length-1].number?{type:"twoList",poker:t,list:o.map((function(e){return{two:e}}))}:t.length>=6&&t[t.length-1].number<=14&&t.length%3===0&&a.length===t.length/3&&t[0].number+t.length/3-1===t[t.length-1].number&&{type:"threeList",poker:t,list:a.map((function(e){return{three:e}}))}}},{key:"pokerListToString",value:function(e){for(var t="",r=0;r0)u={type:e,poker:l[0],one:l[0]};else if(o.length>0){var g=o[0].slice(0,1);u={type:e,poker:g,one:g}}else if(a.length>0){var f=a[0].slice(0,1);u={type:e,poker:f,one:f}}}else if("two"===e){if(o.length>0)u={type:e,poker:o[0],two:o[0]};else if(a.length>0){var c=a[0].slice(0,2);u={type:e,poker:c,one:c}}}else if("three"===e)a.length>0&&(u={type:e,poker:a[0],three:a[0]});else if("threeWithOne"===e){if(a.length>0){var y;if(l.length>0)y=l[0];else if(o.length>0)y=o[0].slice(0,1);else if(a.length>0)for(var k=0;k0&&(u={type:e,poker:h[0],four:h[0]});else if("threeWithTwo"===e){if(a.length>0){var d;if(o.length>0)d=o[0];else if(a.length>0)for(var m=0;m0)l.length>0?b=l[0]:o.length>0?b=o[0].slice(0,1):a.length>0&&(b=a[0].slice(0,1)),b&&(u={type:e,poker:h[0].concat(b),four:h[0],one:b})}else if("fourWithTwo"===e){var v;if(h.length>0)o.length>0?v=o[0]:a.length>0&&(v=a[0].slice(0,2)),v&&(u={type:e,poker:h[0].concat(v),four:h[0],two:v})}else if("threeWithOneList"===e){if(a.length>=2)for(var L=0;L=2)for(var B=0;B=5)for(var I=0;I=3)for(var C=0;C=2)for(var J=0;J=2)for(var E=0;E0){for(var f=0;fe.one[0].number){g={type:u,poker:l[f],one:l[f]};break}}else if(o.length>0){for(var c=0;ce.one[0].number){var y=o[c].slice(0,1);g={type:u,poker:y,one:y};break}}else if(a.length>0)for(var k=0;ke.one[0].number){var d=a[k].slice(0,1);g={type:u,poker:d,one:d};break}}else if("two"===u){if(o.length>0){for(var m=0;me.two[0].number){g={type:u,poker:o[m],two:o[m]};break}}else if(a.length>0)for(var b=0;be.two[0].number){var v=a[b].slice(0,2);g={type:u,poker:v,one:v};break}}else if("three"===u){if(a.length>0)for(var L=0;Le.three[0].number){g={type:u,poker:a[L],three:a[L]};break}}else if("threeWithOne"===u){if(a.length>0)for(var x=0;xe.three[0].number){var S=void 0;if(l.length>0)S=l[0];else if(o.length>0)S=o[0].slice(0,1);else if(a.length>0)for(var w=0;w0)for(var O=0;Oe.three[0].number){var P=void 0;if(o.length>0)P=o[0];else if(a.length>0)for(var _=0;_0)for(var j=0;je.four[0].number){var T=void 0;l.length>0?T=l[0]:o.length>0?T=o[0].slice(0,1):a.length>0&&(T=a[0].slice(0,1)),T&&(g={type:u,poker:h[j].concat(T),four:h[j],one:T});break}}else if("fourWithTwo"===u){if(h.length>0)for(var B=0;Be.four[0].number){var W=void 0;o.length>0?W=o[0]:a.length>0&&(W=a[0].slice(0,2)),W&&(g={type:u,poker:h[B].concat(W),four:h[B],two:W});break}}else if("threeWithOneList"===u){if(a.length>=e.list.length)for(var M=0;Me.list[0].three[0].number&&a[M][0].number+e.list.length-1===a[M+e.list.length-1][0].number&&a[M+e.list.length-1][0].number<=14){for(var A=[],N=0;N=e.list.length)for(var G=0;Ge.list[0].three[0].number&&a[G][0].number+e.list.length-1===a[G+e.list.length-1][0].number&&a[G+e.list.length-1][0].number<=14){for(var J=[],$=0;$=e.list.length)for(var q=0;qe.list[0].one[0].number&&l[q][0].number+e.list.length-1===l[q+e.list.length-1][0].number&&l[q+e.list.length-1][0].number<=14){var U=l.slice(q,q+e.list.length);g={type:u,poker:U.flat(1),list:U.map((function(e){return{one:e}}))};break}}else if("twoList"===u){if(o.length>=e.list.length)for(var V=0;Ve.list[0].two[0].number&&o[V][0].number+e.list.length-1===o[V+e.list.length-1][0].number&&o[V+e.list.length-1][0].number<=14){var Y=o.slice(V,V+e.list.length);g={type:u,poker:Y.flat(1),list:Y.map((function(e){return{two:e}}))};break}}else if("threeList"===u){if(a.length>=e.list.length)for(var Z=0;Ze.list[0].two[0].number&&a[Z][0].number+e.list.length-1===a[Z+e.list.length-1][0].number&&a[Z+e.list.length-1][0].number<=14){var ee=a.slice(Z,Z+e.list.length);g={type:u,poker:ee.flat(1),list:ee.map((function(e){return{three:e}}))};break}}else if("four"===u&&h.length>0)for(var te=0;tee.four[0].number){g={type:u,poker:h[te],four:h[te]};break}if(g||"four"===u||h.length>0&&(g={type:"four",poker:h[0],four:h[0]}),!g&&"sx"!==u&&l.length>1&&16===l[l.length-2]){var re=l[l.length-2].concat(l[l.length-1]);g={type:"sx",poker:re,sx:re}}return g||(g={type:"pass",poker:["pass"]}),g}},{key:"playByObj",value:function(e){var t=this.getObjByObj(e),r=this.deleteFromPokerListAndSendByObj(t);r||alert("error!")}},{key:"getListByList",value:function(e){var t=[];if("pass"===e[0])return["pass"];for(var r=0;r0){var t=e.splice(0,1)[0];this.pokerList.push(t)}this.sortPoker()}},{key:"handleList",value:function(e){if(e){var t=u.getObjByPokerList(e);if(t){if("pass"===t.type)return this.sendPoker(t),!0;var r=this.getLastObj();if(r){if(r.type===t.type){var i=this.compareTwoObj(t,r);return i?(this.sendPoker(t),!0):(this.listBackToPokerList(e),alert("have to bigger than "+u.pokerListToString(r.poker)),!1)}return"sx"===t.type||"four"===t.type&&"sx"!==r.type?(this.sendPoker(t),!0):(this.listBackToPokerList(e),alert("type is not "+r.type+"!"),!1)}return this.sendPoker(t),!0}return this.listBackToPokerList(e),alert("type error!"),!1}return alert("poker error!"),!1}},{key:"playByPokerList",value:function(e){if(this.game.currentPlayer!==this)return alert("请等待 "+this.game.currentPlayer.name+" 出牌"),!1;var t=this.getListByList(e);return this.handleList(t)}},{key:"playByString",value:function(e){if(this.game.currentPlayer!==this)return alert("请等待 "+this.game.currentPlayer.name+" 出牌"),!1;var t=this.getListByString(e);return this.handleList(t)}},{key:"compareTwoObj",value:function(e,t){return(!e.list||!t.list||e.list.length===t.list.length)&&("one"===e.type?e.one[0].number>t.one[0].number:"two"===e.type?e.two[0].number>t.two[0].number:"three"===e.type||"threeWithOne"===e.type||"threeWithTwo"===e.type?e.three[0].number>t.three[0].number:"fourWithOne"===e.type||"fourWithTwo"===e.type?e.four[0].number>t.four[0].number:"threeWithOneList"===e.type||"threeWithTwoList"===e.type?e.list[0].three[0].number>t.list[0].three[0].number:"oneList"===e.type?e.list[0].one[0].number>t.list[0].one[0].number:"twoList"===e.type?e.list[0].two[0].number>t.list[0].two[0].number:"threeList"===e.type?e.list[0].three[0].number>t.list[0].three[0].number:"four"===e.type?e.four[0].number>t.four[0].number:void 0)}},{key:"getAndDeleteOnePokerByNumber",value:function(e){for(var t=0;t3);do{var i=this.pokerList.splice(0,1)[0];this.dizhu.addPoker(i)}while(this.pokerList.length>0);for(var n=0;n=2 && Count3List[Count3List.length-1][0].number<=14 && Count3List[0][0].number+Count3List.length-1===Count3List[Count3List.length-1][0].number){\r\n //threeWithOneList\r\n if(pokerList.length-3*Count3List.length===Count3List.length){\r\n return {\r\n type:'threeWithOneList',\r\n poker: pokerList,\r\n list: Count3List.map(function (item) {\r\n return {\r\n three: item,\r\n };\r\n }),\r\n };\r\n }else{\r\n //threeWithTwoList\r\n if(Count2List.length===Count3List.length){\r\n return {\r\n type:'threeWithTwoList',\r\n poker: pokerList,\r\n list: Count3List.map(function (item) {\r\n return {\r\n three: item,\r\n };\r\n }),\r\n };\r\n }\r\n }\r\n }\r\n\r\n //判断oneList\r\n if(pokerList.length >= 5 && pokerList[pokerList.length-1].number<=14 && Count1List.length === pokerList.length && pokerList[0].number+pokerList.length-1===pokerList[pokerList.length-1].number){\r\n return {\r\n type:'oneList',\r\n poker: pokerList,\r\n list: Count1List.map(function (item) {\r\n return {\r\n one: item,\r\n }\r\n }),\r\n }\r\n }\r\n\r\n //判断twoList\r\n if(pokerList.length >= 6 && pokerList[pokerList.length-1].number<=14 && pokerList.length%2 === 0 && Count2List.length === pokerList.length/2 && pokerList[0].number+pokerList.length/2-1===pokerList[pokerList.length-1].number){\r\n return {\r\n type:'twoList',\r\n poker: pokerList,\r\n list: Count2List.map(function (item) {\r\n return {\r\n two: item,\r\n }\r\n }),\r\n }\r\n }\r\n\r\n //判断threeList\r\n if(pokerList.length >= 6 && pokerList[pokerList.length-1].number<=14 && pokerList.length%3 === 0 && Count3List.length === pokerList.length/3 && pokerList[0].number+pokerList.length/3-1===pokerList[pokerList.length-1].number){\r\n return {\r\n type:'threeList',\r\n poker: pokerList,\r\n list: Count3List.map(function (item) {\r\n return {\r\n three: item,\r\n }\r\n }),\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n static pokerListToString(pokerList){\r\n let result = '';\r\n for(let i=0; i0){\r\n obj = {\r\n type: type,\r\n poker: Count1List[0],\r\n one: Count1List[0],\r\n };\r\n }else if(Count2List.length>0){\r\n let poker = Count2List[0].slice(0,1);\r\n obj = {\r\n type: type,\r\n poker: poker,\r\n one: poker,\r\n };\r\n }else if(Count3List.length>0){\r\n let poker = Count3List[0].slice(0,1);\r\n obj = {\r\n type: type,\r\n poker: poker,\r\n one: poker,\r\n };\r\n }\r\n }else if(type === 'two'){\r\n if(Count2List.length>0){\r\n obj = {\r\n type: type,\r\n poker: Count2List[0],\r\n two: Count2List[0],\r\n };\r\n }else if(Count3List.length>0){\r\n let poker = Count3List[0].slice(0,2);\r\n obj = {\r\n type: type,\r\n poker: poker,\r\n one: poker,\r\n };\r\n }\r\n }else if(type === 'three'){\r\n if(Count3List.length>0){\r\n obj = {\r\n type: type,\r\n poker: Count3List[0],\r\n three: Count3List[0],\r\n };\r\n }\r\n }else if(type === 'threeWithOne'){\r\n if(Count3List.length>0){\r\n let one;\r\n if(Count1List.length>0){\r\n one = Count1List[0];\r\n }else if(Count2List.length>0){\r\n one = Count2List[0].slice(0,1);\r\n }else if(Count3List.length>0){\r\n for(let j=0; j0){\r\n obj = {\r\n type: type,\r\n poker: Count4List[0],\r\n four: Count4List[0],\r\n };\r\n }\r\n }else if(type === 'threeWithTwo'){\r\n if(Count3List.length>0){\r\n let two;\r\n if(Count2List.length>0){\r\n two = Count2List[0];\r\n }else if(Count3List.length>0){\r\n for(let j=0; j0){\r\n let one;\r\n if(Count1List.length>0){\r\n one = Count1List[0];\r\n }else if(Count2List.length>0){\r\n one = Count2List[0].slice(0,1);\r\n }else if(Count3List.length>0){\r\n one = Count3List[0].slice(0,1);\r\n }\r\n\r\n if(one){\r\n obj = {\r\n type: type,\r\n poker: Count4List[0].concat(one),\r\n four: Count4List[0],\r\n one: one,\r\n };\r\n }\r\n }\r\n }else if(type === 'fourWithTwo'){\r\n if(Count4List.length>0){\r\n let two;\r\n if(Count2List.length>0){\r\n two = Count2List[0];\r\n }else if(Count3List.length>0){\r\n two = Count3List[0].slice(0,2);\r\n }\r\n\r\n if(two){\r\n obj = {\r\n type: type,\r\n poker: Count4List[0].concat(two),\r\n four: Count4List[0],\r\n two: two,\r\n };\r\n }\r\n }\r\n }else if(type === 'threeWithOneList'){\r\n if(Count3List.length>=2){\r\n for(let i=0; i=2){\r\n for(let i=0; i=5){\r\n for(let i=0; i=3 ){\r\n for(let i=0; i=2 ){\r\n for(let i=0; i=2){\r\n for(let i=0; i0){\r\n for(let i=0; ilastObj.one[0].number){\r\n obj = {\r\n type: type,\r\n poker: Count1List[i],\r\n one: Count1List[i],\r\n };\r\n break;\r\n }\r\n }\r\n }else if(Count2List.length>0){\r\n for(let i=0; ilastObj.one[0].number){\r\n let poker = Count2List[i].slice(0,1);\r\n obj = {\r\n type: type,\r\n poker: poker,\r\n one: poker,\r\n };\r\n break;\r\n }\r\n }\r\n }else if(Count3List.length>0){\r\n for(let i=0; ilastObj.one[0].number){\r\n let poker = Count3List[i].slice(0,1);\r\n obj = {\r\n type: type,\r\n poker: poker,\r\n one: poker,\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n }else if(type === 'two'){\r\n if(Count2List.length>0){\r\n for(let i=0; ilastObj.two[0].number){\r\n obj = {\r\n type: type,\r\n poker: Count2List[i],\r\n two: Count2List[i],\r\n };\r\n break;\r\n }\r\n }\r\n }else if(Count3List.length>0){\r\n for(let i=0; ilastObj.two[0].number){\r\n let poker = Count3List[i].slice(0,2);\r\n obj = {\r\n type: type,\r\n poker: poker,\r\n one: poker,\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n }else if(type === 'three'){\r\n if(Count3List.length>0){\r\n for(let i=0; ilastObj.three[0].number){\r\n obj = {\r\n type: type,\r\n poker: Count3List[i],\r\n three: Count3List[i],\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n }else if(type === 'threeWithOne'){\r\n if(Count3List.length>0){\r\n for(let i=0; ilastObj.three[0].number){\r\n\r\n let one;\r\n if(Count1List.length>0){\r\n one = Count1List[0];\r\n }else if(Count2List.length>0){\r\n one = Count2List[0].slice(0,1);\r\n }else if(Count3List.length>0){\r\n for(let j=0; j0){\r\n for(let i=0; ilastObj.three[0].number){\r\n\r\n let two;\r\n if(Count2List.length>0){\r\n two = Count2List[0];\r\n }else if(Count3List.length>0){\r\n for(let j=0; j0){\r\n for(let i=0; ilastObj.four[0].number){\r\n\r\n let one;\r\n if(Count1List.length>0){\r\n one = Count1List[0];\r\n }else if(Count2List.length>0){\r\n one = Count2List[0].slice(0,1);\r\n }else if(Count3List.length>0){\r\n one = Count3List[0].slice(0,1);\r\n }\r\n\r\n if(one){\r\n obj = {\r\n type: type,\r\n poker: Count4List[i].concat(one),\r\n four: Count4List[i],\r\n one: one,\r\n };\r\n }\r\n break;\r\n\r\n }\r\n }\r\n }\r\n }else if(type === 'fourWithTwo'){\r\n if(Count4List.length>0){\r\n for(let i=0; ilastObj.four[0].number){\r\n\r\n let two;\r\n if(Count2List.length>0){\r\n two = Count2List[0];\r\n }else if(Count3List.length>0){\r\n two = Count3List[0].slice(0,2);\r\n }\r\n\r\n if(two){\r\n obj = {\r\n type: type,\r\n poker: Count4List[i].concat(two),\r\n four: Count4List[i],\r\n two: two,\r\n };\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n }else if(type === 'threeWithOneList'){\r\n if(Count3List.length>=lastObj.list.length){\r\n for(let i=0; ilastObj.list[0].three[0].number && Count3List[i][0].number+lastObj.list.length-1===Count3List[i+lastObj.list.length-1][0].number && Count3List[i+lastObj.list.length-1][0].number<=14){\r\n\r\n let oneList = [];\r\n\r\n for(let j=0; j=lastObj.list.length){\r\n for(let i=0; ilastObj.list[0].three[0].number && Count3List[i][0].number+lastObj.list.length-1===Count3List[i+lastObj.list.length-1][0].number && Count3List[i+lastObj.list.length-1][0].number<=14){\r\n\r\n let twoList = [];\r\n\r\n for(let j=0; j=lastObj.list.length ){\r\n for(let i=0; ilastObj.list[0].one[0].number && Count1List[i][0].number+lastObj.list.length-1===Count1List[i+lastObj.list.length-1][0].number && Count1List[i+lastObj.list.length-1][0].number<=14){\r\n let list = Count1List.slice(i,i+lastObj.list.length);\r\n obj = {\r\n type: type,\r\n poker: list.flat(1),\r\n list: list.map(function (item) {\r\n return {\r\n one: item,\r\n }\r\n }),\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n }else if(type === 'twoList'){\r\n if(Count2List.length>=lastObj.list.length ){\r\n for(let i=0; ilastObj.list[0].two[0].number && Count2List[i][0].number+lastObj.list.length-1===Count2List[i+lastObj.list.length-1][0].number && Count2List[i+lastObj.list.length-1][0].number<=14){\r\n let list = Count2List.slice(i,i+lastObj.list.length);\r\n obj = {\r\n type: type,\r\n poker: list.flat(1),\r\n list: list.map(function (item) {\r\n return {\r\n two: item,\r\n }\r\n }),\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n }else if(type === 'threeList'){\r\n if(Count3List.length>=lastObj.list.length ){\r\n for(let i=0; ilastObj.list[0].two[0].number && Count3List[i][0].number+lastObj.list.length-1===Count3List[i+lastObj.list.length-1][0].number && Count3List[i+lastObj.list.length-1][0].number<=14){\r\n let list = Count3List.slice(i,i+lastObj.list.length);\r\n obj = {\r\n type: type,\r\n poker: list.flat(1),\r\n list: list.map(function (item) {\r\n return {\r\n three: item,\r\n }\r\n }),\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n }else if(type === 'four'){\r\n if(Count4List.length>0){\r\n for(let i=0; ilastObj.four[0].number){\r\n obj = {\r\n type: type,\r\n poker: Count4List[i],\r\n four: Count4List[i],\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if(!obj && type!=='four'){\r\n\r\n if(Count4List.length>0){\r\n obj = {\r\n type: 'four',\r\n poker: Count4List[0],\r\n four: Count4List[0],\r\n };\r\n }\r\n\r\n }\r\n\r\n if(!obj && type!=='sx'){\r\n\r\n if(Count1List.length>1){\r\n if(Count1List[Count1List.length-2] === 16){\r\n let poker = Count1List[Count1List.length-2].concat(Count1List[Count1List.length-1]);\r\n obj = {\r\n type: 'sx',\r\n poker: poker,\r\n sx: poker,\r\n };\r\n }\r\n }\r\n\r\n }\r\n\r\n if(!obj){\r\n obj = {\r\n type: 'pass',\r\n poker: ['pass'],\r\n };\r\n }\r\n\r\n return obj;\r\n }\r\n\r\n playByObj(lastObj){\r\n\r\n let obj = this.getObjByObj(lastObj);\r\n let success = this.deleteFromPokerListAndSendByObj(obj);\r\n if(!success){\r\n alert('error!');\r\n }\r\n\r\n }\r\n\r\n getListByList(list){\r\n let tempList = [];\r\n if(list[0] === 'pass'){\r\n return ['pass'];\r\n }\r\n for(let i=0; i0){\r\n let poker = list.splice(0,1)[0];\r\n this.pokerList.push(poker);\r\n }\r\n this.sortPoker();\r\n }\r\n\r\n handleList(list){\r\n if(list){\r\n let obj = Poker.getObjByPokerList(list);\r\n if(obj){\r\n if(obj.type === 'pass'){\r\n this.sendPoker(obj);\r\n return true;\r\n }\r\n let lastObj = this.getLastObj();\r\n if(lastObj){\r\n if(lastObj.type === obj.type){\r\n let comp = this.compareTwoObj(obj, lastObj);\r\n if(comp){\r\n this.sendPoker(obj);\r\n return true;\r\n }else{\r\n this.listBackToPokerList(list);\r\n alert('have to bigger than '+Poker.pokerListToString(lastObj.poker));\r\n return false;\r\n }\r\n\r\n }else{\r\n\r\n if(obj.type === 'sx'){\r\n this.sendPoker(obj);\r\n return true;\r\n }else if(obj.type === 'four' && lastObj.type!=='sx'){\r\n this.sendPoker(obj);\r\n return true;\r\n }\r\n\r\n this.listBackToPokerList(list);\r\n alert('type is not '+lastObj.type+'!');\r\n return false;\r\n }\r\n }else{\r\n this.sendPoker(obj);\r\n return true;\r\n }\r\n\r\n }else{\r\n this.listBackToPokerList(list);\r\n alert('type error!');\r\n return false;\r\n }\r\n\r\n }else{\r\n alert('poker error!');\r\n return false;\r\n }\r\n }\r\n\r\n playByPokerList(pokerList){\r\n if(this.game.currentPlayer!==this){\r\n alert('请等待 '+this.game.currentPlayer.name+' 出牌');\r\n return false;\r\n }\r\n\r\n let list = this.getListByList(pokerList);\r\n return this.handleList(list);\r\n }\r\n\r\n playByString(str){\r\n if(this.game.currentPlayer!==this){\r\n alert('请等待 '+this.game.currentPlayer.name+' 出牌');\r\n return false;\r\n }\r\n\r\n let list = this.getListByString(str);\r\n return this.handleList(list);\r\n }\r\n\r\n compareTwoObj(obj1, obj2) {\r\n if(obj1.list && obj2.list){\r\n if(obj1.list.length!==obj2.list.length){\r\n return false;\r\n }\r\n }\r\n\r\n if (obj1.type === 'one') {\r\n return obj1.one[0].number > obj2.one[0].number;\r\n } else if (obj1.type === 'two') {\r\n return obj1.two[0].number > obj2.two[0].number;\r\n } else if (obj1.type === 'three') {\r\n return obj1.three[0].number > obj2.three[0].number;\r\n } else if (obj1.type === 'threeWithOne') {\r\n return obj1.three[0].number > obj2.three[0].number;\r\n } else if (obj1.type === 'threeWithTwo') {\r\n return obj1.three[0].number > obj2.three[0].number;\r\n } else if (obj1.type === 'fourWithOne') {\r\n return obj1.four[0].number > obj2.four[0].number;\r\n } else if (obj1.type === 'fourWithTwo') {\r\n return obj1.four[0].number > obj2.four[0].number;\r\n } else if (obj1.type === 'threeWithOneList') {\r\n return obj1.list[0].three[0].number > obj2.list[0].three[0].number;\r\n } else if (obj1.type === 'threeWithTwoList') {\r\n return obj1.list[0].three[0].number > obj2.list[0].three[0].number;\r\n } else if (obj1.type === 'oneList') {\r\n return obj1.list[0].one[0].number > obj2.list[0].one[0].number;\r\n } else if (obj1.type === 'twoList') {\r\n return obj1.list[0].two[0].number > obj2.list[0].two[0].number;\r\n } else if (obj1.type === 'threeList') {\r\n return obj1.list[0].three[0].number > obj2.list[0].three[0].number;\r\n } else if (obj1.type === 'four') {\r\n return obj1.four[0].number > obj2.four[0].number;\r\n }\r\n }\r\n\r\n\r\n getAndDeleteOnePokerByNumber(number){\r\n for(let i=0; i3);\r\n\r\n do{\r\n let poker = this.pokerList.splice(0,1)[0];\r\n this.dizhu.addPoker(poker);\r\n }while(this.pokerList.length>0);\r\n\r\n for(let i=0; i\n
\n
\n \n {{player2Str[0]}}\n
\n {{player2Str[1]}}\n

\n {{player2Str[2]}}\n
\n
\n\n
\n \n {{player1Str[0]}}\n
\n {{player1Str[1]}}\n

\n {{player1Str[2]}}\n
\n
\n\n
\n \n {{player0Str[0]}}\n
\n {{player0Str[1]}}\n

\n {{player0Str[2]}}\n
\n
\n \n \n \n
\n
\n\n
\n
\n {{deskStr[0]}}\n
\n {{deskStr[1]}}\n
\n
\n\n
\n \n
\n
\n\n\n\n\n\n\n","import mod from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./HelloWorld.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./HelloWorld.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./HelloWorld.vue?vue&type=template&id=62298b0c&scoped=true&\"\nimport script from \"./HelloWorld.vue?vue&type=script&lang=js&\"\nexport * from \"./HelloWorld.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"62298b0c\",\n null\n \n)\n\nexport default component.exports","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticStyle:{\"user-select\":\"none\"}},[_c('div',{staticStyle:{\"width\":\"300px\",\"height\":\"300px\",\"float\":\"left\",\"position\":\"fixed\",\"left\":\"0\",\"top\":\"0px\",\"background-color\":\"aliceblue\",\"text-align\":\"center\"}},[_c('span',[_vm._v(\" 手牌:\"+_vm._s(_vm.player2Str[1])+\" \")])]),_c('div',{staticStyle:{\"width\":\"300px\",\"height\":\"300px\",\"float\":\"left\",\"position\":\"fixed\",\"right\":\"0\",\"top\":\"0px\",\"background-color\":\"aliceblue\",\"text-align\":\"center\"}},[_c('span',[_vm._v(\" 手牌:\"+_vm._s(_vm.player1Str[1])+\" \")])]),_c('div',{staticStyle:{\"width\":\"300px\",\"height\":\"300px\",\"float\":\"left\",\"position\":\"fixed\",\"left\":\"600px\",\"top\":\"0px\",\"background-color\":\"aliceblue\",\"text-align\":\"center\"}},[_c('div',{staticStyle:{\"width\":\"300px\",\"word-wrap\":\"break-word\"}},[_vm._v(\" 已出的牌: \"),_c('br'),_vm._v(\" \"+_vm._s(_vm.deskStr[1])+\" \")])]),_c('div',{staticStyle:{\"position\":\"fixed\",\"left\":\"600px\",\"top\":\"300px\"}},[_c('button',{on:{\"click\":_vm.reStart}},[_vm._v(\"开始新一局\")])]),_c('div',{staticStyle:{\"position\":\"fixed\",\"bottom\":\"0\",\"width\":\"100%\",\"height\":\"200px\",\"line-height\":\"200px\"},style:({ marginLeft: _vm.playerMarginLeft-150 + 'px' })},[_vm._v(\" 你是 \"+_vm._s(_vm.game.playerList[0].type==='nongmin'?'农民':'地主')+\" \")]),_c('div',{staticStyle:{\"position\":\"fixed\",\"bottom\":\"0\",\"width\":\"100%\",\"height\":\"200px\"},style:({ marginLeft: _vm.playerMarginLeft + 'px' })},_vm._l((_vm.game.playerList[0].pokerList),function(item){return _c('div',{staticClass:\"poker\",class:{ selected: item.selected },on:{\"mouseenter\":function($event){return _vm.enter($event,item)},\"mousedown\":function($event){return _vm.pickPoker(item)}}},[_vm._v(\" \"+_vm._s(item.text)+\" \")])}),0),_c('div',{staticStyle:{\"position\":\"fixed\",\"bottom\":\"200px\",\"width\":\"100%\",\"height\":\"100px\",\"text-align\":\"left\"}},[_c('div',{staticStyle:{\"width\":\"200px\",\"height\":\"30px\"},style:({ marginLeft: _vm.buttonMarginLeft + 'px' })},[_c('button',{staticStyle:{\"height\":\"30px\",\"border-radius\":\"4px\",\"float\":\"left\"},on:{\"click\":_vm.sendPoker2}},[_vm._v(\"出牌\")]),_c('button',{staticStyle:{\"height\":\"30px\",\"border-radius\":\"4px\",\"margin-left\":\"20px\",\"float\":\"right\"},on:{\"click\":_vm.pass}},[_vm._v(\"不出\")]),_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.game.currentPlayer===_vm.game.playerList[0]),expression:\"game.currentPlayer===game.playerList[0]\"}],staticStyle:{\"color\":\"red\",\"width\":\"150px\",\"border\":\"solid\",\"border-radius\":\"4px\",\"float\":\"left\"}},[_vm._v(\" 请在\"+_vm._s(_vm.game.second)+\"秒内出牌 \")])])]),(_vm.game.playerList[0].lastSendObj&&_vm.game.playerList[0].lastSendObj.poker[0].text)?_c('div',{staticStyle:{\"position\":\"fixed\",\"bottom\":\"350px\",\"width\":\"100%\",\"height\":\"200px\"},style:({ marginLeft: _vm.deskPokerMarginLeft + 'px' })},_vm._l((_vm.game.playerList[0].lastSendObj.poker),function(item){return _c('div',{staticClass:\"pokerDesk\"},[_vm._v(\" \"+_vm._s(item.text)+\" \")])}),0):_vm._e(),(_vm.game.playerList[0].lastSendObj&&!_vm.game.playerList[0].lastSendObj.poker[0].text)?_c('div',{staticStyle:{\"position\":\"fixed\",\"bottom\":\"350px\",\"width\":\"100%\",\"height\":\"200px\"},style:({ marginLeft: _vm.deskPokerMarginLeft + 'px' })},[_c('div',{staticStyle:{\"height\":\"100%\",\"width\":\"100px\",\"float\":\"left\",\"margin-left\":\"-50px\",\"font-size\":\"50px\"}},[_vm._v(\" pass \")])]):_vm._e(),_c('div',{staticStyle:{\"position\":\"fixed\",\"top\":\"40px\",\"left\":\"20px\",\"height\":\"200px\",\"width\":\"100px\",\"border\":\"solid 1px\",\"border-radius\":\"8px\",\"background-color\":\"azure\",\"text-align\":\"center\"}},[_c('p',[_vm._v(\" \"+_vm._s(_vm.game.playerList[2].type==='nongmin'?'农民':'地主')+\" \")]),_c('p',[_vm._v(\" \"+_vm._s(_vm.game.playerList[2].name)+\" \")]),_c('p',[_vm._v(\" 剩余 \"+_vm._s(_vm.game.playerList[2].pokerList.length)+\" 张 \")]),_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.game.currentPlayer===_vm.game.playerList[2]),expression:\"game.currentPlayer===game.playerList[2]\"}],staticStyle:{\"color\":\"red\",\"width\":\"150px\",\"border\":\"solid\",\"border-radius\":\"4px\",\"position\":\"absolute\",\"bottom\":\"-50px\",\"left\":\"0\"}},[_vm._v(\" 请在\"+_vm._s(_vm.game.second)+\"秒内出牌 \")])]),(_vm.game.playerList[2].lastSendObj&&_vm.game.playerList[2].lastSendObj.poker[0].text)?_c('div',{staticStyle:{\"position\":\"fixed\",\"top\":\"100px\",\"left\":\"200px\",\"height\":\"200px\"}},_vm._l((_vm.game.playerList[2].lastSendObj.poker),function(item){return _c('div',{staticClass:\"pokerDesk\"},[_vm._v(\" \"+_vm._s(item.text)+\" \")])}),0):_vm._e(),(_vm.game.playerList[2].lastSendObj&&!_vm.game.playerList[2].lastSendObj.poker[0].text)?_c('div',{staticStyle:{\"position\":\"fixed\",\"top\":\"100px\",\"left\":\"200px\",\"height\":\"200px\"}},[_c('div',{staticStyle:{\"height\":\"100%\",\"width\":\"100px\",\"float\":\"left\",\"margin-left\":\"-50px\",\"font-size\":\"50px\"}},[_vm._v(\" pass \")])]):_vm._e(),_c('div',{staticStyle:{\"position\":\"fixed\",\"top\":\"40px\",\"right\":\"20px\",\"height\":\"200px\",\"width\":\"100px\",\"border\":\"solid 1px\",\"border-radius\":\"8px\",\"background-color\":\"azure\",\"text-align\":\"center\"}},[_c('p',[_vm._v(\" \"+_vm._s(_vm.game.playerList[1].type==='nongmin'?'农民':'地主')+\" \")]),_c('p',[_vm._v(\" \"+_vm._s(_vm.game.playerList[1].name)+\" \")]),_c('p',[_vm._v(\" 剩余 \"+_vm._s(_vm.game.playerList[1].pokerList.length)+\" 张 \")]),_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.game.currentPlayer===_vm.game.playerList[1]),expression:\"game.currentPlayer===game.playerList[1]\"}],staticStyle:{\"color\":\"red\",\"width\":\"150px\",\"border\":\"solid\",\"border-radius\":\"4px\",\"position\":\"absolute\",\"bottom\":\"-50px\",\"right\":\"0\"}},[_vm._v(\" 请在\"+_vm._s(_vm.game.second)+\"秒内出牌 \")])]),(_vm.game.playerList[1].lastSendObj&&_vm.game.playerList[1].lastSendObj.poker[0].text)?_c('div',{staticStyle:{\"position\":\"fixed\",\"top\":\"100px\",\"right\":\"200px\",\"height\":\"200px\"}},_vm._l((_vm.game.playerList[1].lastSendObj.poker),function(item){return _c('div',{staticClass:\"pokerDesk\"},[_vm._v(\" \"+_vm._s(item.text)+\" \")])}),0):_vm._e(),(_vm.game.playerList[1].lastSendObj&&!_vm.game.playerList[1].lastSendObj.poker[0].text)?_c('div',{staticStyle:{\"position\":\"fixed\",\"top\":\"100px\",\"right\":\"200px\",\"height\":\"200px\"}},[_c('div',{staticStyle:{\"height\":\"100%\",\"width\":\"100px\",\"float\":\"left\",\"margin-left\":\"-50px\",\"font-size\":\"50px\"}},[_vm._v(\" pass \")])]):_vm._e()])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n\n\n\n","import mod from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Game.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Game.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./Game.vue?vue&type=template&id=4dff4871&scoped=true&\"\nimport script from \"./Game.vue?vue&type=script&lang=js&\"\nexport * from \"./Game.vue?vue&type=script&lang=js&\"\nimport style0 from \"./Game.vue?vue&type=style&index=0&id=4dff4871&scoped=true&lang=css&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"4dff4871\",\n null\n \n)\n\nexport default component.exports","\n\n\n\n\n","import mod from \"-!../node_modules/cache-loader/dist/cjs.js??ref--12-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/cache-loader/dist/cjs.js??ref--0-0!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../node_modules/cache-loader/dist/cjs.js??ref--12-0!../node_modules/thread-loader/dist/cjs.js!../node_modules/babel-loader/lib/index.js!../node_modules/cache-loader/dist/cjs.js??ref--0-0!../node_modules/vue-loader/lib/index.js??vue-loader-options!./App.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./App.vue?vue&type=template&id=51e9b17b&\"\nimport script from \"./App.vue?vue&type=script&lang=js&\"\nexport * from \"./App.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports","import Vue from 'vue'\nimport App from './App.vue'\n\nVue.config.productionTip = false;\n\nnew Vue({\n render: h => h(App),\n}).$mount('#app');\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/doudizhu/AI.js b/src/doudizhu/AI.js index 7af94172a5b10ea7fe3a13c6ac50d328f5251767..dd7af4af5d821de301f7c150711049036766bd61 100644 --- a/src/doudizhu/AI.js +++ b/src/doudizhu/AI.js @@ -56,15 +56,20 @@ class AI{ for(let i=0; i0){ + let curList = [Count3List[0]]; + let lists = []; + + for(let i2=1; i21){ - threeList.push(lists[i]); - }else{ - three.push(lists[i][0]); + lists.push(curList); + for(let i3=0; i31){ + threeList.push(lists[i3]); + }else{ + three.push(lists[i3][0]); + } } } - let curList2 = [Count2List[0]]; - let lists2 = []; - for(let i=1; i0){ + let curList2 = [Count2List[0]]; + let lists2 = []; + for(let i4=1; i42){ - twoList.push(lists2[i]); - }else{ - two = two.concat(lists2[i]); + lists2.push(curList2); + for(let i5=0; i52){ + twoList.push(lists2[i5]); + }else{ + two = two.concat(lists2[i5]); + } } } - let curList1 = [Count1List[0]]; - let lists1 = []; - for(let i=1; i0){ + let curList1 = [Count1List[0]]; + let lists1 = []; + for(let i6=1; i64){ - oneList.push(lists1[i]); - }else{ - one = one.concat(lists1[i]); + lists1.push(curList1); + for(let i7=0; i74){ + oneList.push(lists1[i7]); + }else{ + one = one.concat(lists1[i7]); + } } } //combine one two together - let oneIndex = 0; - let twoIndex = 0; - - let findlist = false; - - while(!findlist){ - let startN; - let lastN; - let ones = []; - let twos = []; - if(one[oneIndex][0].number0&&two.length>0){ + + let oneIndex = 0; + let twoIndex = 0; + + let findlist = false; + + while(true){ - do{ if(oneIndex>one.length-1&&twoIndex>two.length-1){ break; } - if(oneIndexone.length-1&&twoIndex>two.length-1){ + break; + } + + if(oneIndex