diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d32ca55..31a105d 100755 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -26,8 +26,19 @@ + - + + + + + + + + + + + + - @@ -194,9 +205,10 @@ - - + + + diff --git a/README.md b/README.md index 3b55491..aef6cc1 100755 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Detail: [client-readme](https://github.com/wzdwc/TexasPokerGame/tree/master/clie ``` ## Demo See: [demo](http://www.jojgame.com) -![img](https://github.com/wzdwc/TexasPokerGame/blob/master/gif/qrCode.jpg) +![img](https://github.com/wzdwc/TexasPokerGame/blob/master/gif/qrcode.jpg) ![img](https://github.com/wzdwc/TexasPokerGame/blob/master/gif/demo1.gif) diff --git a/client/src/components/Action.vue b/client/src/components/Action.vue index 75ecc8e..6cd39c3 100644 --- a/client/src/components/Action.vue +++ b/client/src/components/Action.vue @@ -16,15 +16,10 @@
- - {{Math.floor(size * prevSize)}} - - {{Math.floor(size * pot)}} + > {{Math.floor(size)}}
@@ -85,18 +80,18 @@ import { IPlayer } from '@/interface/IPlayer'; private playClick = false; private playRaise = false; private playFold = false; - private raiseSizeMap = { - firsAction: { - two: 2, - three: 3, - four: 4, - }, - other: { - oneThirdPot: 0.5, - halfPot: 0.75, - pot: 1, - }, - }; + // private raiseSizeMap = { + // firsAction: { + // two: 2, + // three: 3, + // four: 4, + // }, + // other: { + // oneThirdPot: 0.5, + // halfPot: 0.75, + // pot: 1, + // }, + // }; @Watch('isAction') private wAction(val: boolean) { @@ -111,13 +106,20 @@ import { IPlayer } from '@/interface/IPlayer'; this.raiseSize = val > this.currPlayer.counter ? this.currPlayer.counter : val; } + get raiseSizeMap() { + let size = this.pot > this.baseSize * 4 ? this.pot : this.baseSize * 2; + if (this.prevSize > 1) { + size = this.prevSize * 4; + } + return size === this.baseSize * 2 ? [ size, 2 * size, 3 * size ] : [ 0.5 * size, 0.75 * size, size ]; + } + get canActionSize() { return Number(this.currPlayer && this.currPlayer.counter + this.currPlayer.actionSize); } private raise(size: number) { - const realSize = size === 0 ? this.prevSize * 3 : size * this.pot; - this.action(`raise:${Math.floor(realSize)}`); + this.action(`raise:${Math.floor(size)}`); } private action(command: string) { @@ -137,9 +139,8 @@ import { IPlayer } from '@/interface/IPlayer'; } private showActionSize(multiple: number) { - // big then double pre-size and small then counter return this.currPlayer - && this.currPlayer.counter > Math.floor(multiple * this.pot) + && this.currPlayer.counter > Math.floor(multiple) && this.prevSize * 2 <= Math.floor(multiple * this.pot) && this.baseSize * 2 <= Math.floor(multiple * this.pot); } diff --git a/client/src/components/SendMsg.vue b/client/src/components/SendMsg.vue index e1763dd..42bbde9 100644 --- a/client/src/components/SendMsg.vue +++ b/client/src/components/SendMsg.vue @@ -1,80 +1,90 @@ - - - - - - + + + + + + diff --git a/client/src/components/SitList.vue b/client/src/components/SitList.vue index 030f633..37f4b55 100644 --- a/client/src/components/SitList.vue +++ b/client/src/components/SitList.vue @@ -78,7 +78,7 @@
diff --git a/client/src/components/msgList.vue b/client/src/components/msgList.vue new file mode 100644 index 0000000..3b29246 --- /dev/null +++ b/client/src/components/msgList.vue @@ -0,0 +1,39 @@ + + + + diff --git a/client/src/interface/IMsgList.ts b/client/src/interface/IMsgList.ts index 3509f26..f2d5a6a 100644 --- a/client/src/interface/IMsgList.ts +++ b/client/src/interface/IMsgList.ts @@ -1,19 +1,4 @@ -enum PlayerType { - READY, - SIT_DOWN, - GAMING, -} - -export interface IPlayer { - counter: number; - nickName: string; - actionSize: number; - actionCommand: string; - type: string; - userId?: number; - handCard?: string[]; - buyIn: number; - status: number; - income?: number; - isSit: boolean; -} + +export interface IMsgList { + msg: string; +} diff --git a/client/src/utils/PokerStyle.ts b/client/src/utils/PokerStyle.ts index b560fea..db6c519 100644 --- a/client/src/utils/PokerStyle.ts +++ b/client/src/utils/PokerStyle.ts @@ -268,10 +268,11 @@ export class PokerStyle implements IPokerStyle { // tow pair if (isTwo.length >= 2) { const towPair = isTwo; + const threeTowPair = towPair[2] || ''; towPair.length = 2; isTowPair = towPair.join(''); // third tow pair card big then high card - const highCardForTowPair = isTwo[3] && isTwo[3] > highCard[0] ? isTwo[3] : highCard[0]; + const highCardForTowPair = threeTowPair > highCard[0] ? threeTowPair : highCard[0]; isTowPair += highCardForTowPair; this.pokerStyle[7] = isTowPair; return; diff --git a/client/src/views/game.vue b/client/src/views/game.vue index 60cea5b..fffd66d 100644 --- a/client/src/views/game.vue +++ b/client/src/views/game.vue @@ -50,13 +50,13 @@ - + { const pot = winner.evPot >= this.pot ? this.pot : winner.evPot; const leftPot = pot - prevEvPot; - let income = leftPot / (winnerList.length - index); + let income = Math.floor(leftPot / (winnerList.length - index)); if (index === winnerList.length - 1) { // not only one winner if (index !== 0) { diff --git a/server/src/app/core/PokerStyle.ts b/server/src/app/core/PokerStyle.ts index a8cc7eb..f2ea330 100644 --- a/server/src/app/core/PokerStyle.ts +++ b/server/src/app/core/PokerStyle.ts @@ -153,10 +153,11 @@ export class PokerStyle implements IPokerStyle { // tow pair if (isTwo.length >= 2) { const towPair = isTwo; + const threeTowPair = towPair[2] || ''; towPair.length = 2; isTowPair = towPair.join(''); // third tow pair card big then high card - const highCardForTowPair = isTwo[3] && isTwo[3] > highCard[0] ? isTwo[3] : highCard[0]; + const highCardForTowPair = threeTowPair > highCard[0] ? threeTowPair : highCard[0]; isTowPair += highCardForTowPair; this.pokerStyle[7] = isTowPair; return; diff --git a/server/src/app/io/controller/game.ts b/server/src/app/io/controller/game.ts index 6d0d6e6..f9fdcc5 100644 --- a/server/src/app/io/controller/game.ts +++ b/server/src/app/io/controller/game.ts @@ -243,12 +243,15 @@ class GameController extends BaseSocketController { p.status = 0; }); console.log('sit =======', roomInfo.sit); + console.log('roomInfo =======', roomInfo); // calculate re buy in roomInfo.sit.forEach((s: ISit) => { if (s.player) { const player = roomInfo.players.find( p => p.userId === s.player?.userId); if (player) { + // new player + s.player.counter = player.counter; s.player.counter += Number(player.reBuy); console.log('cal reBuy ===============================', s.player, player.reBuy); @@ -317,7 +320,9 @@ class GameController extends BaseSocketController { player.buyIn += Number(buyInSize); player.counter += Number(buyInSize); } + console.log('user in the game------', player); } else { + console.log('user not in the game------', player); player.buyIn += Number(buyInSize); player.counter += Number(buyInSize); } @@ -334,6 +339,7 @@ class GameController extends BaseSocketController { await this.adapter('online', 'players', { players: roomInfo.players, }); + console.log('ont in the game', player); } } catch (e) { console.log(e); diff --git a/server/src/lib/baseSocketController.ts b/server/src/lib/baseSocketController.ts index 79dcb98..6a60452 100644 --- a/server/src/lib/baseSocketController.ts +++ b/server/src/lib/baseSocketController.ts @@ -77,6 +77,7 @@ export default class BaseSocketController extends Controller { }, smallBlind: roomInfo.config.smallBlind, }; + console.log('gameInfo ==========', gameInfo); await this.adapter('online', 'gameInfo', gameInfo); } } diff --git a/server/test/app/core/pokerStyle.test.ts b/server/test/app/core/pokerStyle.test.ts index 911c0cf..7d09b46 100644 --- a/server/test/app/core/pokerStyle.test.ts +++ b/server/test/app/core/pokerStyle.test.ts @@ -61,8 +61,8 @@ describe('test/app/core/pokerStyle.test.ts', () => { assert.strictEqual(pokerStyle.getPokerWeight() , '000000000miged') }); it('compare card', async () => { - let pokerStyle: PokerStyle = new PokerStyle(['e2','f3','g2','h4','k3', 'm1', 'l1'], true) - let pokerStyle2: PokerStyle = new PokerStyle(['e2','f3','g2','h4','k3','l1', 'i2'], true) + let pokerStyle: PokerStyle = new PokerStyle(['k2','k3','g2','e4','m3', 'm1', 'g1'], true) + let pokerStyle2: PokerStyle = new PokerStyle(['k2','k3','g2','e4','m3','m2', 'c2'], true) console.log('getPokerValueCard', pokerStyle.getPokerValueCard()) assert.strictEqual(pokerStyle.getPokerWeight() , pokerStyle2.getPokerWeight()) });