Shared TypeScript type definitions for the Preferans card game libraries.
This package provides essential type definitions for the Preferans card game, based on your actual implementations. It includes only the core types needed for cards, players, bids, tricks, games, paper scoring, ratings, and basic engine functionality.
npm install @prefko/types
# or
pnpm add @prefko/typesimport {
IPrefDeckCard,
PrefDeckSuit,
PrefDeckValue,
TPrefDesignation,
EPrefBid,
IPrefGame
} from '@prefko/types';
const card: IPrefDeckCard = {
suit: PrefDeckSuit.Spade,
value: PrefDeckValue.ACE,
designation: 'SPADE_ACE'
};
const player: IPrefPlayer = {
designation: 'p1',
name: 'Alice'
};- Cards:
IPrefDeckCard,PrefDeckSuit,PrefDeckValue - Players:
IPrefPlayer,TPrefDesignation - Bidding:
EPrefBid,EPrefContract,EPrefKontra - Tricks:
IPrefDeckTrick - Game:
IPrefGame,IPrefRound
- Paper:
IPrefPaper,IPrefPaperEntry - Scoring:
IPrefScore,IPrefGameScore
- Rating:
IPrefRating,IPrefRatingChange
- Engine:
IPrefGameEngine,EPrefEnginePhase - Commands:
IPrefEngineCommand - Events:
IPrefEngineEvent
- Types:
Result<T>,DeepPartial<T>,Validator<T>
- Immutability: All interfaces use
readonlyproperties - Type Safety: Strict TypeScript definitions with no
anytypes - Consistency: Uniform naming conventions (interfaces prefixed with
I) - Modularity: Organized into logical categories for easy importing
- Extensibility: Generic types and flexible interfaces for customization
IGame
├── IPlayer[] (players)
├── IBiddingState (bidding)
└── ITrickPlayState (trick play)
IGameEngine
├── IEngineState (current state)
├── IEngineConfig (configuration)
└── IGameContext[] (active games)
IScoringPaper
├── IPlayerColumn[] (player scores)
└── IPaperEntry[] (score entries)
This package uses strict TypeScript compilation and ESLint rules to ensure type safety and consistency.
pnpm buildpnpm lintpnpm formatWhen adding new types:
- Follow the existing naming conventions
- Use
readonlyfor all properties - Add comprehensive JSDoc comments
- Group related types in appropriate modules
- Export from the main
index.ts
Unlicense - see LICENSE file for details.