npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rosenkoenig-core

v1.1.0

Published

Core engine of the board game Rosenkönig

Downloads

2

Readme

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 [email protected]:kjirou/rosenkoenig-core.git
cd ./rosenkoenig-core
npm install