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-DWtz93trIGr5aRDJO1Oep2F+7o2lpJJPbHH7AynEBFi377JDK3KPABkXUREVsQ5l1zcDaWlCPHy285WPd0s7pg==",
"shasum": "fdc8db3864f1e8e4a6f981bf9c834d347dc4771d",
"tarball": "https://registry.npmjs.org/2048-ts-engine/-/2048-ts-engine-1.3.0.tgz",
"fileCount": 18,
"unpackedSize": 21356,
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEQCICKa1qEx0lz0XMNbR+wm2svfC2T9Ip+4JNoW3qtBSN0CAiArTB9KTbtogD354mMqdn9rUPbE2avNbleIv8ie6e2iqQ=="
}
],
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiSae6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmon2w//T4doxJHDQqSctHec+zUegBal+KvvHxSsZAdCD8xSNj0Yb2Wd\r\nzvczGmi0Ck82G8MmrYgy7c08r4fgOgWrDUNolbrGOxRDl/MPVbXDxCtk+PdF\r\nrNRQkSc53Piw55Rn7hrRozAGwIHzf/WzDEKWpk5Ct2EhVm3cCh7gpzbG2RhR\r\ntnwf4578FlqaD4I/k2ZN6/M0HFzheMcnSotLpt8u3fO9BiIDZcRYH2f8XsC4\r\nmPs3oC3Dpjt9mUPHCUs5Pj6Fhb+xHRxT7/6f5/BZiMWrEwhtVPXEmyT3t/SF\r\npK8WbwAfB3lHCWMcDgXDAIjcQhWbmaV75JNrMoTuOIQ4XvHkTVyuGi1T51I6\r\ndlIIh6owOS2sBG8c4tuHWFqJc4tmd4vj39lKthZBTXubDGXWEKOLqFBb2wtg\r\nXpQfUyaCbMcZ2APqQcqe9E3s5CeUITYFpzv2ZufWIuJKTpVd84cyo7aIvyG/\r\n7zWCbFPONhUwPN1a9YpUx/YAuPLnTf0zs4uEecWnhYDHR2m+R4649777WVhN\r\nJYXqIRHwwe2vzmOh+UEyAjAQ+qavFWyTTkmK2qC8xXj3o7sOFDBcINKs10sY\r\nohfcUTBA5hwjyax/Ulqk9QCaD2e9YjFPPRpoxEftA6iYt45cHpAtMa8qq+HQ\r\n0xu0r0hBZseJg/NwmzsdJRuwe9wwe3gOZYY=\r\n=hW8S\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:68a67ebffa92e52d15243fdedf5c4cfe1bce18e590a3a2f6391789f8204672fd