edit readme,fix some bug,edit client ui

This commit is contained in:
wzdwc
2020-09-12 20:52:18 +08:00
parent 3105f88f97
commit 70ecee7d87
157 changed files with 6409 additions and 7263 deletions
+329 -218
View File
@@ -1,4 +1,4 @@
import { PokerGame, EGameStatus } from '../../../src/app/core/PokerGame';
import { PokerGame } from '../../../src/app/core/PokerGame';
// @ts-ignore
import { expect } from 'chai';
import { IPlayer } from '../../../src/app/core/Player';
@@ -7,265 +7,376 @@ describe('test/app/core/pokerGame.test.ts', () => {
const users: IPlayer[] = [
{
userId: '1',
counter: 200,
counter: 511,
nickName: '1',
account: '1',
socketId: '1',
buyIn: 0,
reBuy: 0,
actionSize: 0,
actionCommand: '',
status: 0,
type: '',
},
{
userId: '2',
counter: 400,
counter: 427,
nickName: '2',
account: '2',
socketId: '2',
buyIn: 0,
reBuy: 0,
actionSize: 0,
actionCommand: '',
status: 0,
type: '',
},
{
userId: '3',
counter: 730,
nickName: '3',
account: '3',
socketId: '3',
buyIn: 0,
reBuy: 0,
actionSize: 0,
actionCommand: '',
status: 0,
type: '',
},
{
userId: '4',
counter: 744,
nickName: '4',
account: '4',
socketId: '4',
buyIn: 0,
reBuy: 0,
actionSize: 0,
actionCommand: '',
status: 0,
type: '',
},
// {
// userId: '3',
// counter: 50,
// nick_name: '3',
// account: '3',
// socketId: '3',
// userId: '5',
// counter: 802,
// nickName: '5',
// account: '5',
// socketId: '5',
// buyIn: 0,
// reBuy: 0,
// actionSize: 0,
// actionCommand: '',
// status: 0,
// type: '',
// },
];
/**
* game ready
*/
it('game init', async () => {
const game = new PokerGame({
smallBlind: 1,
users,
updateCommonCard: () => {},
gameOverCallBack: () => {},
});
game.play();
expect(game.status).to.equal(EGameStatus.GAME_ACTION);
expect(game.pot).to.equal(3);
expect(game.pot).to.equal(3);
expect(game.playerLink.getNode(1).node.actionSize).to.equal(1);
});
// it('game init', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {},
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// expect(game.status).to.equal(EGameStatus.GAME_ACTION);
// expect(game.pot).to.equal(3);
// expect(game.pot).to.equal(3);
// // expect(game.playerLink.getNode(1).node.actionSize).to.equal(1);
// });
/**
* game playing
*/
it('game play', async () => {
const game = new PokerGame({
smallBlind: 1,
users,
updateCommonCard: () => {},
gameOverCallBack: () => {},
});
game.play();
game.action('raise:9');
game.action('call');
// game.action('call');
// game.action('call');
// game.action('call');
// game.action('check');
// game.sendCard();
// game.action('raise:10');
// game.action('raise:20');
// game.action('call');
// game.action('call');
// game.action('raise:40');
// game.action('call');
// game.action('call');
// game.action('call');
// game.action('call');
// game.sendCard();
// game.action('allin');
// game.action('allin');
// game.action('allin');
// game.action('fold');
// game.action('allin');
console.log('cc');
// game.action('raise:10');
console.log(game.commonCard);
console.log(game.pot);
console.log(game.getPlayers());
console.log(game.winner);
// console.log(game.winner[0][0], game.commonCard);
});
it('raise check ', async () => {
const game = new PokerGame({
smallBlind: 1,
users,
updateCommonCard: () => {
if (game.status < 6) {
game.startActionRound();
game.sendCard();
}
},
gameOverCallBack: () => {},
});
game.play();
game.action('raise:9');
game.action('call');
game.action('check');
game.action('check');
// game.action('raise:10');
console.log(game.commonCard);
console.log(game.pot);
console.log(game.getPlayers());
console.log(game.winner);
// console.log(game.winner[0][0], game.commonCard);
});
it('raise call raise fold ', async () => {
const game = new PokerGame({
smallBlind: 1,
users,
updateCommonCard: () => {
if (game.status < 6) {
game.startActionRound();
game.sendCard();
}
},
gameOverCallBack: () => {},
});
game.play();
game.action('raise:9');
game.action('call');
// game.action('check');
// game.action('check');
game.action('raise:90');
game.action('fold');
// game.action('raise:10');
console.log(game.commonCard);
console.log(game.pot);
console.log(game.getPlayers());
console.log(game.winner);
// console.log(game.winner[0][0], game.commonCard);
});
it('show down', async () => {
const game = new PokerGame({
smallBlind: 1,
users,
updateCommonCard: () => {
if (game.status < 6) {
game.startActionRound();
game.sendCard();
}
},
gameOverCallBack: () => {},
});
game.play();
// pre flop
game.action('raise:9');
game.action('call');
// flop
game.action('raise:90');
game.action('call');
// turn
game.action('check');
game.action('check');
// river
game.action('raise:90');
game.action('call');
// show down
// game.action('raise:10');
console.log(game.commonCard);
console.log(game.pot);
console.log(game.getPlayers());
console.log(game.winner);
// console.log(game.winner[0][0], game.commonCard);
});
it('all player allin for pre flop', async () => {
const game = new PokerGame({
smallBlind: 1,
users,
updateCommonCard: () => {
if (game.status < 6) {
game.startActionRound();
game.sendCard();
}
},
gameOverCallBack: () => {},
});
game.play();
// pre flop
game.action('raise:9');
game.action('allin');
game.action('allin');
// game over
// game.action('raise:10');
console.log(game.commonCard);
console.log(game.pot);
console.log(game.getPlayers());
console.log(game.winner);
// console.log(game.winner[0][0], game.commonCard);
});
// it('game play', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {},
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// game.action('fold');
// });
//
// it('raise check ', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {
// if (game.status < 6) {
// game.startActionRound();
// game.sendCard();
// }
// },
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// game.action('raise:9');
// game.action('call');
// game.action('check');
// game.action('check');
// // game.action('raise:10');
// // console.log(game.commonCard);
// // console.log(game.pot);
// // console.log(game.getPlayers());
// // console.log(game.winner);
// // console.log(game.winner[0][0], game.commonCard);
// });
//
// it('raise call raise fold ', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {
// if (game.status < 6) {
// game.startActionRound();
// game.sendCard();
// }
// },
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// game.action('raise:9');
// game.action('call');
// // game.action('check');
// // game.action('check');
// game.action('raise:90');
// game.action('fold');
// // game.action('raise:10');
// // console.log(game.commonCard);
// // console.log(game.pot);
// // console.log(game.getPlayers());
// // console.log(game.winner);
// // console.log(game.winner[0][0], game.commonCard);
// });
//
// it('show down', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {
// if (game.status < 6) {
// game.startActionRound();
// game.sendCard();
// }
// },
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// // pre flop
// game.action('raise:9');
// game.action('call');
// // flop
// game.action('raise:90');
// game.action('call');
// // turn
// game.action('check');
// game.action('check');
// // river
// game.action('raise:90');
// game.action('call');
// // show down
// // game.action('raise:10');
// // console.log(game.commonCard);
// // console.log(game.pot);
// // console.log(game.getPlayers());
// // console.log(game.winner);
// // console.log(game.winner[0][0], game.commonCard);
// });
//
// it('all player allin for pre flop', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {
// if (game.status < 6) {
// game.startActionRound();
// game.sendCard();
// }
// },
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// // pre flop
// game.action('raise:9');
// game.action('allin');
// game.action('allin');
// // game over
// // game.action('raise:10');
// // console.log('all player ------commonCard', game.commonCard);
// // console.log('all player ------pot', game.pot);
// // console.log('all player ------getPlayers', game.getPlayers());
// // console.log('all player ------winner', game.winner);
// // console.log(game.winner[0][0], game.commonCard);
// });
//
it('one player allin', async () => {
const game = new PokerGame({
smallBlind: 1,
isShort: false,
users,
updateCommonCard: () => {
actionRoundComplete: () => {
if (game.status < 6) {
game.startActionRound();
game.sendCard();
}
},
gameOverCallBack: () => {},
autoActionCallBack: () => {},
});
game.play();
// pre flop
game.action('raise:9');
game.action('call');
game.action('raise: 9');
game.action('raise: 18');
game.action('raise: 200');
game.action('allin');
console.log('curr----------------------------1', game.currPlayer);
// game.action('fold'); // utg
// console.log('curr----------------------------2', game.currPlayer);
game.action('raise:6'); // co
game.action('call'); // D
game.action('call'); // sb
game.action('call'); // sb
game.action('check'); // bb
game.action('raise:12'); // d
game.action('call'); // bb
game.action('call'); // bb
// game.action('call'); // bb
game.action('fold'); // sb
game.action('check'); // bb
game.action('check'); // bb
game.action('raise:30'); // bb
game.action('raise:90'); // bb
game.action('fold'); // sb
game.action('raise:180'); // bb
game.action('raise:360'); // bb
game.action('allin'); // bb
game.action('allin'); // bb
// game.action('fold'); // bb
// console.log(game.pot, 'pot1');
// game.action('check'); // bb
// game.action('fold'); // sb
// game.action('fold'); // bb
// game.action('check'); // bb
// game.action('raise:30'); // bb
// console.log(game.pot, 'pot');
// game.action('call'); // bb
// game.action('check'); // bb
// game.action('allin'); // bb
// game.action('allin'); // bb
// game.action('fold'); // bb
console.log(game.winner);
console.log(game.pot, 'pot2');
// // console.log('curr----------------------------3', game.currPlayer);
// game.action('check'); // BB 200
// game.action('check'); // utg
// game.action('raise:20'); // d
// game.action('call'); // sb
// game.action('fold'); // bb
// game.action('fold'); // utg
// game.action('allin'); // sb
// console.log('curr----------------------------4', game.currPlayer);
// game.action('raise:20'); // bb 1000
// console.log('curr----------------------------1', game.currPlayer);
// game.action('call'); // utg
// game.action('fold'); // sb
// game.action('call'); // bb
// game over
// game.action('raise:10');
console.log(game.commonCard);
console.log(game.pot);
console.log(game.slidePots, 'slidePots');
console.log(game.getPlayers());
console.log(game.winner);
// console.log(game.winner[0][0], game.commonCard);
});
// flop
// turn
// river
// chip in
// has Allin need separate pot
// many allin
/**
* game over
*/
it('game over', async () => {
// only one player
// last player, other player fold
// multiple player
// last player, has all in player
// all player all in
// one player all in
// many player all in
// winner
// one winner
// multiple winner
// bisecting pot
// allin player winner and small pot, multiple second winner bisecting pot
// allin player winner and small pot, one second winner
// all player allin, winner can't win all pot,
});
/**
* count
*/
it('count', async () => {
});
// has other pot
//
// it('player fold pre flop', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {
// if (game.status < 6) {
// game.startActionRound();
// game.sendCard();
// }
// },
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// // pre flop
// game.action('fold');
// // game over
// // game.action('raise:10');
// // console.log(game.commonCard);
// // console.log(game.pot);
// // console.log(game.getPlayers());
// // console.log(game.winner);
// // console.log(game.winner[0][0], game.commonCard);
// });
// // flop
// // turn
// // river
// // chip in
// // has Allin need separate pot
// // many allin
//
// /**
// * game over
// */
// it('game over', async () => {
// const game = new PokerGame({
// smallBlind: 1,
// users,
// actionRoundComplete: () => {
// if (game.status < 6) {
// game.startActionRound();
// game.sendCard();
// }
// },
// gameOverCallBack: () => {},
// autoActionCallBack: () => {},
// });
// game.play();
// game.action('raise:10');
// game.action('allin');
// game.action('fold');
//
// // console.log('game over----------- common', game.commonCard);
// // console.log(game.pot);
// // console.log(game.getPlayers());
// // console.log(game.winner);
// // only one player
// // last player, other player fold
//
// // multiple player
// // last player, has all in player
// // all player all in
// // one player all in
// // many player all in
//
// // winner
// // one winner
// // multiple winner
// // bisecting pot
// // allin player winner and small pot, multiple second winner bisecting pot
// // allin player winner and small pot, one second winner
// // all player allin, winner can't win all pot,
// });
// /**
// * count
// */
// it('count', async () => {
//
// });
// // has other pot
});
+28 -4
View File
@@ -5,41 +5,65 @@ const assert = require('assert');
describe('test/app/core/pokerStyle.test.ts', () => {
it('Royal Flush', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['i1','j1', 'k1', 'l1', 'm1', 'a2', 'a4'])
// console.log(pokerStyle)
assert.strictEqual(pokerStyle.getPokerWeight() , '1000000000')
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , 'ijklm000000000')
});
it('straight flush', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b1', 'c1', 'd1', 'e1', 'a2', 'a4'])
// console.log(pokerStyle)
assert.strictEqual(pokerStyle.getPokerWeight() , '0a00000000')
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '0edcba00000000')
});
it('four of kind', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'a3', 'b4', 'd1', 'a2', 'a4'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '00ad0000000')
});
//
it('full house', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'c3', 'b4', 'd1', 'a2', 'b3'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight(), '000ba000000');
});
it('two full house', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'a3', 'b4', 'd1', 'a2', 'b3'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '000ba000000')
});
it('flush', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['m1','b1', 'k2', 'e1', 'f1', 'i1', 'k1'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '0000mkife00000')
});
it('straight', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','c2', 'e3', 'b4', 'd1', 'g2', 'm3'])
assert.strictEqual(pokerStyle.getPokerWeight() , '00000a0000')
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '00000abcde0000')
});
it('tow pairs to tow full house', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'a3', 'b4', 'd1', 'd2', 'b3'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '000bd000000')
});
it('tow pairs', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','c2', 'd3', 'b4', 'f1', 'a2', 'c3'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '0000000caf00')
});
it('pairs', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['k1','c2', 'd3', 'b4', 'f1', 'a2', 'c3'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , '00000000ckfd0')
});
it('high card', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','i2', 'e3', 'b4', 'd1', 'g2', 'm3'])
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
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)
console.log('getPokerValueCard', pokerStyle.getPokerValueCard())
assert.strictEqual(pokerStyle.getPokerWeight() , pokerStyle2.getPokerWeight())
});
});
+23 -23
View File
@@ -1,23 +1,23 @@
import { Link } from '../../src/utils/Link';
import { Player } from '../../src/app/core/Player';
describe('test/utils/link.test.ts', () => {
it('link', async () => {
const person1 = new Player({
buyIn: 0,
counter: 1, position: 1, userId: '1', socketId: '', account: '', nickName: '' });
const person2 = new Player({
buyIn: 0,
counter: 2, position: 2, userId: '2', socketId: '', account: '', nickName: '' });
const person3 = new Player({
buyIn: 0,
counter: 2, position: 3, userId: '3', socketId: '', account: '', nickName: '' });
const person4 = new Player({
buyIn: 0,
counter: 2, position: 4, userId: '4', socketId: '', account: '', nickName: '' });
// const person5 = new Player({ counter: 2, position: 5, userId: '5' });
const link = new Link<Player>([ person1, person2, person3, person4 ], false);
console.log(link.removeNode(0));
});
});
// import { Link } from '../../src/utils/Link';
// import { Player } from '../../src/app/core/Player';
//
// describe('test/utils/link.test.ts', () => {
// it('link', async () => {
// const person1 = new Player({
// buyIn: 0,
// counter: 1, position: 1, userId: '1', socketId: '', account: '', nickName: '' });
// const person2 = new Player({
// buyIn: 0,
// counter: 2, position: 2, userId: '2', socketId: '', account: '', nickName: '' });
// const person3 = new Player({
// buyIn: 0,
// counter: 2, position: 3, userId: '3', socketId: '', account: '', nickName: '' });
// const person4 = new Player({
// buyIn: 0,
// counter: 2, position: 4, userId: '4', socketId: '', account: '', nickName: '' });
// // const person5 = new Player({ counter: 2, position: 5, userId: '5' });
// const link = new Link<Player>([ person1, person2, person3, person4 ], false);
// console.log(link.removeNode(0));
// });
//
// });