Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
微笑面对bug
ddz
提交
a2e1f8c0
ddz
项目概览
微笑面对bug
/
ddz
通知
5
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ddz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a2e1f8c0
编写于
9月 26, 2020
作者:
微笑面对bug
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
界面
上级
c0b094bb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
54 addition
and
804 deletion
+54
-804
src/components/Game.vue
src/components/Game.vue
+41
-27
src/doudizhu/AI.js
src/doudizhu/AI.js
+4
-0
src/doudizhu/Game.js
src/doudizhu/Game.js
+4
-6
src/doudizhu/Player.js
src/doudizhu/Player.js
+5
-771
src/img/s.jpg
src/img/s.jpg
+0
-0
src/img/x.png
src/img/x.png
+0
-0
未找到文件。
src/components/Game.vue
浏览文件 @
a2e1f8c0
<
template
>
<div
style=
"user-select: none"
>
<div
style=
"width: 300px;height:300px;float: left; position: fixed ; left: 0; top: 0px; background-color: aliceblue; text-align: center"
>
<div
style=
"user-select: none
;position: fixed;left: 0;right: 0;top: 0;bottom: 0;background-repeat: no-repeat;background-size: cover;"
:style=
"
{backgroundImage:'url('+require('../img/scene.jpg')+')'}
">
<div
v-show=
"false"
style=
"width: 300px;height:300px;float: left; position: fixed ; left: 0; top: 0px; background-color: aliceblue; text-align: center"
>
<span>
手牌:
{{
player2Str
[
1
]
}}
</span>
</div>
<div
style=
"width: 300px;height:300px;float: left; position: fixed ; right: 0; top: 0px; background-color: aliceblue; text-align: center"
>
<div
v-show=
"false"
style=
"width: 300px;height:300px;float: left; position: fixed ; right: 0; top: 0px; background-color: aliceblue; text-align: center"
>
<span>
手牌:
{{
player1Str
[
1
]
}}
</span>
</div>
<div
style=
"width: 300px;height:300px;float: left; position: fixed ; left: 600px; top: 0px; background-color: aliceblue; text-align: center"
>
<div
v-show=
"false"
style=
"width: 300px;height:300px;float: left; position: fixed ; left: 600px; top: 0px; background-color: aliceblue; text-align: center"
>
<div
style=
"width: 300px;word-wrap: break-word;"
>
已出的牌:
<br/>
...
...
@@ -20,32 +20,36 @@
</div>
</div>
<div
style=
"position: fixed;left:
600px;top: 30
0px;"
>
<button
@
click=
"reStart"
>
开始新一局
</button>
<div
style=
"position: fixed;left:
10px;bottom: 1
0px;"
>
<button
@
click=
"reStart"
style=
"height: 50px;font-size:30px;"
>
开始新一局
</button>
</div>
<div
:style=
"
{ marginLeft: playerMarginLeft-150 + 'px' }" style="position: fixed;bottom:0;width: 100%;height: 200px;line-height: 200px;">
你是
{{
game
.
playerList
[
0
].
type
===
'
nongmin
'
?
'
农民
'
:
'
地主
'
}}
<div
:style=
"
{ marginLeft: playerMarginLeft-150 + 'px' }" style="
color:white;
position: fixed;bottom:0;width: 100%;height: 200px;line-height: 200px;">
你是
<span
style=
"color:red;font-size: 20px"
>
{{
game
.
playerList
[
0
].
type
===
'
nongmin
'
?
'
农民
'
:
'
地主
'
}}
</span>
</div>
<div
:style=
"
{ marginLeft: playerMarginLeft + 'px' }" style="position: fixed;bottom:0;width: 100%;height: 200px;">
<div
@
mouseenter=
"enter($event,item)"
@
mousedown=
"pickPoker(item)"
v-for=
"item in game.playerList[0].pokerList"
:class=
"
{ selected: item.selected }" class="poker" style="">
{{
item
.
text
}}
<div
@
mouseenter=
"enter($event,item)"
@
mousedown=
"pickPoker(item)"
v-for=
"item in game.playerList[0].pokerList"
:class=
"
{ selected: item.selected, s:item.number===16, x:item.number===17 }" class="poker pokerDesk" style="">
<span
v-show=
"item.number
<
16"
>
{{
item
.
text
}}
</span>
</div>
</div>
<div
style=
"position: fixed;bottom:200px;width: 100%;height: 100px;text-align:left;"
>
<div
:style=
"
{ marginLeft: buttonMarginLeft + 'px' }" style="width:
200px;height: 3
0px;">
<button
@
click=
"
sendPoker2"
style=
"height: 30px;border-radius: 4px;float:left"
>
出牌
</button>
<button
@
click=
"
pass"
style=
"height: 30px;border-radius: 4px;margin-left: 20px;float:right"
>
不出
</button>
<div
v-show=
"game.currentPlayer===game.playerList[0]"
style=
"color: red;width:150px;border: solid;border-radius: 4px;float: left"
>
<div
:style=
"
{ marginLeft: buttonMarginLeft + 'px' }" style="width:
400px;height: 6
0px;">
<button
@
click=
"
pass"
style=
"height: 60px;border-radius: 4px;float:left;font-size:40px;background-color: red"
>
不出
</button>
<button
@
click=
"
sendPoker2"
style=
"height: 60px;border-radius: 4px;float:right;font-size:40px;background-color: lawngreen"
>
出牌
</button>
<div
v-show=
"game.currentPlayer===game.playerList[0]"
style=
"color: red;width:150px;border: solid;border-radius: 4px;float: left
;margin-left: 20px;
"
>
请在
{{
game
.
second
}}
秒内出牌
</div>
</div>
</div>
<div
v-if=
"game.playerList[0].lastSendObj&&game.playerList[0].lastSendObj.poker[0].text"
:style=
"
{ marginLeft: deskPokerMarginLeft + 'px' }" style="position: fixed;bottom:350px;width: 100%;height: 200px">
<div
v-for=
"item in game.playerList[0].lastSendObj.poker"
class=
"pokerDesk"
>
{{
item
.
text
}}
<div
v-for=
"item in game.playerList[0].lastSendObj.poker"
class=
"pokerDesk"
:class=
"
{ s:item.number===16, x:item.number===17 }">
<span
v-show=
"item.number
<
16"
>
{{
item
.
text
}}
</span>
</div>
</div>
<div
v-if=
"game.playerList[0].lastSendObj&&!game.playerList[0].lastSendObj.poker[0].text"
:style=
"
{ marginLeft: deskPokerMarginLeft + 'px' }" style="position: fixed;bottom:350px;width: 100%;height: 200px">
...
...
@@ -55,7 +59,7 @@
</div>
<div
style=
"position: fixed;top:40px;left: 20px;height:200px;width:100px;border: solid 1px;border-radius: 8px;background-color: azure;text-align: center"
>
<p>
<p
style=
"color:red;font-size: 20px"
>
{{
game
.
playerList
[
2
].
type
===
'
nongmin
'
?
'
农民
'
:
'
地主
'
}}
</p>
<p>
...
...
@@ -70,8 +74,10 @@
</div>
</div>
<div
v-if=
"game.playerList[2].lastSendObj&&game.playerList[2].lastSendObj.poker[0].text"
style=
"position: fixed;top:100px;left:200px;height: 200px;"
>
<div
v-for=
"item in game.playerList[2].lastSendObj.poker"
class=
"pokerDesk"
>
{{
item
.
text
}}
<div
v-for=
"item in game.playerList[2].lastSendObj.poker"
class=
"pokerDesk"
:class=
"
{ s:item.number===16, x:item.number===17 }">
<span
v-show=
"item.number
<
16"
>
{{
item
.
text
}}
</span>
</div>
</div>
<div
v-if=
"game.playerList[2].lastSendObj&&!game.playerList[2].lastSendObj.poker[0].text"
style=
"position: fixed;top:100px;left:200px;height: 200px;"
>
...
...
@@ -81,7 +87,7 @@
</div>
<div
style=
"position: fixed;top:40px;right: 20px;height:200px;width:100px;border: solid 1px;border-radius: 8px;background-color: azure;text-align: center"
>
<p>
<p
style=
"color:red;font-size: 20px"
>
{{
game
.
playerList
[
1
].
type
===
'
nongmin
'
?
'
农民
'
:
'
地主
'
}}
</p>
<p>
...
...
@@ -95,8 +101,10 @@
</div>
</div>
<div
v-if=
"game.playerList[1].lastSendObj&&game.playerList[1].lastSendObj.poker[0].text"
style=
"position: fixed;top:100px;right:200px;height: 200px;"
>
<div
v-for=
"item in game.playerList[1].lastSendObj.poker"
class=
"pokerDesk"
>
{{
item
.
text
}}
<div
v-for=
"item in game.playerList[1].lastSendObj.poker"
class=
"pokerDesk"
:class=
"
{ s:item.number===16, x:item.number===17 }">
<span
v-show=
"item.number
<
16"
>
{{
item
.
text
}}
</span>
</div>
</div>
<div
v-if=
"game.playerList[1].lastSendObj&&!game.playerList[1].lastSendObj.poker[0].text"
style=
"position: fixed;top:100px;right:200px;height: 200px;"
>
...
...
@@ -130,7 +138,7 @@ export default {
return
(
window
.
innerWidth
-
(
this
.
game
.
playerList
[
0
].
lastSendObj
.
poker
.
length
*
50
))
/
2
;
},
buttonMarginLeft
:
function
(){
return
(
window
.
innerWidth
-
2
00
)
/
2
;
return
(
window
.
innerWidth
-
4
00
)
/
2
;
},
deskPoker
:
function
(){
...
...
@@ -234,11 +242,9 @@ export default {
.pokerDesk
{
height
:
100%
;
width
:
100px
;
border
:
solid
1px
;
border-radius
:
16px
;
float
:
left
;
margin-left
:
-50px
;
background-color
:
azure
;
font-size
:
30px
;
background-repeat
:
no-repeat
;
background-size
:
cover
;
}
.poker
{
height
:
100%
;
width
:
100px
;
border
:
solid
1px
;
border-radius
:
16px
;
float
:
left
;
margin-left
:
-50px
;
background-color
:
azure
;
font-size
:
30px
;
}
.poker
:hover
{
background-color
:
antiquewhite
;
}
...
...
@@ -246,4 +252,12 @@ export default {
.selected
{
margin-top
:
-20px
;
}
.s
{
background-image
:
url("../img/s.jpg")
;
}
.x
{
background-image
:
url("../img/x.png")
;
}
</
style
>
src/doudizhu/AI.js
浏览文件 @
a2e1f8c0
...
...
@@ -545,7 +545,11 @@ class AI{
let
types
=
[
'
threeWithTwoList
'
,
'
threeWithOneList
'
,
'
threeList
'
,
'
twoList
'
,
'
oneList
'
,
'
threeWithTwo
'
,
'
threeWithOne
'
,
'
three
'
,
'
two
'
,
'
four
'
,
'
sx
'
,
'
one
'
];
for
(
let
i
=
0
;
i
<
types
.
length
;
i
++
){
let
obj
=
this
.
getSmallestObjByType
(
types
[
i
],
true
);
if
(
!
obj
){
continue
;
}
this
.
player
.
deleteFromPokerListAndSendByObj
(
obj
);
break
;
}
}
...
...
src/doudizhu/Game.js
浏览文件 @
a2e1f8c0
...
...
@@ -9,7 +9,7 @@ class Game{
this
.
oldPokerList
=
[];
this
.
currentPlayer
=
[];
this
.
dizhu
=
null
;
this
.
MaxSecond
=
999999
;
this
.
MaxSecond
=
60
;
this
.
second
=
this
.
MaxSecond
;
this
.
isOver
=
true
;
...
...
@@ -50,13 +50,11 @@ class Game{
start
(){
// this.playerList[0].getClassifyObj();
this
.
isOver
=
false
;
this
.
timeLoop
();
this
.
currentPlayer
=
this
.
dizhu
;
if
(
this
.
currentPlayer
.
isRobot
){
this
.
currentPlayer
.
playByAI
2
();
this
.
currentPlayer
.
playByAI
();
}
}
...
...
@@ -69,12 +67,12 @@ class Game{
this
.
resetTime
();
this
.
currentPlayer
=
this
.
currentPlayer
.
next
;
if
(
this
.
currentPlayer
.
isRobot
){
this
.
currentPlayer
.
playByAI
2
();
this
.
currentPlayer
.
playByAI
();
}
}
gameOver
(){
alert
(
'
gameOver!
'
+
this
.
currentPlayer
.
name
+
'
[
'
+
this
.
currentPlayer
.
type
+
'
] win
!
'
);
alert
(
'
游戏结束!
'
+
this
.
currentPlayer
.
name
+
'
[
'
+
this
.
currentPlayer
.
type
+
'
] 胜
!
'
);
this
.
isOver
=
true
;
}
...
...
src/doudizhu/Player.js
浏览文件 @
a2e1f8c0
...
...
@@ -51,20 +51,6 @@ class Player{
playByAI
(){
let
that
=
this
;
setTimeout
(
function
()
{
let
lastObj
=
that
.
getLastObj
();
if
(
lastObj
){
that
.
playByObj
(
lastObj
);
}
else
{
that
.
playByAllType
();
}
},
1000
);
}
playByAI2
(){
let
that
=
this
;
that
.
getClassifyObj
();
...
...
@@ -76,7 +62,7 @@ class Player{
}
else
{
that
.
ai
.
playByAllType
();
}
},
100
0
);
},
0
);
}
...
...
@@ -88,22 +74,6 @@ class Player{
this
.
game
.
next
();
}
playByAllType
(){
let
types2
=
[
'
one
'
,
'
two
'
,
'
three
'
,
'
threeWithOne
'
,
'
threeWithTwo
'
,
'
fourWithOne
'
,
'
fourWithTwo
'
,
'
threeWithOneList
'
,
'
threeWithTwoList
'
,
'
oneList
'
,
'
twoList
'
,
'
threeList
'
,
'
four
'
,
'
sx
'
,
'
pass
'
];
let
types
=
[
'
threeWithTwoList
'
,
'
threeWithOneList
'
,
'
threeList
'
,
'
twoList
'
,
'
fourWithTwo
'
,
'
fourWithOne
'
,
'
threeWithTwo
'
,
'
oneList
'
,
'
threeWithOne
'
,
'
three
'
,
'
two
'
,
'
one
'
,
'
four
'
,
'
sx
'
,
'
pass
'
];
for
(
let
i
=
0
;
i
<
types
.
length
;
i
++
){
let
obj
=
this
.
getSmallestObjByType
(
types
[
i
]);
if
(
obj
){
let
success
=
this
.
deleteFromPokerListAndSendByObj
(
obj
);
if
(
!
success
){
alert
(
'
error!
'
);
}
return
;
}
}
}
deleteFromPokerListAndSendByObj
(
obj
){
let
tempList
=
[];
if
(
obj
.
type
===
'
pass
'
){
...
...
@@ -125,742 +95,6 @@ class Player{
return
true
;
}
getSmallestObjByType
(
type
){
let
pokerList
=
this
.
pokerList
;
let
lastPoker
=
pokerList
[
0
];
let
curList
=
[
lastPoker
];
let
lists
=
[];
for
(
let
i
=
1
;
i
<
pokerList
.
length
;
i
++
){
if
(
pokerList
[
i
].
number
!==
lastPoker
.
number
){
lists
.
push
(
curList
);
curList
=
[
pokerList
[
i
]];
}
else
{
curList
.
push
(
pokerList
[
i
]);
}
lastPoker
=
pokerList
[
i
];
}
lists
.
push
(
curList
);
let
Count1List
=
[];
let
Count2List
=
[];
let
Count3List
=
[];
let
Count4List
=
[];
for
(
let
i
=
0
;
i
<
lists
.
length
;
i
++
){
if
(
lists
[
i
].
length
===
3
){
Count3List
.
push
(
lists
[
i
]);
}
else
if
(
lists
[
i
].
length
===
2
){
Count2List
.
push
(
lists
[
i
]);
}
else
if
(
lists
[
i
].
length
===
1
){
Count1List
.
push
(
lists
[
i
]);
}
else
if
(
lists
[
i
].
length
===
4
){
Count4List
.
push
(
lists
[
i
]);
}
}
let
obj
=
null
;
if
(
type
===
'
one
'
){
if
(
Count1List
.
length
>
0
){
obj
=
{
type
:
type
,
poker
:
Count1List
[
0
],
one
:
Count1List
[
0
],
};
}
}
else
if
(
type
===
'
two
'
){
if
(
Count2List
.
length
>
0
){
obj
=
{
type
:
type
,
poker
:
Count2List
[
0
],
two
:
Count2List
[
0
],
};
}
}
else
if
(
type
===
'
three
'
){
if
(
Count3List
.
length
>
0
){
obj
=
{
type
:
type
,
poker
:
Count3List
[
0
],
three
:
Count3List
[
0
],
};
}
}
else
if
(
type
===
'
threeWithOne
'
){
if
(
Count3List
.
length
>
0
){
let
one
;
if
(
Count1List
.
length
>
0
){
one
=
Count1List
[
0
];
}
if
(
one
){
obj
=
{
type
:
type
,
poker
:
Count3List
[
0
].
concat
(
one
),
three
:
Count3List
[
0
],
one
:
one
,
};
}
}
}
else
if
(
type
===
'
four
'
){
if
(
Count4List
.
length
>
0
){
obj
=
{
type
:
type
,
poker
:
Count4List
[
0
],
four
:
Count4List
[
0
],
};
}
}
else
if
(
type
===
'
threeWithTwo
'
){
if
(
Count3List
.
length
>
0
){
let
two
;
if
(
Count2List
.
length
>
0
){
two
=
Count2List
[
0
];
}
if
(
two
){
obj
=
{
type
:
type
,
poker
:
Count3List
[
0
].
concat
(
two
),
three
:
Count3List
[
0
],
two
:
two
,
};
}
}
}
else
if
(
type
===
'
fourWithOne
'
){
if
(
Count4List
.
length
>
0
){
let
one
;
if
(
Count1List
.
length
>
0
){
one
=
Count1List
[
0
];
}
if
(
one
){
obj
=
{
type
:
type
,
poker
:
Count4List
[
0
].
concat
(
one
),
four
:
Count4List
[
0
],
one
:
one
,
};
}
}
}
else
if
(
type
===
'
fourWithTwo
'
){
if
(
Count4List
.
length
>
0
){
let
two
;
if
(
Count2List
.
length
>
0
){
two
=
Count2List
[
0
];
}
if
(
two
){
obj
=
{
type
:
type
,
poker
:
Count4List
[
0
].
concat
(
two
),
four
:
Count4List
[
0
],
two
:
two
,
};
}
}
}
else
if
(
type
===
'
threeWithOneList
'
){
if
(
Count3List
.
length
>=
2
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
-
2
+
1
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
+
2
-
1
===
Count3List
[
i
+
2
-
1
][
0
].
number
&&
Count3List
[
i
+
2
-
1
][
0
].
number
<=
14
){
let
oneList
=
[];
for
(
let
j
=
0
;
j
<
Count1List
.
length
&&
oneList
.
length
<
2
;
j
++
){
oneList
.
push
(
Count1List
[
j
]);
}
for
(
let
j
=
0
;
j
<
Count2List
.
length
&&
oneList
.
length
<
2
;
j
++
){
oneList
.
push
(
Count2List
[
j
].
slice
(
0
,
1
));
if
(
oneList
.
length
<
2
){
oneList
.
push
(
Count2List
[
j
].
slice
(
1
,
2
));
}
}
for
(
let
j
=
0
;
j
<
Count3List
.
length
&&
oneList
.
length
<
2
;
j
++
){
oneList
.
push
(
Count3List
[
j
].
slice
(
0
,
1
));
if
(
oneList
.
length
<
2
){
oneList
.
push
(
Count3List
[
j
].
slice
(
1
,
2
));
}
if
(
oneList
.
length
<
2
){
oneList
.
push
(
Count3List
[
j
].
slice
(
2
,
3
));
}
}
if
(
oneList
.
length
===
2
){
let
poker
=
[];
let
list
=
[];
for
(
let
j
=
0
;
j
<
2
;
j
++
){
poker
.
concat
(
Count3List
[
i
+
j
]);
poker
.
concat
(
oneList
[
i
]);
let
threeOne
=
{
three
:
Count3List
[
i
+
j
],
one
:
oneList
[
i
],
};
list
.
push
(
threeOne
);
}
obj
=
{
type
:
type
,
poker
:
poker
,
list
:
list
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
threeWithTwoList
'
){
if
(
Count3List
.
length
>=
2
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
-
2
+
1
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
+
2
-
1
===
Count3List
[
i
+
2
-
1
][
0
].
number
&&
Count3List
[
i
+
2
-
1
][
0
].
number
<=
14
){
let
twoList
=
[];
for
(
let
j
=
0
;
j
<
Count2List
.
length
&&
twoList
.
length
<
2
;
j
++
){
twoList
.
push
(
Count2List
);
}
//还差一对
if
(
twoList
.
length
===
2
-
1
){
for
(
let
j
=
0
;
j
<
Count3List
.
length
&&
twoList
.
length
<
2
;
j
++
){
twoList
.
push
(
Count3List
[
j
].
slice
(
0
,
2
));
}
}
if
(
twoList
.
length
===
2
){
let
poker
=
[];
let
list
=
[];
for
(
let
j
=
0
;
j
<
2
;
j
++
){
poker
.
concat
(
Count3List
[
i
+
j
]);
poker
.
concat
(
twoList
[
i
]);
let
threeOne
=
{
three
:
Count3List
[
i
+
j
],
two
:
twoList
[
i
],
};
list
.
push
(
threeOne
);
}
obj
=
{
type
:
type
,
poker
:
poker
,
list
:
list
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
oneList
'
){
if
(
Count1List
.
length
>=
5
){
for
(
let
i
=
0
;
i
<
Count1List
.
length
-
5
+
1
;
i
++
){
if
(
Count1List
[
i
][
0
].
number
+
5
-
1
===
Count1List
[
i
+
5
-
1
][
0
].
number
&&
Count1List
[
i
+
5
-
1
][
0
].
number
<=
14
){
let
list
=
Count1List
.
slice
(
i
,
i
+
5
);
obj
=
{
type
:
type
,
poker
:
list
.
flat
(
1
),
list
:
list
.
map
(
function
(
item
)
{
return
{
one
:
item
,
}
}),
};
break
;
}
}
}
}
else
if
(
type
===
'
twoList
'
){
if
(
Count2List
.
length
>=
3
){
for
(
let
i
=
0
;
i
<
Count2List
.
length
-
3
+
1
;
i
++
){
if
(
Count2List
[
i
][
0
].
number
+
3
-
1
===
Count2List
[
i
+
3
-
1
][
0
].
number
&&
Count2List
[
i
+
3
-
1
][
0
].
number
<=
14
){
let
list
=
Count2List
.
slice
(
i
,
i
+
3
);
obj
=
{
type
:
type
,
poker
:
list
.
flat
(
1
),
list
:
list
.
map
(
function
(
item
)
{
return
{
two
:
item
,
}
}),
};
break
;
}
}
}
}
else
if
(
type
===
'
threeList
'
){
if
(
Count3List
.
length
>=
2
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
-
2
+
1
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
+
2
-
1
===
Count3List
[
i
+
2
-
1
][
0
].
number
&&
Count3List
[
i
+
2
-
1
][
0
].
number
<=
14
){
let
list
=
Count3List
.
slice
(
i
,
i
+
2
);
obj
=
{
type
:
type
,
poker
:
list
.
flat
(
1
),
list
:
list
.
map
(
function
(
item
)
{
return
{
three
:
item
,
}
}),
};
break
;
}
}
}
}
else
if
(
type
===
'
sx
'
){
if
(
Count1List
.
length
>=
2
){
for
(
let
i
=
0
;
i
<
Count1List
.
length
-
1
;
i
++
){
if
(
Count1List
[
i
][
0
].
number
===
16
){
let
list
=
Count2List
.
slice
(
i
,
i
+
2
);
let
poker
=
list
.
flat
(
1
);
obj
=
{
type
:
type
,
poker
:
poker
,
sx
:
poker
,
};
break
;
}
}
}
}
else
if
(
type
===
'
pass
'
){
obj
=
{
type
:
type
,
poker
:
[
'
pass
'
],
};
}
return
obj
;
}
getObjByObj
(
lastObj
){
let
pokerList
=
this
.
pokerList
;
let
lastPoker
=
pokerList
[
0
];
let
curList
=
[
lastPoker
];
let
lists
=
[];
for
(
let
i
=
1
;
i
<
pokerList
.
length
;
i
++
){
if
(
pokerList
[
i
].
number
!==
lastPoker
.
number
){
lists
.
push
(
curList
);
curList
=
[
pokerList
[
i
]];
}
else
{
curList
.
push
(
pokerList
[
i
]);
}
lastPoker
=
pokerList
[
i
];
}
lists
.
push
(
curList
);
let
Count1List
=
[];
let
Count2List
=
[];
let
Count3List
=
[];
let
Count4List
=
[];
for
(
let
i
=
0
;
i
<
lists
.
length
;
i
++
){
if
(
lists
[
i
].
length
===
3
){
Count3List
.
push
(
lists
[
i
]);
}
else
if
(
lists
[
i
].
length
===
2
){
Count2List
.
push
(
lists
[
i
]);
}
else
if
(
lists
[
i
].
length
===
1
){
Count1List
.
push
(
lists
[
i
]);
}
else
if
(
lists
[
i
].
length
===
4
){
Count4List
.
push
(
lists
[
i
]);
}
}
let
type
=
lastObj
.
type
;
let
obj
=
null
;
if
(
type
===
'
one
'
){
if
(
Count1List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count1List
.
length
;
i
++
){
if
(
Count1List
[
i
][
0
].
number
>
lastObj
.
one
[
0
].
number
){
obj
=
{
type
:
type
,
poker
:
Count1List
[
i
],
one
:
Count1List
[
i
],
};
break
;
}
}
}
else
if
(
Count2List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count2List
.
length
;
i
++
){
if
(
Count2List
[
i
][
0
].
number
>
lastObj
.
one
[
0
].
number
){
let
poker
=
Count2List
[
i
].
slice
(
0
,
1
);
obj
=
{
type
:
type
,
poker
:
poker
,
one
:
poker
,
};
break
;
}
}
}
else
if
(
Count3List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
one
[
0
].
number
){
let
poker
=
Count3List
[
i
].
slice
(
0
,
1
);
obj
=
{
type
:
type
,
poker
:
poker
,
one
:
poker
,
};
break
;
}
}
}
}
else
if
(
type
===
'
two
'
){
if
(
Count2List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count2List
.
length
;
i
++
){
if
(
Count2List
[
i
][
0
].
number
>
lastObj
.
two
[
0
].
number
){
obj
=
{
type
:
type
,
poker
:
Count2List
[
i
],
two
:
Count2List
[
i
],
};
break
;
}
}
}
else
if
(
Count3List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
two
[
0
].
number
){
let
poker
=
Count3List
[
i
].
slice
(
0
,
2
);
obj
=
{
type
:
type
,
poker
:
poker
,
two
:
poker
,
};
break
;
}
}
}
}
else
if
(
type
===
'
three
'
){
if
(
Count3List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
three
[
0
].
number
){
obj
=
{
type
:
type
,
poker
:
Count3List
[
i
],
three
:
Count3List
[
i
],
};
break
;
}
}
}
}
else
if
(
type
===
'
threeWithOne
'
){
if
(
Count3List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
three
[
0
].
number
){
let
one
;
if
(
Count1List
.
length
>
0
){
one
=
Count1List
[
0
];
}
else
if
(
Count2List
.
length
>
0
){
one
=
Count2List
[
0
].
slice
(
0
,
1
);
}
else
if
(
Count3List
.
length
>
0
){
for
(
let
j
=
0
;
j
<
Count3List
.
length
;
j
++
){
if
(
j
===
i
){
continue
;
}
one
=
Count3List
[
j
].
slice
(
0
,
1
);
}
}
if
(
one
){
obj
=
{
type
:
type
,
poker
:
Count3List
[
i
].
concat
(
one
),
three
:
Count3List
[
i
],
one
:
one
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
threeWithTwo
'
){
if
(
Count3List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
three
[
0
].
number
){
let
two
;
if
(
Count2List
.
length
>
0
){
two
=
Count2List
[
0
];
}
else
if
(
Count3List
.
length
>
0
){
for
(
let
j
=
0
;
j
<
Count3List
.
length
;
j
++
){
if
(
j
===
i
){
continue
;
}
two
=
Count3List
[
j
].
slice
(
0
,
2
);
}
}
if
(
two
){
obj
=
{
type
:
type
,
poker
:
Count3List
[
i
].
concat
(
two
),
three
:
Count3List
[
i
],
two
:
two
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
fourWithOne
'
){
if
(
Count4List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count4List
.
length
;
i
++
){
if
(
Count4List
[
i
][
0
].
number
>
lastObj
.
four
[
0
].
number
){
let
one
;
if
(
Count1List
.
length
>
0
){
one
=
Count1List
[
0
];
}
else
if
(
Count2List
.
length
>
0
){
one
=
Count2List
[
0
].
slice
(
0
,
1
);
}
else
if
(
Count3List
.
length
>
0
){
one
=
Count3List
[
0
].
slice
(
0
,
1
);
}
if
(
one
){
obj
=
{
type
:
type
,
poker
:
Count4List
[
i
].
concat
(
one
),
four
:
Count4List
[
i
],
one
:
one
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
fourWithTwo
'
){
if
(
Count4List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count4List
.
length
;
i
++
){
if
(
Count4List
[
i
][
0
].
number
>
lastObj
.
four
[
0
].
number
){
let
two
;
if
(
Count2List
.
length
>
0
){
two
=
Count2List
[
0
];
}
else
if
(
Count3List
.
length
>
0
){
two
=
Count3List
[
0
].
slice
(
0
,
2
);
}
if
(
two
){
obj
=
{
type
:
type
,
poker
:
Count4List
[
i
].
concat
(
two
),
four
:
Count4List
[
i
],
two
:
two
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
threeWithOneList
'
){
if
(
Count3List
.
length
>=
lastObj
.
list
.
length
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
-
lastObj
.
list
.
length
+
1
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
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
){
let
oneList
=
[];
for
(
let
j
=
0
;
j
<
Count1List
.
length
&&
oneList
.
length
<
lastObj
.
list
.
length
;
j
++
){
oneList
.
push
(
Count1List
[
j
]);
}
for
(
let
j
=
0
;
j
<
Count2List
.
length
&&
oneList
.
length
<
lastObj
.
list
.
length
;
j
++
){
oneList
.
push
(
Count2List
[
j
].
slice
(
0
,
1
));
if
(
oneList
.
length
<
lastObj
.
list
.
length
){
oneList
.
push
(
Count2List
[
j
].
slice
(
1
,
2
));
}
}
for
(
let
j
=
0
;
j
<
Count3List
.
length
&&
oneList
.
length
<
lastObj
.
list
.
length
;
j
++
){
oneList
.
push
(
Count3List
[
j
].
slice
(
0
,
1
));
if
(
oneList
.
length
<
lastObj
.
list
.
length
){
oneList
.
push
(
Count3List
[
j
].
slice
(
1
,
2
));
}
if
(
oneList
.
length
<
lastObj
.
list
.
length
){
oneList
.
push
(
Count3List
[
j
].
slice
(
2
,
3
));
}
}
if
(
oneList
.
length
===
lastObj
.
list
.
length
){
let
poker
=
[];
let
list
=
[];
for
(
let
j
=
0
;
j
<
lastObj
.
list
.
length
;
j
++
){
poker
.
concat
(
Count3List
[
i
+
j
]);
poker
.
concat
(
oneList
[
i
]);
let
threeOne
=
{
three
:
Count3List
[
i
+
j
],
one
:
oneList
[
i
],
};
list
.
push
(
threeOne
);
}
obj
=
{
type
:
type
,
poker
:
poker
,
list
:
list
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
threeWithTwoList
'
){
if
(
Count3List
.
length
>=
lastObj
.
list
.
length
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
-
lastObj
.
list
.
length
+
1
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
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
){
let
twoList
=
[];
for
(
let
j
=
0
;
j
<
Count2List
.
length
&&
twoList
.
length
<
lastObj
.
list
.
length
;
j
++
){
twoList
.
push
(
Count2List
);
}
for
(
let
j
=
0
;
j
<
Count3List
.
length
&&
twoList
.
length
<
lastObj
.
list
.
length
;
j
++
){
twoList
.
push
(
Count3List
[
j
].
slice
(
0
,
2
));
}
if
(
twoList
.
length
===
lastObj
.
list
.
length
){
let
poker
=
[];
let
list
=
[];
for
(
let
j
=
0
;
j
<
lastObj
.
list
.
length
;
j
++
){
poker
.
concat
(
Count3List
[
i
+
j
]);
poker
.
concat
(
twoList
[
i
]);
let
threeOne
=
{
three
:
Count3List
[
i
+
j
],
two
:
twoList
[
i
],
};
list
.
push
(
threeOne
);
}
obj
=
{
type
:
type
,
poker
:
poker
,
list
:
list
,
};
}
break
;
}
}
}
}
else
if
(
type
===
'
oneList
'
){
if
(
Count1List
.
length
>=
lastObj
.
list
.
length
){
for
(
let
i
=
0
;
i
<
Count1List
.
length
-
lastObj
.
list
.
length
+
1
;
i
++
){
if
(
Count1List
[
i
][
0
].
number
>
lastObj
.
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
){
let
list
=
Count1List
.
slice
(
i
,
i
+
lastObj
.
list
.
length
);
obj
=
{
type
:
type
,
poker
:
list
.
flat
(
1
),
list
:
list
.
map
(
function
(
item
)
{
return
{
one
:
item
,
}
}),
};
break
;
}
}
}
}
else
if
(
type
===
'
twoList
'
){
if
(
Count2List
.
length
>=
lastObj
.
list
.
length
){
for
(
let
i
=
0
;
i
<
Count2List
.
length
-
lastObj
.
list
.
length
+
1
;
i
++
){
if
(
Count2List
[
i
][
0
].
number
>
lastObj
.
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
){
let
list
=
Count2List
.
slice
(
i
,
i
+
lastObj
.
list
.
length
);
obj
=
{
type
:
type
,
poker
:
list
.
flat
(
1
),
list
:
list
.
map
(
function
(
item
)
{
return
{
two
:
item
,
}
}),
};
break
;
}
}
}
}
else
if
(
type
===
'
threeList
'
){
if
(
Count3List
.
length
>=
lastObj
.
list
.
length
){
for
(
let
i
=
0
;
i
<
Count3List
.
length
-
lastObj
.
list
.
length
+
1
;
i
++
){
if
(
Count3List
[
i
][
0
].
number
>
lastObj
.
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
){
let
list
=
Count3List
.
slice
(
i
,
i
+
lastObj
.
list
.
length
);
obj
=
{
type
:
type
,
poker
:
list
.
flat
(
1
),
list
:
list
.
map
(
function
(
item
)
{
return
{
three
:
item
,
}
}),
};
break
;
}
}
}
}
else
if
(
type
===
'
four
'
){
if
(
Count4List
.
length
>
0
){
for
(
let
i
=
0
;
i
<
Count4List
.
length
;
i
++
){
if
(
Count4List
[
i
][
0
].
number
>
lastObj
.
four
[
0
].
number
){
obj
=
{
type
:
type
,
poker
:
Count4List
[
i
],
four
:
Count4List
[
i
],
};
break
;
}
}
}
}
if
(
!
obj
&&
type
!==
'
four
'
){
if
(
Count4List
.
length
>
0
){
obj
=
{
type
:
'
four
'
,
poker
:
Count4List
[
0
],
four
:
Count4List
[
0
],
};
}
}
if
(
!
obj
&&
type
!==
'
sx
'
){
if
(
Count1List
.
length
>
1
){
if
(
Count1List
[
Count1List
.
length
-
2
]
===
16
){
let
poker
=
Count1List
[
Count1List
.
length
-
2
].
concat
(
Count1List
[
Count1List
.
length
-
1
]);
obj
=
{
type
:
'
sx
'
,
poker
:
poker
,
sx
:
poker
,
};
}
}
}
if
(
!
obj
){
obj
=
{
type
:
'
pass
'
,
poker
:
[
'
pass
'
],
};
}
return
obj
;
}
playByObj
(
lastObj
){
let
obj
=
this
.
getObjByObj
(
lastObj
);
let
success
=
this
.
deleteFromPokerListAndSendByObj
(
obj
);
if
(
!
success
){
alert
(
'
error!
'
);
}
}
getListByList
(
list
){
let
tempList
=
[];
if
(
list
[
0
]
===
'
pass
'
){
...
...
@@ -923,7 +157,7 @@ class Player{
return
true
;
}
else
{
this
.
listBackToPokerList
(
list
);
alert
(
'
have to bigger than
'
+
Poker
.
pokerListToString
(
lastObj
.
poker
));
alert
(
'
必须大于
'
+
Poker
.
pokerListToString
(
lastObj
.
poker
));
return
false
;
}
...
...
@@ -938,7 +172,7 @@ class Player{
}
this
.
listBackToPokerList
(
list
);
alert
(
'
type is not
'
+
lastObj
.
type
+
'
!
'
);
alert
(
'
牌型不是
'
+
lastObj
.
type
+
'
!
'
);
return
false
;
}
}
else
{
...
...
@@ -948,12 +182,12 @@ class Player{
}
else
{
this
.
listBackToPokerList
(
list
);
alert
(
'
type error
!
'
);
alert
(
'
牌型错误
!
'
);
return
false
;
}
}
else
{
alert
(
'
poker error
!
'
);
alert
(
'
你没有此牌
!
'
);
return
false
;
}
}
...
...
src/img/s.jpg
0 → 100644
浏览文件 @
a2e1f8c0
22.1 KB
src/img/x.png
0 → 100644
浏览文件 @
a2e1f8c0
70.3 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录