@pompidup/kingdomino-engine 1.0.3 → 1.0.4
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/README.md +61 -25
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -2,65 +2,101 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This is under development. The goal is to create a simple and lightweight TypeScript engine designed to facilitate the gameplay of Kingdomino. It provides the core logic for managing game states, rules, and player interactions, making it easy to integrate into any application that requires a Kingdomino game engine.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Game State Management**: Efficiently manage game states, including player turns, game rules, and game progression.
|
|
10
10
|
- **Rule Enforcement**: Automatically enforce game rules, ensuring a fair and consistent gameplay experience.
|
|
11
11
|
- **Player Interaction**: Simplify player interactions, including drawing tiles, placing dominoes, and scoring.
|
|
12
|
-
- **Customizable Rules**: Support for custom game rules, allowing for a wide range of gameplay variations.
|
|
13
12
|
|
|
14
13
|
## Installation
|
|
15
14
|
|
|
16
|
-
To install the Kingdomino Engine, you can use npm or
|
|
17
|
-
|
|
15
|
+
To install the Kingdomino Engine, you can use npm, yarn or pnpm. Run the following command in your terminal:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @pompidup/kingdomino-engine
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @pompidup/kingdomino-engine
|
|
25
|
+
```
|
|
18
26
|
|
|
19
27
|
or
|
|
20
28
|
|
|
21
|
-
bash
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @pompidup/kingdomino-engine
|
|
31
|
+
```
|
|
22
32
|
|
|
23
33
|
## Usage
|
|
24
34
|
|
|
35
|
+
The Kingdomino Engine is designed to be easy to use and integrate into any application. Below are some examples of how you can use the engine to create a new game, add players, and start playing.
|
|
36
|
+
|
|
37
|
+
Each method returns an updated game state object, which contains the current state of the game, including the board, players, and dominoes. In return you will receive too the nextKing (the next player to play) and the nextAction (the next action to be performed by the next player).
|
|
38
|
+
|
|
39
|
+
**It's your responsibility to save and pass the updated game state to the next method call.**
|
|
40
|
+
|
|
25
41
|
### Basic Setup
|
|
26
42
|
|
|
27
43
|
To start using the Kingdomino Engine, you need to import it and initialize a new game instance.
|
|
28
44
|
|
|
29
|
-
typescript
|
|
45
|
+
```typescript
|
|
46
|
+
import gameEngine from "@pompidup/kingdomino-engine";
|
|
30
47
|
|
|
31
|
-
const engine =
|
|
48
|
+
const engine = gameEngine();
|
|
49
|
+
let gameState = engine.init();
|
|
50
|
+
```
|
|
32
51
|
|
|
33
|
-
###
|
|
52
|
+
### Start game and setting up players
|
|
34
53
|
|
|
35
|
-
You can
|
|
54
|
+
You can add players to the game by passing an array of player.
|
|
36
55
|
|
|
37
|
-
typescript
|
|
56
|
+
```typescript
|
|
57
|
+
const players = [{ name: "Player 1" }, { name: "Player 2" }];
|
|
58
|
+
gameState = engine.start(gameState, players);
|
|
59
|
+
```
|
|
38
60
|
|
|
39
|
-
###
|
|
61
|
+
### Choosing game mode (Classic, Queendomino...)
|
|
40
62
|
|
|
41
|
-
|
|
63
|
+
Incoming...
|
|
42
64
|
|
|
43
|
-
|
|
65
|
+
### Setting Up Rules
|
|
44
66
|
|
|
45
|
-
|
|
67
|
+
Incoming...
|
|
46
68
|
|
|
47
|
-
|
|
69
|
+
### Player Actions
|
|
48
70
|
|
|
49
|
-
|
|
71
|
+
Players can perform actions like pick domino, placing domino, and passing turns.
|
|
50
72
|
|
|
51
|
-
|
|
73
|
+
- Pick Domino:
|
|
74
|
+
You can pick a domino by passing the kingId and the number of the domino you want to pick.
|
|
52
75
|
|
|
53
|
-
|
|
76
|
+
```typescript
|
|
77
|
+
gameState = engine.pickDomino(gameState, "kingId", 12);
|
|
78
|
+
```
|
|
54
79
|
|
|
55
|
-
|
|
80
|
+
- Place Domino:
|
|
81
|
+
You can place a domino by passing the kingId, the position where you want to place the domino, the orientation (horizontal or vertical), and the rotation (if you want to switch left and right tile you can pass 180 else 0).
|
|
56
82
|
|
|
57
|
-
|
|
83
|
+
```typescript
|
|
84
|
+
gameState = engine.placeDomino(
|
|
85
|
+
gameState,
|
|
86
|
+
"kingId",
|
|
87
|
+
{ x: 0, y: 0 },
|
|
88
|
+
"horizontal",
|
|
89
|
+
0
|
|
90
|
+
);
|
|
91
|
+
```
|
|
58
92
|
|
|
59
|
-
|
|
93
|
+
- Pass Turn:
|
|
94
|
+
If you can not place a domino you can pass your turn.
|
|
60
95
|
|
|
61
|
-
|
|
96
|
+
```typescript
|
|
97
|
+
gameState = engine.passTurn(gameState, "kingId");
|
|
98
|
+
```
|
|
62
99
|
|
|
63
|
-
|
|
100
|
+
### Scoring
|
|
64
101
|
|
|
65
|
-
|
|
66
|
-
- Special thanks to the Kingdomino community for their support and feedback.
|
|
102
|
+
When last turn is played, you will received the final score of each player and their position.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pompidup/kingdomino-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A simple engine for the game Kingdomino",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"test": "vitest",
|
|
18
18
|
"coverage": "vitest --coverage --config ./vitest.config.ts",
|
|
19
19
|
"build": "tsup",
|
|
20
|
+
"bump:major": "npm version major",
|
|
21
|
+
"bump:minor": "npm version minor",
|
|
22
|
+
"bump:patch": "npm version patch",
|
|
20
23
|
"pub": "pnpm build && npm login && npm publish --access public"
|
|
21
24
|
},
|
|
22
25
|
"keywords": [
|