提交 df7b3a70 编写于 作者: 微笑面对bug's avatar 微笑面对bug

新增 叫分阶段(待完善)

上级 de8c183e
.pokerDesk[data-v-b2f40602]{height:100%;width:100px;border:1px solid;border-radius:16px;float:left;margin-left:-50px;background-color:azure;font-size:30px;background-repeat:no-repeat;background-size:cover}.poker[data-v-b2f40602]:hover{background-color:#faebd7}.selected[data-v-b2f40602]{margin-top:-20px}.s[data-v-b2f40602]{background-image:url(../img/s.aa339508.jpg)}.x[data-v-b2f40602]{background-image:url(../img/x.aa03af01.png)}
\ No newline at end of file
.pokerDesk[data-v-7bd525ec]{height:100%;width:100px;border:1px solid;border-radius:16px;float:left;margin-left:-50px;background-color:azure;font-size:30px;background-repeat:no-repeat;background-size:cover}.poker[data-v-7bd525ec]:hover{background-color:#faebd7}.selected[data-v-7bd525ec]{margin-top:-20px}.s[data-v-7bd525ec]{background-image:url(../img/s.aa339508.jpg)}.x[data-v-7bd525ec]{background-image:url(../img/x.aa03af01.png)}
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><title>Vue App</title><link href=css/app.7fb6ba30.css rel=preload as=style><link href=js/app.4b39f358.js rel=preload as=script><link href=js/chunk-vendors.caf18475.js rel=preload as=script><link href=css/app.7fb6ba30.css rel=stylesheet></head><body><div id=app></div><script src=js/chunk-vendors.caf18475.js></script><script src=js/app.4b39f358.js></script></body></html>
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><title>Vue App</title><link href=css/app.ad699e7c.css rel=preload as=style><link href=js/app.92687945.js rel=preload as=script><link href=js/chunk-vendors.caf18475.js rel=preload as=script><link href=css/app.ad699e7c.css rel=stylesheet></head><body><div id=app></div><script src=js/chunk-vendors.caf18475.js></script><script src=js/app.92687945.js></script></body></html>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -29,14 +29,24 @@
<!-- <button @click="reStart" style="height: 50px;font-size:30px;">开始新一局</button>-->
<!-- </div>-->
<div v-show="game.isOver" :style="{ marginLeft: playerMarginLeft-40 + 'px' }" style="font-size: 20px;color:white;position: fixed;bottom:200px;z-index: 999;">
<div v-show="game.stage==='ready'" :style="{ marginLeft: playerMarginLeft-40 + 'px' }" style="font-size: 20px;color:white;position: fixed;bottom:200px;z-index: 999;">
<button v-show="!game.playerList[0].ready" @mousedown="setReady" style="font-size: 40px;height: 60px;line-height: 30px;border-radius: 4px;background-color: lawngreen;">{{game.playerList[0].ready?'已准备':'准备'}}</button>
<div v-show="game.playerList[0].ready" style="color: red;width:80px;border: solid;border-radius: 4px;position: absolute;">
{{game.playerList[0].ready?'已准备':'未准备'}}
</div>
</div>
<div v-show="!game.isOver" :style="{ marginLeft: playerMarginLeft-150 + 'px' }" style="color:white;position: fixed;bottom:0;width: 100%;height: 200px;line-height: 200px;">
<div v-show="game.stage==='jiaoFen'&&game.currentJiaoFenPlayer===game.playerList[0]" :style="{ marginLeft: playerMarginLeft-40 + 'px' }" style="font-size: 20px;color:white;position: fixed;bottom:200px;z-index: 999;">
<button v-show="true" @mousedown="game.playerList[0].setJiaoFen(0)" style="font-size: 40px;height: 60px;line-height: 30px;border-radius: 4px;background-color: lawngreen;">不叫</button>
<button v-show="true" @mousedown="game.playerList[0].setJiaoFen(1)" style="font-size: 40px;height: 60px;line-height: 30px;border-radius: 4px;background-color: lawngreen;">1分</button>
<button v-show="true" @mousedown="game.playerList[0].setJiaoFen(2)" style="font-size: 40px;height: 60px;line-height: 30px;border-radius: 4px;background-color: lawngreen;">2分</button>
<button v-show="true" @mousedown="game.playerList[0].setJiaoFen(3)" style="font-size: 40px;height: 60px;line-height: 30px;border-radius: 4px;background-color: lawngreen;">3分</button>
<!-- <div v-show="game.playerList[0].ready" style="color: red;width:80px;border: solid;border-radius: 4px;position: absolute;">-->
<!-- {{game.playerList[0].ready?'已准备':'未准备'}}-->
<!-- </div>-->
</div>
<div v-show="game.stage==='play'" :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;">
......@@ -71,7 +81,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 v-show="!game.isOver" style="color:red;font-size: 20px">
<p v-show="game.stage==='play'" style="color:red;font-size: 20px">
{{game.playerList[2].type==='nongmin'?'农民':'地主'}}
</p>
<p>
......@@ -84,7 +94,7 @@
<div v-show="game.currentPlayer===game.playerList[2]" style="color: red;width:150px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;left: 0">
请在{{game.second}}秒内出牌
</div>
<div v-show="game.isOver" style="color: red;width:80px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;left: 0;z-index: 999;">
<div v-show="game.stage==='ready'" style="color: red;width:80px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;left: 0;z-index: 999;">
{{game.playerList[2].ready?'已准备':'未准备'}}
</div>
</div>
......@@ -100,9 +110,14 @@
pass
</div>
</div>
<div v-if="game.stage==='jiaoFen'" style="position: fixed;top:100px;left:200px;height: 200px;">
<div style="height:100%;width:100px;float: left;margin-left:-50px;font-size: 50px;color:#ff0000">
{{game.playerList[2].jiaoFen}}
</div>
</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 v-show="!game.isOver" style="color:red;font-size: 20px">
<p v-show="game.stage==='play'" style="color:red;font-size: 20px">
{{game.playerList[1].type==='nongmin'?'农民':'地主'}}
</p>
<p>
......@@ -114,7 +129,7 @@
<div v-show="game.currentPlayer===game.playerList[1]" style="color: red;width:150px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;right: 0">
请在{{game.second}}秒内出牌
</div>
<div v-show="game.isOver" style="color: red;width:80px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;right: 0;z-index: 999;">
<div v-show="game.stage==='ready'" style="color: red;width:80px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;right: 0;z-index: 999;">
{{game.playerList[1].ready?'已准备':'未准备'}}
</div>
</div>
......@@ -130,6 +145,11 @@
pass
</div>
</div>
<div v-if="game.stage==='jiaoFen'" style="position: fixed;top:100px;right:200px;height: 200px;">
<div style="height:100%;width:100px;float: left;margin-left:-50px;font-size: 50px;color:#ff0000">
{{game.playerList[1].jiaoFen}}
</div>
</div>
</div>
</template>
......
......@@ -7,11 +7,13 @@ class Game{
this.pokerList = [];
this.deskPokerObj = null;
this.oldPokerList = [];
this.currentPlayer = [];
this.currentPlayer = null;
this.currentJiaoFenPlayer = null;
this.jiaoFenCount = 0;
this.dizhu = null;
this.MaxSecond = 60;
this.second = this.MaxSecond;
this.isOver = true;
this.stage = 'ready'; //阶段 ready\jiaoFen\play
this.init();
}
......@@ -23,16 +25,51 @@ class Game{
setReady(){
if(this.playerList[0]&&this.playerList[0].ready&&this.playerList[1]&&this.playerList[1].ready&&this.playerList[2]&&this.playerList[2].ready){
this.start();
this.sendPoker();
this.startJiaoFen();
}
}
//开始叫分
startJiaoFen(){
this.stage = 'jiaoFen';
let index = this.getRandomIntInclusive(0,2);
this.currentJiaoFenPlayer = this.playerList[index];
}
someOneJiaoFen(){
let that = this;
this.jiaoFenCount++;
if(this.jiaoFenCount === 3){
setTimeout(function () {
that.setDiZhu();
},1000);
return;
}else{
this.currentJiaoFenPlayer = this.currentJiaoFenPlayer.next;
}
}
setDiZhu(){
let sortList = this.playerList.slice(0).sort(this.sortByJiaoFen);
let dizhu = sortList[0];
dizhu.type = 'dizhu';
this.dizhu = dizhu;
this.start();
}
sortByJiaoFen(a, b){
return b.jiaoFen - a.jiaoFen;
}
resetTime(){
this.second = this.MaxSecond;
}
timeLoop(){
if(this.isOver){
if(this.stage !== 'play'){
return;
}
this.second--;
......@@ -53,10 +90,7 @@ class Game{
start(){
this.setDiZhu();
this.sendPoker();
this.isOver = false;
this.stage = 'play';
this.timeLoop();
this.currentPlayer = this.dizhu;
if(this.currentPlayer.isRobot){
......@@ -64,12 +98,6 @@ class Game{
}
}
setDiZhu(){
let dizhuIndex = this.getRandomIntInclusive(0,2);
this.playerList[dizhuIndex].type = 'dizhu';
this.dizhu = this.playerList[dizhuIndex];
}
reset(){
this.playerList[0].reset();
......@@ -80,9 +108,11 @@ class Game{
this.deskPokerObj = null;
this.oldPokerList = [];
this.currentPlayer = null;
this.currentJiaoFenPlayer = null;
this.jiaoFenCount = 0;
this.dizhu = null;
this.second = this.MaxSecond;
this.isOver = true;
this.stage = 'ready';
this.initPokerList();
}
......@@ -102,7 +132,6 @@ class Game{
gameOver(){
alert('游戏结束! '+this.currentPlayer.name+' ['+this.currentPlayer.type+'] 胜!');
this.isOver = true;
this.reset();
}
......@@ -120,6 +149,15 @@ class Game{
}
}
sendDiZhuPoker(){
do{
let poker = this.pokerList.splice(0,1)[0];
this.dizhu.addPoker(poker);
}while(this.pokerList.length>0);
this.dizhu.sortPoker();
}
sendPoker(){
let player = this.playerList[0];
do{
......@@ -129,11 +167,6 @@ class Game{
player = player.next;
}while(this.pokerList.length>3);
do{
let poker = this.pokerList.splice(0,1)[0];
this.dizhu.addPoker(poker);
}while(this.pokerList.length>0);
for(let i=0; i<this.playerList.length; i++){
this.playerList[i].sortPoker();
}
......
......@@ -5,6 +5,7 @@ class Player{
constructor(param) {
param = param || {};
this.ready = false; //已准备
this.jiaoFen = 0; //叫分
this.pokerList = [];
this.name = param.name || 'noName'+Math.random();
this.type = param.type || 'nongmin';
......@@ -18,7 +19,15 @@ class Player{
});
this.classifyObj = null;
this.lastSendObj = null;
this.loopRobot();
if(this.isRobot){
this.loopRobot();
}
}
setJiaoFen(fen){
this.jiaoFen = fen;
this.game.someOneJiaoFen();
}
loopRobot(){
......@@ -28,6 +37,9 @@ class Player{
that.setReady();
}
}
if(that.game.stage==='jiaoFen' && that.game.currentJiaoFenPlayer === that){
that.setJiaoFen(3);
}
setTimeout(function(){
that.loopRobot();
......@@ -41,6 +53,7 @@ class Player{
reset(){
this.ready = false;
this.jiaoFen = 0;
this.pokerList = [];
this.type = 'nongmin';
this.classifyObj = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册