add client

This commit is contained in:
wzdwc
2020-04-14 22:20:02 +08:00
parent 32dd3302f8
commit d98223a6c6
80 changed files with 8461 additions and 20 deletions
+119
View File
@@ -0,0 +1,119 @@
import { PokerGame, EGameStatus } from '../../../src/app/core/PokerGame';
// @ts-ignore
import { expect } from 'chai';
import { IPlayer } from '../../../src/app/core/Player';
describe('test/app/core/pokerGame.test.ts', () => {
const users: IPlayer[] = [
{
userId: '1',
counter: 200,
},
{
userId: '2',
counter: 200,
},
{
userId: '3',
counter: 50,
},
{
userId: '4',
counter: 400,
},
{
userId: '5',
counter: 1200,
},
];
/**
* game ready
*/
it('game init', async () => {
const game = new PokerGame({
smallBlind: 1,
users,
});
game.play();
expect(game.status).to.equal(EGameStatus.GAME_ACTION);
expect(game.currPlayer.node.actionSize).to.equal(0);
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,
});
game.play();
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].handCard, 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
});
+45
View File
@@ -0,0 +1,45 @@
/* tslint:disable */
import {PokerStyle} from '../../../src/app/core/PokerStyle';
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')
});
it('straight flush', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b1', 'c1', 'd1', 'e1', 'a2', 'a4'])
// console.log(pokerStyle)
assert.strictEqual(pokerStyle.getPokerWeight() , '0a00000000')
});
it('four of kind', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'a3', 'b4', 'd1', 'a2', 'a4'])
assert.strictEqual(pokerStyle.getPokerWeight() , '00ad0000000')
});
//
it('full house', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'c3', 'b4', 'd1', 'a2', 'b3'])
assert.strictEqual(pokerStyle.getPokerWeight(), '000ba000000');
});
it('two full house', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'a3', 'b4', 'd1', 'a2', 'b3'])
assert.strictEqual(pokerStyle.getPokerWeight() , '000ba000000')
});
it('straight', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','c2', 'e3', 'b4', 'd1', 'g2', 'm3'])
assert.strictEqual(pokerStyle.getPokerWeight() , '00000a0000')
});
it('tow pairs to tow full house', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','b2', 'a3', 'b4', 'd1', 'd2', 'b3'])
assert.strictEqual(pokerStyle.getPokerWeight() , '000bd000000')
});
it('tow pairs', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','c2', 'd3', 'b4', 'f1', 'a2', 'c3'])
assert.strictEqual(pokerStyle.getPokerWeight() , '0000000caf00')
});
it('high card', async () => {
let pokerStyle: PokerStyle = new PokerStyle(['a1','i2', 'e3', 'b4', 'd1', 'g2', 'm3'])
assert.strictEqual(pokerStyle.getPokerWeight() , '000000000miged')
});
});
+16
View File
@@ -0,0 +1,16 @@
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({ counter: 1, position: 1, userId: '1' });
const person2 = new Player({ counter: 2, position: 2, userId: '2' });
const person3 = new Player({ counter: 2, position: 3, userId: '3' });
const person4 = new Player({ counter: 2, position: 4, userId: '4' });
// const person5 = new Player({ counter: 2, position: 5, userId: '5' });
const link = new Link<Player>([ person1, person2, person3, person4 ], false);
// console.log(link.getNode(0), 'link--------')
console.log(link);
});
});