Observed since 20 Oct, 18:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
2048-ts-engine
`2048-ts-engine` is a typescript based app that handles logic for 2048 game. You can also use plain JS, if Typescript is not needed.
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.
| Package / target | Requirement | Relationship |
|---|---|---|
@types/jestEnvironment{
"local_name": "@types/jest",
"alias": false,
"peer_metadata": null
} | ^26.0.23 | development |
jestEnvironment{
"local_name": "jest",
"alias": false,
"peer_metadata": null
} | ^26.6.3 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^4.2.4 | development |
Source distribution
{
"integrity": "sha512-Z5cn/jG4sQWniq/TBasMzCQr8cZhOTy9T8qxSA58q2okcElab+mRt4LWZwM6Tmgvd1n0Aqkz/QGNDj5ntFOTPg==",
"shasum": "e84356a0d4537b8dd831681f9345dbe098e3f16f",
"tarball": "https://registry.npmjs.org/2048-ts-engine/-/2048-ts-engine-1.4.2.tgz",
"fileCount": 46,
"unpackedSize": 42771,
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEQCIGxjlMhZwavPZLoGeiPv/HXIwXQ0/OQbA+ob38EWqhx0AiB3/9U1nUgLXNsZlaAhSxM0oaZUqXs2jEFFdeCedb3tBg=="
}
],
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiScvgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpdFA//ZGEPZzx6Z5ZF3wScGGW1+DcPkFb4V3/oiauOyYFMTbcR4PUU\r\nStRXoMA/YGhx6Obg+ahZtiKaturqf0tHpplV78uWuOxV1EEMwkEK6dK0Cm8c\r\nzgI0He8EK1yQA1S3Z+7Z/ooL2Jibvy309e4MdidH8MM1Lar90VHIwppN5Vi0\r\nXp0gsv51NKSbbOq05/yOrEpgMtEx10m+VUZD64jM0+j1ZmMa9D1gPUY2E6jM\r\nk2oaH2zA55M6IPYfRmZR9mU8RGipuBah4sLWhwdL5e3+qDv77vcRZHLfacMS\r\nVSQq4TKJ6H6p5n0D3M1enm928fN2MCtI9DvK40JQpotiJ/HEZtf17PVdCYEm\r\nmSpYLDXYyXXwRADaLaVL+AgsD6nXsKkZexUkhgxzaJRir2C5FoTuaNYlRneS\r\nutJmWEWmBBdoJiA7WqTn8VgbCkJ9KICC/ay4tRqkKbA/K6dHpLAyfifHqIAN\r\nt3QcM0xNUn1X87Wirh7RBP9J6XSYzdzklIVVvqvYh0uvjjR58KaYRiBimMnn\r\nUuxUB49Zy8AsQDs7Qf1RaH06XduJ/TAFbBi8hyHSB1EcRGACw4i70lUuthTa\r\nOBtdXqwxJT+eqS/tKjy944MFW22YiVVoMgUTFz5F+KlSMTwMg4l2aw9Qmvoj\r\nkCmpFeytyP0zGqCicXTgAAxtx/v/Xlpjn4o=\r\n=ZhxP\r\n-----END PGP SIGNATURE-----\r\n"
}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:a50c25cb706069a0fc035c6183f82655da665eb6b4d3cf54d18a7a98d7e0891e