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

gamer

v0.0.1

Published

Turn-based game server

Downloads

7

Readme

Circle CI Coverage Status

Gamer.JS

GamerJS - tiny NodeJS game server based on Socket.IO.

Features

  • Game with 1 to N players or AI.
  • Authentication.
  • WebSockets or Long-Polling for transferring data.
  • Public and private game-rooms.
  • Turn-base behavior, when players do turns one-by-one, like Tic-Tak-Toe, Age of Empires, Civilization ,etc.
  • Realtime behavior, when each player can do independent turns. Like Dota2, LoL, etc.

Workflow

  1. Game server is initiated.
  2. Client connects to the server. If the client want to create new game - step 3, if find already created or join - step 4.
  3. Create new game:
  4. Public 1. Client send 'client:create-public-room' to the server. 2. Client receive 'room:created' with id in payload.
  5. Private 1. Client send 'client:create-private-room' to the server. 2. Client receive 'room:created' with id in payload.
  6. Find already created game or join:
  7. Public 1. Client send 'client:find-public-room' to the server. 2. Client receive 'room:found' with id in payload or 'room:not-found'.
  8. Private 1. Client send 'client:join-private-room' to the server. 2. Client receive 'room:joined' with id in payload or 'room:not-found'.
  9. When players number in game are equal to needed - all the client receive 'game:ready'.
  10. Now every client need send 'client:ready' or 'client:not-ready' to the server.
  11. If some clients are not ready - move to step 2.
  12. When all the clients are ready, server execute inititalAction action and after send 'game:initial-state' to all the clients with the result as payload.
  13. Send every second to the clients 'game:will-start-in' with countdown as payload. It use countdown parameter as base and decrease it every second.
  14. When countdown value is zero - the server sends 'game:started' to all the clients.
  15. After game is started, clients available to send 'client:turn' to the server. Payload of this message will be passed to 'turnAction' method.
  16. After 'turnAction' is done, 'syncAction' is fired. In 'syncAction' determine what the data will be send with 'game:update-state' message as payload.
  17. Sending to all the clients 'game:update-state' with result of 'syncAction' method.
  18. After it - 'gameOverAction' will be fired. If the game is over - method fires callback with data, which will be passed to 'game:over' message later.
  19. Client receive 'game:update-state' and update current game state.
  20. Steps 10-13 is repeating until 'gameOverAction' keep not firing callback.
  21. When the game is over clients receive 'game:over' message with information to show the game results, which was build in 'gameOverAction' before.
  22. After it, players still connected and game state on the server is identically to step 5. If rematch is take the place - client need to do step 6 and replay game again.

Installation

npm install gamer --save

Examples

API

here will be described API...

License

MIT