rosenkoenig-core
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

rosenkoenig-core

run-tests

Core engine of the board game Rosenkönig

🚀 Installation

This package is ESModules only.

npm install rosenkoenig-core

♟️ 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);

🐱 API Doc

Look at the source code 😇

🛠️ Development

Preparation

Installation

git clone git@github.com:kjirou/rosenkoenig-core.git
cd ./rosenkoenig-core
npm install

Readme

Keywords

Package Sidebar

Install

npm i rosenkoenig-core

Weekly Downloads

0

Version

1.1.0

License

SEE LICENSE IN LICENSE

Unpacked Size

23.5 kB

Total Files

5

Last publish

Collaborators

  • kjirou