@pompidup/kingdomino-engine 1.0.2 → 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 +102 -0
  2. package/package.json +6 -2
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # Kingdomino Engine
2
+
3
+ ## Overview
4
+
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
+
7
+ ## Features
8
+
9
+ - **Game State Management**: Efficiently manage game states, including player turns, game rules, and game progression.
10
+ - **Rule Enforcement**: Automatically enforce game rules, ensuring a fair and consistent gameplay experience.
11
+ - **Player Interaction**: Simplify player interactions, including drawing tiles, placing dominoes, and scoring.
12
+
13
+ ## Installation
14
+
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
+ ```
26
+
27
+ or
28
+
29
+ ```bash
30
+ pnpm add @pompidup/kingdomino-engine
31
+ ```
32
+
33
+ ## Usage
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
+
41
+ ### Basic Setup
42
+
43
+ To start using the Kingdomino Engine, you need to import it and initialize a new game instance.
44
+
45
+ ```typescript
46
+ import gameEngine from "@pompidup/kingdomino-engine";
47
+
48
+ const engine = gameEngine();
49
+ let gameState = engine.init();
50
+ ```
51
+
52
+ ### Start game and setting up players
53
+
54
+ You can add players to the game by passing an array of player.
55
+
56
+ ```typescript
57
+ const players = [{ name: "Player 1" }, { name: "Player 2" }];
58
+ gameState = engine.start(gameState, players);
59
+ ```
60
+
61
+ ### Choosing game mode (Classic, Queendomino...)
62
+
63
+ Incoming...
64
+
65
+ ### Setting Up Rules
66
+
67
+ Incoming...
68
+
69
+ ### Player Actions
70
+
71
+ Players can perform actions like pick domino, placing domino, and passing turns.
72
+
73
+ - Pick Domino:
74
+ You can pick a domino by passing the kingId and the number of the domino you want to pick.
75
+
76
+ ```typescript
77
+ gameState = engine.pickDomino(gameState, "kingId", 12);
78
+ ```
79
+
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).
82
+
83
+ ```typescript
84
+ gameState = engine.placeDomino(
85
+ gameState,
86
+ "kingId",
87
+ { x: 0, y: 0 },
88
+ "horizontal",
89
+ 0
90
+ );
91
+ ```
92
+
93
+ - Pass Turn:
94
+ If you can not place a domino you can pass your turn.
95
+
96
+ ```typescript
97
+ gameState = engine.passTurn(gameState, "kingId");
98
+ ```
99
+
100
+ ### Scoring
101
+
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.2",
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",
@@ -16,7 +16,11 @@
16
16
  "lint": "tsc",
17
17
  "test": "vitest",
18
18
  "coverage": "vitest --coverage --config ./vitest.config.ts",
19
- "build": "tsup"
19
+ "build": "tsup",
20
+ "bump:major": "npm version major",
21
+ "bump:minor": "npm version minor",
22
+ "bump:patch": "npm version patch",
23
+ "pub": "pnpm build && npm login && npm publish --access public"
20
24
  },
21
25
  "keywords": [
22
26
  "kingdomino",