Skip to content

Commit

Permalink
Remove Card interface from poker-evaluator. Simplify Deck interface t…
Browse files Browse the repository at this point in the history
…o key: string (#42386)
  • Loading branch information
rorymcgit committed Feb 18, 2020
1 parent 670dc42 commit ef30524
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 60 deletions.
60 changes: 3 additions & 57 deletions types/poker-evaluator/index.d.ts
Expand Up @@ -6,11 +6,10 @@
/// <reference types="node" />

export const HANDTYPES: HandName[];
export const CARDS: Deck;
export const ranks: Buffer;

export function evalHand(cards: Card[]): EvaluatedHand;
export function evalCard(card: Card): number;
export function evalHand(cards: string[]): EvaluatedHand;
export function evalCard(card: string): number;

export type HandName =
'invalid hand' |
Expand All @@ -25,62 +24,9 @@ export type HandName =
'straight flush';

export interface Deck {
'2c': 1;
'2d': 2;
'2h': 3;
'2s': 4;
'3c': 5;
'3d': 6;
'3h': 7;
'3s': 8;
'4c': 9;
'4d': 10;
'4h': 11;
'4s': 12;
'5c': 13;
'5d': 14;
'5h': 15;
'5s': 16;
'6c': 17;
'6d': 18;
'6h': 19;
'6s': 20;
'7c': 21;
'7d': 22;
'7h': 23;
'7s': 24;
'8c': 25;
'8d': 26;
'8h': 27;
'8s': 28;
'9c': 29;
'9d': 30;
'9h': 31;
'9s': 32;
'tc': 33;
'td': 34;
'th': 35;
'ts': 36;
'jc': 37;
'jd': 38;
'jh': 39;
'js': 40;
'qc': 41;
'qd': 42;
'qh': 43;
'qs': 44;
'kc': 45;
'kd': 46;
'kh': 47;
'ks': 48;
'ac': 49;
'ad': 50;
'ah': 51;
'as': 52;
[key: string]: number;
}

export type Card = keyof Deck;

export interface EvaluatedHand {
handType: number; // Index of HANDTYPES array
handRank: number;
Expand Down
4 changes: 1 addition & 3 deletions types/poker-evaluator/poker-evaluator-tests.ts
@@ -1,7 +1,6 @@
import { HandName, Deck, Card, EvaluatedHand, CARDS, HANDTYPES, evalHand, ranks, evalCard } from 'poker-evaluator';
import { Deck, evalCard, evalHand, EvaluatedHand, HandName, HANDTYPES, ranks } from 'poker-evaluator';

HANDTYPES; // $ExpectType HandName[]
CARDS; // $ExpectType Deck
ranks; // $ExpectType Buffer

evalHand(['as', 'ks', 'qs', 'js', 'ts', '3c', '5h']); // $ExpectType EvaluatedHand
Expand All @@ -15,7 +14,6 @@ const result: EvaluatedHand = {
evalCard('as'); // $ExpectType number

const highCardName: HandName = 'high card';
const card: Card = '2c';
const deck: Deck = {
'2c': 1,
'2d': 2,
Expand Down

0 comments on commit ef30524

Please sign in to comment.