1.1.0 • Published 12 months ago

rosenkoenig-core v1.1.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
12 months ago

rosenkoenig-core

run-tests

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 git@github.com:kjirou/rosenkoenig-core.git
cd ./rosenkoenig-core
npm install
1.1.0

12 months ago

1.0.0

12 months ago

0.0.1

12 months ago