@hanabi-live/game
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

Hanab Live Game Logic

This package contains the rules for the game of Hanab. These are exported as functions like isCardTouchedByClue, isCardOnChop, and so on.

You can see the full list of things that this library provides in the auto-generated documentation.

The main export of this library is the gameReducer function, which can compute the next game state from an existing game state and a game action.


Installation

If you want to use the game logic in a bot or some other Hanab-related program, then you can install it from npm:

npm install @hanabi-live/game --save

Usage

Here is an example of a TypeScript program using the gameReducer function to compute a game state:

import {
  draw,
  gameReducer,
  getDefaultMetadata,
  getInitialGameState,
} from "@hanabi-live/game";

const numPlayers = 2;
const metadata = getDefaultMetadata(numPlayers);
const initialGameState = getInitialGameState(metadata);

console.log(`First player has ${initialGameState.hands[0].length} cards.`); // Should print 0.

const action = draw(0, 0, 0, 1);
const nextGameState = gameReducer(
  initialGameState,
  action,
  true,
  false,
  false,
  false,
  metadata,
);

console.log(`First player now has ${initialGameState.hands[0].length} cards.`); // Should print 1.

Readme

Keywords

none

Package Sidebar

Install

npm i @hanabi-live/game

Weekly Downloads

0

Version

0.0.8

License

GPL-3.0

Unpacked Size

1.83 MB

Total Files

405

Last publish

Collaborators

  • zamiell