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
此差异已折叠。
点击以展开。
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录