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

新增 准备阶段

上级 7ec7c9c9
.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-74905788]{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-74905788]:hover{background-color:#faebd7}.selected[data-v-74905788]{margin-top:-20px}.s[data-v-74905788]{background-image:url(../img/s.aa339508.jpg)}.x[data-v-74905788]{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.8693bba6.css rel=preload as=style><link href=js/app.fdd410da.js rel=preload as=script><link href=js/chunk-vendors.caf18475.js rel=preload as=script><link href=css/app.8693bba6.css rel=stylesheet></head><body><div id=app></div><script src=js/chunk-vendors.caf18475.js></script><script src=js/app.fdd410da.js></script></body></html> <!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 \ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -5,17 +5,17 @@ ...@@ -5,17 +5,17 @@
您的浏览器不支持 audio 元素。 您的浏览器不支持 audio 元素。
</audio> </audio>
<div v-show="false" style="width: 300px;height:300px;float: left; position: fixed ; left: 0; top: 0px; background-color: aliceblue; text-align: center"> <!-- <div v-show="false" style="width: 300px;height:300px;float: left; position: fixed ; left: 0; top: 0px; background-color: aliceblue; text-align: center">-->
<span> <!-- <span>-->
手牌:{{player2Str[1]}} <!-- 手牌:{{player2Str[1]}}-->
</span> <!-- </span>-->
</div> <!-- </div>-->
<div v-show="false" 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> <!-- <span>-->
手牌:{{player1Str[1]}} <!-- 手牌:{{player1Str[1]}}-->
</span> <!-- </span>-->
</div> <!-- </div>-->
<div v-show="false" 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;"> <div style="width: 300px;word-wrap: break-word;">
...@@ -25,11 +25,18 @@ ...@@ -25,11 +25,18 @@
</div> </div>
</div> </div>
<div style="position: fixed;left: 10px;bottom: 10px;"> <!-- <div style="position: fixed;left: 10px;bottom: 10px;">-->
<button @click="reStart" style="height: 50px;font-size:30px;">开始新一局</button> <!-- <button @click="reStart" style="height: 50px;font-size:30px;">开始新一局</button>-->
</div> <!-- </div>-->
<div v-show="game.isOver" :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 :style="{ marginLeft: playerMarginLeft-150 + 'px' }" style="color:white;position: fixed;bottom:0;width: 100%;height: 200px;line-height: 200px;"> <div v-show="!game.isOver" :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> 你是 <span style="color:red;font-size: 20px">{{game.playerList[0].type==='nongmin'?'农民':'地主'}}</span>
</div> </div>
<div :style="{ marginLeft: playerMarginLeft + 'px' }" style="position: fixed;bottom:0;width: 100%;height: 200px;"> <div :style="{ marginLeft: playerMarginLeft + 'px' }" style="position: fixed;bottom:0;width: 100%;height: 200px;">
...@@ -40,7 +47,7 @@ ...@@ -40,7 +47,7 @@
</div> </div>
</div> </div>
<div style="position: fixed;bottom:200px;width: 100%;height: 100px;text-align:left;"> <div v-show="game.currentPlayer===game.playerList[0]" style="position: fixed;bottom:200px;width: 100%;height: 100px;text-align:left;">
<div :style="{ marginLeft: buttonMarginLeft + 'px' }" style="width: 400px;height: 60px;"> <div :style="{ marginLeft: buttonMarginLeft + 'px' }" style="width: 400px;height: 60px;">
<button @click="pass" style="height: 60px;border-radius: 4px;float:left;font-size:40px;background-color: red">不出</button> <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> <button @click="sendPoker2" style="height: 60px;border-radius: 4px;float:right;font-size:40px;background-color: lawngreen">出牌</button>
...@@ -64,7 +71,7 @@ ...@@ -64,7 +71,7 @@
</div> </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"> <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 style="color:red;font-size: 20px"> <p v-show="!game.isOver" style="color:red;font-size: 20px">
{{game.playerList[2].type==='nongmin'?'农民':'地主'}} {{game.playerList[2].type==='nongmin'?'农民':'地主'}}
</p> </p>
<p> <p>
...@@ -77,6 +84,9 @@ ...@@ -77,6 +84,9 @@
<div v-show="game.currentPlayer===game.playerList[2]" style="color: red;width:150px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;left: 0"> <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}}秒内出牌 请在{{game.second}}秒内出牌
</div> </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;">
{{game.playerList[2].ready?'已准备':'未准备'}}
</div>
</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-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" :class="{ s:item.number===16, x:item.number===17 }"> <div v-for="item in game.playerList[2].lastSendObj.poker" class="pokerDesk" :class="{ s:item.number===16, x:item.number===17 }">
...@@ -92,7 +102,7 @@ ...@@ -92,7 +102,7 @@
</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"> <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 style="color:red;font-size: 20px"> <p v-show="!game.isOver" style="color:red;font-size: 20px">
{{game.playerList[1].type==='nongmin'?'农民':'地主'}} {{game.playerList[1].type==='nongmin'?'农民':'地主'}}
</p> </p>
<p> <p>
...@@ -104,6 +114,9 @@ ...@@ -104,6 +114,9 @@
<div v-show="game.currentPlayer===game.playerList[1]" style="color: red;width:150px;border: solid;border-radius: 4px;position: absolute;bottom:-50px;right: 0"> <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}}秒内出牌 请在{{game.second}}秒内出牌
</div> </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;">
{{game.playerList[1].ready?'已准备':'未准备'}}
</div>
</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-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" :class="{ s:item.number===16, x:item.number===17 }"> <div v-for="item in game.playerList[1].lastSendObj.poker" class="pokerDesk" :class="{ s:item.number===16, x:item.number===17 }">
...@@ -194,6 +207,12 @@ export default { ...@@ -194,6 +207,12 @@ export default {
window.game = this.game; window.game = this.game;
}, },
methods:{ methods:{
setReady: function() {
let that = this;
that.game.playerList[0].setReady();
},
enter: function(e, poker){ enter: function(e, poker){
if(e.buttons === 1){ if(e.buttons === 1){
this.pickPoker(poker); this.pickPoker(poker);
......
...@@ -19,9 +19,12 @@ class Game{ ...@@ -19,9 +19,12 @@ class Game{
init(){ init(){
this.initPokerList(); this.initPokerList();
this.initPlayerList(); this.initPlayerList();
this.sendPoker(); }
this.start(); 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();
}
} }
resetTime(){ resetTime(){
...@@ -50,6 +53,9 @@ class Game{ ...@@ -50,6 +53,9 @@ class Game{
start(){ start(){
this.setDiZhu();
this.sendPoker();
this.isOver = false; this.isOver = false;
this.timeLoop(); this.timeLoop();
this.currentPlayer = this.dizhu; this.currentPlayer = this.dizhu;
...@@ -58,6 +64,29 @@ class Game{ ...@@ -58,6 +64,29 @@ class Game{
} }
} }
setDiZhu(){
let dizhuIndex = this.getRandomIntInclusive(0,2);
this.playerList[dizhuIndex].type = 'dizhu';
this.dizhu = this.playerList[dizhuIndex];
}
reset(){
this.playerList[0].reset();
this.playerList[1].reset();
this.playerList[2].reset();
this.pokerList = [];
this.deskPokerObj = null;
this.oldPokerList = [];
this.currentPlayer = null;
this.dizhu = null;
this.second = this.MaxSecond;
this.isOver = true;
this.initPokerList();
}
next(){ next(){
let over = this.checkGameOver(); let over = this.checkGameOver();
if(over){ if(over){
...@@ -74,6 +103,8 @@ class Game{ ...@@ -74,6 +103,8 @@ class Game{
gameOver(){ gameOver(){
alert('游戏结束! '+this.currentPlayer.name+' ['+this.currentPlayer.type+'] 胜!'); alert('游戏结束! '+this.currentPlayer.name+' ['+this.currentPlayer.type+'] 胜!');
this.isOver = true; this.isOver = true;
this.reset();
} }
checkGameOver(){ checkGameOver(){
...@@ -116,12 +147,12 @@ class Game{ ...@@ -116,12 +147,12 @@ class Game{
game: this, game: this,
}); });
let player1 = new Player({ let player1 = new Player({
name: 'robot1', name: '机器人1',
isRobot: true, isRobot: true,
game: this, game: this,
}); });
let player2 = new Player({ let player2 = new Player({
name: 'robot2', name: '机器人2',
isRobot: true, isRobot: true,
game: this, game: this,
}); });
...@@ -134,9 +165,6 @@ class Game{ ...@@ -134,9 +165,6 @@ class Game{
this.playerList[1].last = this.playerList[0]; this.playerList[1].last = this.playerList[0];
this.playerList[2].last = this.playerList[1]; this.playerList[2].last = this.playerList[1];
let dizhuIndex = this.getRandomIntInclusive(0,2);
this.playerList[dizhuIndex].type = 'dizhu';
this.dizhu = this.playerList[dizhuIndex];
} }
initPokerList(){ initPokerList(){
......
...@@ -4,6 +4,7 @@ import AI from "./AI"; ...@@ -4,6 +4,7 @@ import AI from "./AI";
class Player{ class Player{
constructor(param) { constructor(param) {
param = param || {}; param = param || {};
this.ready = false; //已准备
this.pokerList = []; this.pokerList = [];
this.name = param.name || 'noName'+Math.random(); this.name = param.name || 'noName'+Math.random();
this.type = param.type || 'nongmin'; this.type = param.type || 'nongmin';
...@@ -16,7 +17,33 @@ class Player{ ...@@ -16,7 +17,33 @@ class Player{
game: param.game, game: param.game,
}); });
this.classifyObj = null; this.classifyObj = null;
this.lastSendObj = null;
this.loopRobot();
}
loopRobot(){
let that = this;
if(that.isRobot){
if(!that.ready){
that.setReady();
}
}
setTimeout(function(){
that.loopRobot();
},2000);
}
setReady(){
this.ready = true;
this.game.setReady();
}
reset(){
this.ready = false;
this.pokerList = [];
this.type = 'nongmin';
this.classifyObj = null;
this.lastSendObj = null; this.lastSendObj = null;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册