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-uQKkgE9BoQfS/UjOndeon4ei73fM4BzrhDPsXaUDl9531A0NkPWViqfuZNTZZR8NAAM0NAEdtUfSRLNRq0xJVA==",
"shasum": "1f67781c662d22b2e7fd7f341c1cf9ad45ce0817",
"tarball": "https://registry.npmjs.org/2048-ts-engine/-/2048-ts-engine-1.1.1.tgz",
"fileCount": 57,
"unpackedSize": 37707,
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgjS2TCRA9TVsSAnZWagAAE74QAIZENzdJ0EsZF16WsDQu\nm2DgViAL6w8r/+KQpiLnDW02B0c80M7jZ7DGG+Nu2YYTeR41s0CeH1mNCels\nGwsbZdWq33oE/Ux1Z2RV+LCfDh9PaKEeEC3Up1OcYInnGAnm7J7FJPVWyh44\nmQzXQXZQ81IoED7LVQkGaP7Hdqh+XukoTtLvO7bUqBoA75OpxsxuQyzmWnow\n35BzOd1U9i7StWbT9doaYzgUnADhfDf4KoxFNYyG83JmAjpsL5ZG2XhtIFSg\nwZ0Hpazo//CUYw5lZdOzzab4cwcdIt1qH6mRFM5IoHTmxDnszXd2ZKX5GAZq\nDd6opWwHNFI6pknXhPR+kE4VRo0d6pL4MRD2GPNAPtU3tzrcnsot21al2Gog\nxC5lnE6a2jxvbv9EvdDZDZ3oIR0CoAgK2yFD1sZk9Kf+fq1p1SHgmnyHgAOx\nGMgAjRJr/36304w0+7q70oVwfpbcm+O/bPgU5j7jvUvOKI7xJSh9e2JWeRtx\nDM5OwzEkwg9ySN4oemXz+cENYss1quy4OOUSre5RRkeGnNl7W+tVw4MV2oL4\nmx7BgBiORhRkpZQGkGehuqBuJPPwifgbm+8PFwNTieHhLkaZglzXZfEwYD4o\nlxIK6Bn6ThVM6IIlbZx8nBXFzQ/pHk0TpzWc9NLckWNPmTkQGP93BZCFVfP9\nE84X\r\n=q7ne\r\n-----END PGP SIGNATURE-----\r\n",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIHH3h6i9OqBKQ4loyowd3r/pFcGvbtEbHSvZuBUnTlSFAiEAom6QsTND9WcMC5HwPLLkrgkSiCj08YGgSKm7uNcdTig="
}
]
}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:0261f428f6e473ce55be847b88d5de9a8c9d8dc0eb77e2aba8ba58cd359560ef