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` handles logic for 2048 game. Despite being written in Typescript, you can also use plain JS, if TS 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-2nadc5qdgETcDcitT98w9BnxpHrcrtcFsOYT8bktFf/VqZAyXDqYQX6ywbk1xCBxRNnsdlvySPCYAjGQEF5iwA==",
"shasum": "fbff8ae22499fdde05c2176469a0a24261f049c7",
"tarball": "https://registry.npmjs.org/2048-ts-engine/-/2048-ts-engine-1.2.6.tgz",
"fileCount": 17,
"unpackedSize": 21354,
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIDv8PK/A1oKEISdRrLK03nkhbPfArZfiW7Rq0D4Tr1ugAiEAstbJyzM2Rn/f/kDUUdgME1+BgLDVd6uqZ1PI+MqHHJY="
}
],
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiSaWoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrFpxAAlkrtBCFhL9JyLHuP1YHHbRpXzX7sWffk+qtY1VJyRodnhIey\r\nmPWF1DyxpsRlhg59RpIVkfERSodzJR6I4TDMcFv12mGZC6LKKWaJaYzuLngm\r\nWPONQUmzHvQDPznYAKcTiG8BFhmlbNCYzfNo3wehe9Z1KObUkSNgB5ziq1A4\r\nBuC9oevqqI9F7qrpLJtEaZojZTG737N6Asb1rgZK9smtuiXBArgoC1Xcw3la\r\nf5e3iT+VkDehhV/cnKxV3aA/VxWSszw1bQDBxLthuXhXhziKGu63Vuw2BNYt\r\nAsRVHFK36vyj5VgUbjN3P+6QSS0kPW9e2Forq4hUQs8Ftlm7qUxxOyXbhYD3\r\n9RDz96+TmtgjxKJCvA6r6NOVOUlwZPlu8+wPC/ZPejj6gcDdpX4CEwdmj/oN\r\nTfnu7ioe+pk6oUK37M4nqKlO5eL+18w//eTMpL83+Z9rwj10NIb2Y7gU3nYH\r\nvwWXHxCow7wfzrGLHVUdgD/PYsxCnuibEOOAROMu21YXOkGYmPQ57FQBNKaC\r\nLtCNjswYSHAVaiHas8C1s5b3tChGzcim1aRT4cTW90uVUxMAMTWBmCSmTH3L\r\nz60z83QDsKnaoTHXGP8ICTWELF5hMAYiYC+FmEPOKfzgmshiNzQhJ3hWTzWL\r\nPkODlQenmTN/71QP5G+SK51qQaXrDqey8xg=\r\n=dkEh\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:de87bb4c80aaab4cb4f25b02f266cae251e2f0f5da27188fe450711713117dc0