-
@@ -105,6 +107,7 @@
import BuyIn from '../components/BuyIn.vue';
import range from '../components/range.vue';
import toast from '../components/toast.vue';
+ import record from '../components/record.vue';
import map from '../utils/map';
import {PokerStyle} from '@/utils/PokerStyle';
import origin from '../utils/origin'
@@ -133,6 +136,7 @@
BuyIn,
range,
toast,
+ record
},
})
export default class Game extends Vue {
@@ -160,6 +164,7 @@
private msg = '';
private time = 30;
private timeSt = 0;
+ private showRecord = false;
private raiseSizeMap = {
firsAction: {
two: 2,
@@ -177,7 +182,7 @@
private playerChange(players: IPlayer[]) {
console.log('player change-------');
this.sitList = this.sitList.map((sit: ISit) => {
- const player = players.find((p) => p.userId === sit.player?.userId);
+ const player = players.find((p) => sit.player && p.userId === sit.player.userId && sit.player.counter > 0);
return Object.assign({}, {}, {player, position: sit.position}) as ISit;
});
this.initSitLink();
@@ -268,6 +273,12 @@
this.isRaise = false;
this.winner = [];
this.showBuyIn = false;
+ this.initSitLink();
+ }
+
+ private showCounterRecord() {
+ this.showRecord = true;
+ this.showSetting = false;
}
private doCountDown() {
@@ -488,6 +499,12 @@
if (msg.action === 'newGame') {
this.init();
}
+
+ if (msg.action === 'pause') {
+ this.players = msg.data.players;
+ this.gaming = false;
+ this.init();
+ }
});
// 系统事件
@@ -509,11 +526,12 @@
if (this.currPlayer && (!this.isPlay || !this.hasSit)) {
this.currPlayer.counter += size;
}
+ console.log('come in buyIn ==================', size)
+ this.showMsg = true;
+ this.msg = this.hasSit && this.isPlay ? `已补充买入 ${ size }, 下局生效` : `已补充买入 ${ size }`;
this.emit('buyIn', {
buyInSize: size,
});
- this.showMsg = true;
- this.msg = this.hasSit ? `已补充买入 ${ size }, 下局生效` : `已补充买入 ${ size }`;
} catch (e) {
console.log(e);
}
@@ -577,7 +595,7 @@
+
+
+
+
J-POKER
+
+
+
+ sign in
+ sign up
+
+
+
+
+
+
diff --git a/client/src/views/register.vue b/client/src/views/register.vue
index 7f02c91..36f4b12 100644
--- a/client/src/views/register.vue
+++ b/client/src/views/register.vue
@@ -1,81 +1,124 @@
-
-
-
-
-
+
+
+
+
J-POKER
+
Create Account
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/client/yarn.lock b/client/yarn.lock
index d20581c..131f702 100644
--- a/client/yarn.lock
+++ b/client/yarn.lock
@@ -926,6 +926,11 @@
resolved "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
+"@types/fastclick@^1.0.29":
+ version "1.0.29"
+ resolved "https://registry.npmjs.org/@types/fastclick/-/fastclick-1.0.29.tgz#90f43082848187b42250620f13ec93e32393169b"
+ integrity sha512-umkMhdAk3dNAenNuhoKPzZUYN9uBHrK8UAvUKWMLst80Gj4BWC1syLuiNzdBzPpM2b2Xg036vvl6X1wiu1Piuw==
+
"@types/glob@^7.1.1":
version "7.1.1"
resolved "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
@@ -2618,6 +2623,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
safe-buffer "^5.0.1"
sha.js "^2.4.8"
+cross-env@^7.0.2:
+ version "7.0.2"
+ resolved "https://registry.npm.taobao.org/cross-env/download/cross-env-7.0.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcross-env%2Fdownload%2Fcross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9"
+ integrity sha1-vV7TEzmpOjQYrE88qco0Awgq5fk=
+ dependencies:
+ cross-spawn "^7.0.1"
+
cross-spawn@^5.0.1:
version "5.1.0"
resolved "https://registry.npm.taobao.org/cross-spawn/download/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -2638,7 +2650,7 @@ cross-spawn@^6.0.0:
shebang-command "^1.2.0"
which "^1.2.9"
-cross-spawn@^7.0.0:
+cross-spawn@^7.0.0, cross-spawn@^7.0.1:
version "7.0.2"
resolved "https://registry.npm.taobao.org/cross-spawn/download/cross-spawn-7.0.2.tgz#d0d7dcfa74e89115c7619f4f721a94e1fdb716d6"
integrity sha1-0Nfc+nTokRXHYZ9PchqU4f23FtY=
diff --git a/server/src/app/io/controller/game.ts b/server/src/app/io/controller/game.ts
index 20a1b8d..3a74f4b 100644
--- a/server/src/app/io/controller/game.ts
+++ b/server/src/app/io/controller/game.ts
@@ -1,9 +1,9 @@
'use strict';
import BaseSocketController from '../../../lib/baseSocketController';
-import {IRoomInfo, ISit} from '../../../interface/IGameRoom';
-import {PokerGame} from '../../core/PokerGame';
-import {IPlayer} from '../../core/Player';
-import {ILinkNode, Link} from '../../../utils/Link';
+import { IRoomInfo, ISit } from '../../../interface/IGameRoom';
+import { PokerGame } from '../../core/PokerGame';
+import { IPlayer } from '../../core/Player';
+import { ILinkNode, Link } from '../../../utils/Link';
class GameController extends BaseSocketController {
@@ -32,14 +32,19 @@ class GameController extends BaseSocketController {
currNode = next;
}
} else {
- sitDownPlayer = roomInfo.sit.filter(s => s.player && s.player.counter > 0).map(sit => sit.player);
+ sitDownPlayer = roomInfo.sit.filter(
+ s => s.player && s.player.counter > 0).map(sit => sit.player);
if (sitDownPlayer.length < 2) {
throw 'player not enough';
}
roomInfo.sitLink = new Link
(sitDownPlayer).link;
}
console.log('sitDownPlayer===============sit11111111111', sitDownPlayer);
- console.log('roomInfo.sitLink===============sit11111111111', roomInfo.sitLink);
+ console.log('roomInfo.sitLink===============sit11111111111',
+ roomInfo.sitLink);
+ if (sitDownPlayer.length < 2) {
+ throw 'player not enough';
+ }
if (!roomInfo.game) {
roomInfo.game = null;
roomInfo.game = new PokerGame({
@@ -88,7 +93,12 @@ class GameController extends BaseSocketController {
if (roomInfo.game) {
// game over show winner
if (roomInfo.game.status === 7) {
- let winner: any = [[{ ...roomInfo.game.winner[0][0], handCard: [] }]];
+ let winner: any = [
+ [
+ {
+ ...roomInfo.game.winner[0][0],
+ handCard: [],
+ }]];
let allPlayers = winner[0];
// only player, other fold
if (roomInfo.game.getPlayers().length !== 1) {
@@ -153,51 +163,79 @@ class GameController extends BaseSocketController {
}
async reStart() {
- const roomInfo: IRoomInfo = await this.getRoomInfo();
- const dealer = roomInfo.sitLink?.next?.node;
- roomInfo.game = null;
- // init player status
- roomInfo.players.forEach(p => {
- p.status = 0;
- });
- console.log('sit =======', roomInfo.sit);
- // calculate re buy in
- roomInfo.sit.forEach((s: ISit) => {
- if (s.player) {
- if (s.player.counter === 0) {
- delete s.player;
- }
- console.log('roomInfo.players===============', roomInfo.players);
- const player = roomInfo.players.find(p => p.userId === s.player?.userId);
- if (player) {
- s.player.counter += Number(player.reBuy);
- console.log('cal reBuy ===============================', s.player, player.reBuy);
- player.reBuy = 0;
- s.player.reBuy = 0;
- }
- }
- });
-
- // init sit link
- const players = roomInfo.sit.filter(s => s.player && s.player.counter > 0).map(s => s.player) || [];
- console.log(players, 'players===========');
- let link: ILinkNode | null = new Link(players).link;
- while (link?.node.userId !== dealer?.userId) {
- link = link?.next || null;
- }
- roomInfo.sitLink = link;
- console.log('dealer ===================', dealer, link);
- // new game
- this.nsp.adapter.clients([ this.roomNumber ], async (err: any, clients: any) => {
- // 广播信息
- this.nsp.to(this.roomNumber).emit('online', {
- clients,
- action: 'newGame',
- target: 'participator',
- data: {},
+ try {
+ const roomInfo: IRoomInfo = await this.getRoomInfo();
+ const dealer = roomInfo.sitLink?.next?.node;
+ roomInfo.game = null;
+ // init player status
+ roomInfo.players.forEach(p => {
+ p.status = 0;
});
- await this.playGame();
- });
+ console.log('sit =======', roomInfo.sit);
+ // calculate re buy in
+ roomInfo.sit.forEach((s: ISit) => {
+ if (s.player) {
+ if (s.player.counter === 0) {
+ delete s.player;
+ } else {
+ console.log('roomInfo.players===============', roomInfo.players);
+ const player = roomInfo.players.find(
+ p => p.userId === s.player?.userId);
+ if (player) {
+ s.player.counter += Number(player.reBuy);
+ console.log('cal reBuy ===============================', s.player,
+ player.reBuy);
+ player.reBuy = 0;
+ s.player.reBuy = 0;
+ }
+ }
+ }
+ });
+ const players = roomInfo.sit.filter(s => s.player && s.player.counter > 0)
+ .map(s => s.player) || [];
+ if (players.length >= 2) {
+ // init sit link
+ console.log(players, 'players===========');
+ let link: ILinkNode | null = new Link(players).link;
+ while (link?.node.userId !== dealer?.userId) {
+ link = link?.next || null;
+ }
+ roomInfo.sitLink = link;
+ console.log('dealer ===================', dealer, link);
+ // new game
+ this.nsp.adapter.clients([ this.roomNumber ],
+ async (err: any, clients: any) => {
+ // 广播信息
+ this.nsp.to(this.roomNumber).emit('online', {
+ clients,
+ action: 'newGame',
+ target: 'participator',
+ data: {},
+ });
+ await this.playGame();
+ });
+ } else {
+ roomInfo.sitLink = null;
+ console.log('come in only one player');
+ // player not enough
+ // await this.updateGameInfo();
+ // new game
+ this.nsp.adapter.clients([ this.roomNumber ],
+ async (err: any, clients: any) => {
+ // 广播信息
+ this.nsp.to(this.roomNumber).emit('online', {
+ clients,
+ action: 'pause',
+ target: 'participator',
+ data: {
+ players: roomInfo.players,
+ },
+ });
+ });
+ }
+ } catch (e) {
+ console.log(e + 'restart ex');
+ }
}
async buyIn() {
@@ -212,10 +250,12 @@ class GameController extends BaseSocketController {
const isGaming = !!roomInfo.game;
if (player) {
if (roomInfo.game) {
- const inTheGame = roomInfo.game.allPlayer.find(p => p.userId === userInfo.userId);
+ const inTheGame = roomInfo.game.allPlayer.find(
+ p => p.userId === userInfo.userId);
// player in the game, can't buy in
if (inTheGame) {
player.reBuy += Number(buyInSize);
+ player.buyIn += Number(buyInSize);
}
} else {
player.buyIn += Number(buyInSize);
@@ -230,17 +270,18 @@ class GameController extends BaseSocketController {
roomInfo.players.push(player);
}
if (!isGaming) {
- this.nsp.adapter.clients([ this.roomNumber ], (err: any, clients: any) => {
- // 广播信息
- this.nsp.to(this.roomNumber).emit('online', {
- clients,
- action: 'players',
- target: 'participator',
- data: {
- players: roomInfo.players,
- },
+ this.nsp.adapter.clients([ this.roomNumber ],
+ (err: any, clients: any) => {
+ // 广播信息
+ this.nsp.to(this.roomNumber).emit('online', {
+ clients,
+ action: 'players',
+ target: 'participator',
+ data: {
+ players: roomInfo.players,
+ },
+ });
});
- });
}
} catch (e) {
console.log(e);
@@ -321,7 +362,8 @@ class GameController extends BaseSocketController {
}
});
}
- console.log('fold ===============', roomInfo.players, roomInfo.game.allPlayer);
+ console.log('fold ===============', roomInfo.players,
+ roomInfo.game.allPlayer);
// todo notice next player action
await this.updateGameInfo();
console.log('curr player', roomInfo.game.currPlayer.node);