rosenkoenig-core
v1.1.0
Published
Core engine of the board game Rosenkönig
Downloads
1
Readme
rosenkoenig-core
Core engine of the board game Rosenkönig
:rocket: Installation
This package is ESModules only.
npm install rosenkoenig-core
:chess_pawn: Usage
This is a set of APIs to implement Rosenkönig.
For example, use the following image.
Or see the web demo and its pure HTML/JS source code.
import {
computeNextPlayerIndex,
computeSelectablePlayerActions,
initialize,
playTurn,
} from "rosenkoenig-core";
const gamePlay = initialize();
// Returns the next player to act as an index of 0 or 1.
const nextPlayerIndex = computeNextPlayerIndex(gamePlay);
// Returns a list of actions that the player can select from.
// The list includes the following types of actions.
//
// 1. Move the crown by using power card
// 2. Draw a power card
// 3. Pass the turn
const selectablePlayerActions = computeSelectablePlayerActions({
board: gamePlay.game.board,
player: gamePlay.game.players[nextPlayerIndex],
playerIndex: nextPlayerIndex,
});
// Determines the action the player selects to take.
// Usually, the selection would be made through the UI.
const playerAction = selectablePlayerActions[0];
// Resolves the player action and generates new game states.
// Wins and losses are also computed at this point.
const newGamePlay = playTurn(gamePlay, playerAction);
:cat: API Doc
Look at the source code :innocent:
:hammer_and_wrench: Development
Preparation
Installation
git clone [email protected]:kjirou/rosenkoenig-core.git
cd ./rosenkoenig-core
npm install