wip but I need to sleep
This commit is contained in:
@@ -26,10 +26,11 @@ export type Card =
|
||||
}
|
||||
| { kind: "joker"; color: "red" | "black" };
|
||||
|
||||
export type Pile = Card[];
|
||||
export type Stack = Card[];
|
||||
export type Hand = Card[];
|
||||
export type Board = Card[];
|
||||
export type vCard = Card | null | number;
|
||||
export type Pile<C extends vCard = Card> = C[];
|
||||
export type Stack<C extends vCard = Card> = C[];
|
||||
export type Hand<C extends vCard = Card> = C[];
|
||||
export type Board<C extends vCard = Card> = C[];
|
||||
|
||||
export const newDeck = (withJokers = false): Pile =>
|
||||
suits
|
||||
@@ -55,13 +56,3 @@ export const shuffle = (cards: Card[]) => {
|
||||
}
|
||||
return cards;
|
||||
};
|
||||
|
||||
export type GameState = {
|
||||
deck: Pile;
|
||||
hand: Hand;
|
||||
};
|
||||
export const newGame = () =>
|
||||
({
|
||||
deck: shuffle(newDeck()),
|
||||
hand: [],
|
||||
} as GameState);
|
||||
3
packages/shared/utils.ts
Normal file
3
packages/shared/utils.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import hash, { NotUndefined } from "object-hash";
|
||||
|
||||
export const heq = (a: NotUndefined) => (b: NotUndefined) => hash(a) == hash(b);
|
||||
Reference in New Issue
Block a user