@pompidup/kingdomino-engine 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +110 -0
- package/dist/index.js +1402 -2
- package/dist/index.js.map +1 -7
- package/package.json +6 -8
- package/dist/bin/test.d.ts +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -7
- package/dist/src/_utils/container.d.ts +0 -9
- package/dist/src/application/engine/index.d.ts +0 -31
- package/dist/src/domain/engine/index.d.ts +0 -15
- package/dist/src/domain/entities/domino.d.ts +0 -22
- package/dist/src/domain/entities/game.d.ts +0 -38
- package/dist/src/domain/entities/kingdom.d.ts +0 -15
- package/dist/src/domain/port/dominoesRepository.d.ts +0 -4
- package/dist/src/domain/port/gamesRepository.d.ts +0 -6
- package/dist/src/domain/useCases/game/availableRules.d.ts +0 -4
- package/dist/src/domain/useCases/game/draw.d.ts +0 -6
- package/dist/src/domain/useCases/game/endGame.d.ts +0 -1
- package/dist/src/domain/useCases/game/endTurn.d.ts +0 -8
- package/dist/src/domain/useCases/game/firstTurn.d.ts +0 -8
- package/dist/src/domain/useCases/game/game.d.ts +0 -76
- package/dist/src/domain/useCases/game/init.d.ts +0 -4
- package/dist/src/domain/useCases/game/order.d.ts +0 -6
- package/dist/src/domain/useCases/game/pass.d.ts +0 -4
- package/dist/src/domain/useCases/game/pick.d.ts +0 -4
- package/dist/src/domain/useCases/game/place.d.ts +0 -4
- package/dist/src/domain/useCases/game/result.d.ts +0 -11
- package/dist/src/domain/useCases/game/scoring.d.ts +0 -8
- package/dist/src/domain/useCases/game/setRules.d.ts +0 -6
- package/dist/src/domain/useCases/game/setup.d.ts +0 -10
- package/dist/src/domain/useCases/game/startTurn.d.ts +0 -8
- package/dist/src/index.d.ts +0 -2
- package/dist/src/infrastructure/repositories/inMemoryDominoes.d.ts +0 -3
- package/dist/src/infrastructure/repositories/inMemoryGames.d.ts +0 -8
- package/dist/src/utils/container.d.ts +0 -9
- package/dist/src/utils/testHelpers.d.ts +0 -7
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
declare const ground: readonly ["castle", "wheat", "forest", "sea", "plain", "swamp", "mine"];
|
|
2
|
+
type Ground = (typeof ground)[number];
|
|
3
|
+
type Tile = {
|
|
4
|
+
type: Ground;
|
|
5
|
+
crowns: number;
|
|
6
|
+
};
|
|
7
|
+
type EmptyTile = {
|
|
8
|
+
type: "empty";
|
|
9
|
+
crowns: 0;
|
|
10
|
+
};
|
|
11
|
+
type Domino = {
|
|
12
|
+
left: Tile;
|
|
13
|
+
right: Tile;
|
|
14
|
+
number: number;
|
|
15
|
+
};
|
|
16
|
+
type RevealsDomino = {
|
|
17
|
+
domino: Domino;
|
|
18
|
+
picked: boolean;
|
|
19
|
+
kingId: string | null;
|
|
20
|
+
position: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Position = {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
type Orientation = "vertical" | "horizontal";
|
|
28
|
+
type Rotation = 0 | 180;
|
|
29
|
+
type Kingdom = (Tile | EmptyTile)[][];
|
|
30
|
+
|
|
31
|
+
type King = {
|
|
32
|
+
id: string;
|
|
33
|
+
playerId: string;
|
|
34
|
+
order: number;
|
|
35
|
+
turnEnded: boolean;
|
|
36
|
+
hasPick: boolean;
|
|
37
|
+
hasPlace: boolean;
|
|
38
|
+
dominoPicked?: Domino;
|
|
39
|
+
};
|
|
40
|
+
type Player = {
|
|
41
|
+
id?: string;
|
|
42
|
+
name: string;
|
|
43
|
+
kingdom: Kingdom;
|
|
44
|
+
};
|
|
45
|
+
declare const availableMode: readonly ["Classic"];
|
|
46
|
+
type AvailableMode = (typeof availableMode)[number];
|
|
47
|
+
type Rule = {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
mode: AvailableMode[];
|
|
51
|
+
playersLimit?: number;
|
|
52
|
+
};
|
|
53
|
+
type Game = {
|
|
54
|
+
id: string;
|
|
55
|
+
dominoes: Domino[];
|
|
56
|
+
currentDominoes: RevealsDomino[];
|
|
57
|
+
players: Player[];
|
|
58
|
+
kings: King[];
|
|
59
|
+
turn: number;
|
|
60
|
+
maxTurns: number;
|
|
61
|
+
maxDominoes: number;
|
|
62
|
+
dominoesPerTurn: number;
|
|
63
|
+
order: Record<number, string>;
|
|
64
|
+
rules?: Rule[];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type Score = {
|
|
68
|
+
score: number;
|
|
69
|
+
maxPropertiesSize: number;
|
|
70
|
+
totalCrowns: number;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type ScoreResult = {
|
|
74
|
+
playerId: string;
|
|
75
|
+
playerName: string;
|
|
76
|
+
details: Score;
|
|
77
|
+
};
|
|
78
|
+
type FinalResult = ScoreResult & {
|
|
79
|
+
position: number;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type Resp = {
|
|
83
|
+
nextKing: string;
|
|
84
|
+
nextAction: "pick" | "place" | "end";
|
|
85
|
+
game: Game;
|
|
86
|
+
};
|
|
87
|
+
type GameResult = {
|
|
88
|
+
result: FinalResult[];
|
|
89
|
+
game: Game;
|
|
90
|
+
};
|
|
91
|
+
/** Todo
|
|
92
|
+
* Add rules step
|
|
93
|
+
*
|
|
94
|
+
**/
|
|
95
|
+
declare const gameEngine: () => {
|
|
96
|
+
init: () => Game;
|
|
97
|
+
getMode: () => readonly ["Classic"];
|
|
98
|
+
setMode: (mode: string, game: Game) => Game;
|
|
99
|
+
getRules: (mode: string) => never[];
|
|
100
|
+
setRules: (rules: string[], game: Game) => Game;
|
|
101
|
+
start: (game: Game, players: {
|
|
102
|
+
name: string;
|
|
103
|
+
}[]) => Resp;
|
|
104
|
+
pass: (game: Game, kingId: string) => Resp;
|
|
105
|
+
placeDomino: (game: Game, kingId: string, position: Position, orientation: Orientation, rotation: Rotation) => Resp;
|
|
106
|
+
pickDomino: (game: Game, kingId: string, dominoPick: number) => Resp;
|
|
107
|
+
endGame: (game: Game) => GameResult;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { gameEngine as default };
|