Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

2048-ts-engine

Logical part of a famous game 2048 written in Typescript

2048enginegametypescript
Published12 Mar 2021
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

Getting Started 🚀

2048-ts-engine handles logic for 2048 game. Despite being written in Typescript, you can also use plain JS, if TS is not needed.

Installation

yarn add 2048-ts-engine

How to use

  • The lib returns two main functions
    • startGame - simply starting the game
    • move
      • evaluating move, calculating points, board coordination etc,
      • accepts these parameters
    direction: Direction
    game: Game
    

Both these functions return all game related data (board coordinates, score, status etc.) which look like this:

{
  "score": 16,
  "board": [
    [ 0, 0, 4, 0 ],
    [ 0, 0, 0, 0 ],
    [ 2, 0, 0, 0 ],
    [ 4, 8, 0, 8 ]
  ],
  "gameStatus": "STARTED"
}

You will need to store the current state somewhere, since the engine only processes the game, and after every move, the current state of game is returned.

import { startGame, move } from '2048-ts-engine';
import { Direction, Game, GameStatus } from '2048-ts-engine/src/types';

const newGame = startGame();
const gameProcessed = move(Direction.UP, newGame);

Useful scripts

  # test game logic
  yarn test

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-Wa4LSgzTHJ6PZYqGU3cYDDEg8ZMnX0ghGU8LbYoPRAAatuC8kZU3jcf62Z+VbF9tWMKOan5wr2gXTmX+ucaXVA==",
  "shasum": "af8d5eb20a09580b38b7b83ad2463162501953f3",
  "tarball": "https://registry.npmjs.org/2048-ts-engine/-/2048-ts-engine-1.0.0.tgz",
  "fileCount": 1,
  "unpackedSize": 244,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS5lICRA9TVsSAnZWagAAGUMP/3kX+/qQvyVLrJ/bwi4w\nNW2AIlVdu1XW2lmCfGl/OXhZIqZJ+PHBKKit4xhI9m4EGrsuUu/GVKsZnP/N\noa4oObiwkSGWL9oZeP2bfnAlB1wv615pU07yNRhGr3d1S0nzuyVpESklhRYZ\njULMWjbFmQuWQFUL3ThDmUReGSULngCy4HZh761v54vEUkLnRfk3LPLQg/Zy\n5yQmyLiB3miKsp9g9fzJBaamr6HrdfTuMLx9rD5xTfRFK93KWG+g4RmcuPeW\ntsVO/cE4Sk86C5ZLhX7L7EXMdauGWSwqwg/MpNQWjzQVRqEEFWMM4IV+wp97\nDgMhb7cjCvWuawLCns8U+6y3t/u9wJuIMoAqhDO5uonqJE/S12EsC/31OAjH\nzs8/E3v9zq+KoWkupg+cZ6G9b6KhCv16GUWF6YM56rMPqMjFujgDWZF6mRFt\njVVTvVseZL9fQQygNFciRetNsyQQXETJ53In6D2RMTgpp8Wdso47OmFh8Q1h\nomqs9/63Y+7yxuoMTieiu42ROIdzr0OkNzPWR700nu9Q5bWx/kG2enTmP+tJ\nO9pbxPOkKkNdwotiXK53j5n/D6z6eH2MDO/5MIKN6SDQe34yyM1z0gnjS6Xp\nU6drkvjHmZaudIXmlLWmIlEv3VaPXuHIf5HQwiy5OTF25YNpX4AYtOyoryPJ\nZqSR\r\n=p/q1\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIE7izKUozEjcXzt7EuqeUkN5czkL9q4oixm+BVzCpE/HAiEAwvpaIXTQTQ082MOEcQz6LmayInYC8sLglNoM8eKzCO4="
    }
  ]
}

Repository

PENDING
karelnguyen/2048-ts-engine

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:55 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:0f936cd88a1edc4e08defbbf12b9ad74e06495113f44e9c34629620ee175f8ee

Other collected versions

1.4.53 Apr1.4.43 Apr1.4.33 Apr1.4.23 Apr1.4.13 Apr1.4.03 AprView all collected versions →