Observed since 20 Oct, 18:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
2048-ts-engine
Logical part of a famous game 2048 written in Typescript
2048-ts-engine handles logic for 2048 game. Despite being written in Typescript, you can also use plain JS, if TS is not needed.
yarn add 2048-ts-engine
startGame - simply starting the gamemove
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);
# test game logic
yarn test
Download counts and popularity will appear here as the collector receives them.
Declarations describe requirements; they are not a resolved dependency graph.
Source distribution
{
"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="
}
]
}Shared repository data · GitHub
Observed since 20 Oct, 18:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:0f936cd88a1edc4e08defbbf12b9ad74e06495113f44e9c34629620ee175f8ee