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-dwXkTg+C6X7uEMwJdoc7xnT99CSHlkLecGzzlcvKN/M2NBzr4rPCUp/XGDXFNnNVhIdYmQeIhzNNagzlW6mfHQ==",
"shasum": "86bdf14b823bead49b22ee3398cc319f03df7b51",
"tarball": "https://registry.npmjs.org/2048-ts-engine/-/2048-ts-engine-1.3.1.tgz",
"fileCount": 18,
"unpackedSize": 21356,
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIQCkF+4OWqZ21ADm+Z257Fk0bGmrNFrgBoD9/JVMSe2RLwIgULGtKWzmzFXTjKKYvrJQyWUQGwtFjfklSh6ceU8hyNY="
}
],
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiSagmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrDGBAAjxpD0ukRf5Sy5ZyxjFcYNYkWuwT6Dy5UVdVvGfKvnuB+IO82\r\ndOp82MlHmbu9MXCe91lDBvpk90wDzyfUrHW6zHRWZmK+iHKyXJl5sdaKIkHT\r\nK87YBQjUaYuo3/034ynnxcd8ZoWfx1Z8BDUNgrjd98jzqSYmYSGPN13sJjLt\r\nzCKZp6ghWfMB29iAgILZvVNx9E4K3SwOK8Jmbm0Hvb2K7Vbv/GCEDE0qKBXA\r\n2AGybGZugri3i/RBTvTHlaDT+i4LgLo6fLQO8YQaxxcWbs8C3/iG7Py/RJUQ\r\ntNb9GZ3ImMQqXr/WH6J7m4XFMPVAMFjjWvyZxt85AYfghNVXjBBDlDoOol+r\r\ndWJuYtgjtEn7TCAVKxVMcSRNzXimnIYDGNjZcaqGoFkcgVM26Nc5C+6nUKD7\r\nEh3PX3a0avJrLx5MTAcw/pkdJ3ejokluwLTh2vUqx10vlHG9NuSxNddHGHLD\r\n/c/ncVrMako9hJ+2CCfIRonVJkFt0CBR4WrWCGWCtVEe/BKnQANIbZG7aKfY\r\nB4s6SET6G5ZQHL6EOB0GBjU7+veTkyhZZEqJ2hWn8MHWrBIUZpzr70lERA6j\r\nhn+owIvfuHGouF21QFYiaDSlKqXQtKYUYmolTm5xpboL5NG7nEAdO7S70WW3\r\ng3ZZdzxvcLCBMZDyhJDmr+MsKixKP1hkLpY=\r\n=WOiC\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:edd3379f1fe703b02a8c35aca92ee820daef06d139c6620f019d39e4808d544e