@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.
Files changed (2) hide show
  1. package/README.md +61 -25
  2. package/package.json +4 -1
package/README.md CHANGED
@@ -2,65 +2,101 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- Kingdomino Engine is 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.
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 yarn. Run the following command in your terminal:
17
- bash npm install @pompidup/kingdomino-engine
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 yarn add @pompidup/kingdomino-engine
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 import { KingdominoEngine } from '@pompidup/kingdomino-engine';
45
+ ```typescript
46
+ import gameEngine from "@pompidup/kingdomino-engine";
30
47
 
31
- const engine = new KingdominoEngine();
48
+ const engine = gameEngine();
49
+ let gameState = engine.init();
50
+ ```
32
51
 
33
- ### Setting Up Rules
52
+ ### Start game and setting up players
34
53
 
35
- You can customize the game rules by passing an array of rule names to the `setRules` method.
54
+ You can add players to the game by passing an array of player.
36
55
 
37
- typescript engine.setRules(['rule1', 'rule2']);
56
+ ```typescript
57
+ const players = [{ name: "Player 1" }, { name: "Player 2" }];
58
+ gameState = engine.start(gameState, players);
59
+ ```
38
60
 
39
- ### Starting a Game
61
+ ### Choosing game mode (Classic, Queendomino...)
40
62
 
41
- To start a new game, use the `startGame` method.
63
+ Incoming...
42
64
 
43
- typescript engine.startGame();
65
+ ### Setting Up Rules
44
66
 
45
- ### Player Actions
67
+ Incoming...
46
68
 
47
- Players can perform actions like drawing tiles, placing dominoes, and passing turns.
69
+ ### Player Actions
48
70
 
49
- typescript // Example: Drawing a tile engine.drawTile('player1');
71
+ Players can perform actions like pick domino, placing domino, and passing turns.
50
72
 
51
- // Example: Placing a domino engine.placeDomino('player1', { x: 0, y: 0 }, 'domino1');
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
- // Example: Passing a turn engine.passTurn('player1');
76
+ ```typescript
77
+ gameState = engine.pickDomino(gameState, "kingId", 12);
78
+ ```
54
79
 
55
- ## Contributing
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
- Contributions are welcome! Please read the [contributing guide](CONTRIBUTING.md) for details on how to contribute to this project.
83
+ ```typescript
84
+ gameState = engine.placeDomino(
85
+ gameState,
86
+ "kingId",
87
+ { x: 0, y: 0 },
88
+ "horizontal",
89
+ 0
90
+ );
91
+ ```
58
92
 
59
- ## License
93
+ - Pass Turn:
94
+ If you can not place a domino you can pass your turn.
60
95
 
61
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
96
+ ```typescript
97
+ gameState = engine.passTurn(gameState, "kingId");
98
+ ```
62
99
 
63
- ## Acknowledgments
100
+ ### Scoring
64
101
 
65
- - Thanks to all the contributors who have helped shape this project.
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",
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": [