{"_id":"2048-engine","_rev":"1-43ce09beb1255d71800770b519341c04","name":"2048-engine","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"2048-engine","version":"0.1.0","description":"Game engine for 2048 game","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"prettier":"prettier --write 'src/**/*.ts'","lint":"yarn lint:prettier && yarn lint:eslint","lint:prettier":"prettier --check 'src/**/*.ts'","lint:eslint":"eslint src/**","test":"jest","build":"tsc -p tsconfig.json"},"dependencies":{"random-seed":"^0.3.0"},"devDependencies":{"@types/jest":"^28.1.4","@types/random-seed":"^0.3.3","@typescript-eslint/eslint-plugin":"^5.30.6","@typescript-eslint/parser":"^5.30.6","eslint":"^8.19.0","jest":"^28.1.2","prettier":"^2.7.1","ts-jest":"^28.0.5","ts-node":"^10.8.2","typescript":"^4.7.4"},"prettier":{"singleQuote":true},"author":{"name":"Eik Hvattum Røgeberg"},"license":"ISC","gitHead":"1f232c9a52a54a65b3f84e4d723b8e22570eacaf","_id":"2048-engine@0.1.0","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-G2jkQgT6hsGoWmyaz8IBXB8TUjwef9kcjrf5lsKqaGBg7dCLceEisF7Q5ca5ExfA327JXmb+tPpQ4yiFkCEjdA==","shasum":"e61112c2a569b71cd96eecbad5006eb5cb4e17f9","tarball":"https://registry.npmjs.org/2048-engine/-/2048-engine-0.1.0.tgz","fileCount":78,"unpackedSize":75800,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQChOXKwr8rRoXfKEokML8MOOGzG5Id4ed8bx12Pp44jBgIhALbAFs+z8uQY7H4FS7Kcbx4ISKKhdT7dqe32wV3/NnKT"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizsXOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqexA/8DbVN8B4zcgatQMmoDVwOmwfetDrms33cijzPSrzdBs+juvh3\r\nXolg9AXdLiuOQqwDXuD24omDL08WzKYpFIGBtUQS9c8iU71MCSrXSWZ6X3AJ\r\n6cPe9mQN//WfJHcI+hta3cuw+fPiKwl7avmd0joIHDV1K8U/p/eFU5zb7+kC\r\n4tPl+aI0WN605Xj1dU1+v4l6rjJrJk56s7uZ86WDCoNP16iuhYA66kSq+w3y\r\nSOL7D1i82rtXgt7yJjRG7LfLODSpoWTyAIRePK3+iuJDjzQ6dmtHemznSo2M\r\nFEAHSM1gbcgwbnkVUaau+h3CrPU3IdOH74ouATma395hZ9K1sG1xzGQqUtrA\r\n0dEGrMEUBL01p2gH6DltSyBijHhCJs8u72UJguQIeHBC70HRO65wQ593FZWu\r\nWf7dHmZzmT97DVptuX3TS5mfNdbWoh1Ijr6CD667KDIBbbc+ZFNGmHw5jTOc\r\nGKUUOZJDZyzKhz9UNdV6raouTDxTd9FyeKZniI1yU6aTbnMVfmKxDBUicLaa\r\niiZZeoFeLM1RH7J5WwDA2goIf1AVydJq75SHAGuuZ0ncmLiKM7gfK3d3AHKz\r\nE65dKDFlwRIfh1a7YOIaGaYri+Fk4erlezkTC+1lv/mBlCoTeHOCJ24mBhjh\r\n0NL8dcPUgbezqm16RMVPz44H+7kPTdNQxRA=\r\n=PGMR\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"eikhr","email":"eik.rogeberg@gmail.com"},"directories":{},"maintainers":[{"name":"eikhr","email":"eik.rogeberg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2048-engine_0.1.0_1657718222180_0.9800528554432932"},"_hasShrinkwrap":false},"0.1.1":{"name":"2048-engine","version":"0.1.1","description":"Game engine for 2048 game","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"prettier":"prettier --write 'src/**/*.ts'","lint":"yarn lint:prettier && yarn lint:eslint","lint:prettier":"prettier --check 'src/**/*.ts'","lint:eslint":"eslint src/**","test":"jest","build":"tsc -p tsconfig.json"},"dependencies":{"random-seed":"^0.3.0"},"devDependencies":{"@types/jest":"^28.1.4","@types/random-seed":"^0.3.3","@typescript-eslint/eslint-plugin":"^5.30.6","@typescript-eslint/parser":"^5.30.6","eslint":"^8.19.0","jest":"^28.1.2","prettier":"^2.7.1","ts-jest":"^28.0.5","ts-node":"^10.8.2","typescript":"^4.7.4"},"prettier":{"singleQuote":true},"author":{"name":"Eik Hvattum Røgeberg"},"license":"ISC","gitHead":"73c75b35fa82884d3a1a9aed55606e74da4fecd9","_id":"2048-engine@0.1.1","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-MppxN5pi4AQ84EwkJN6GUt10QMB7LVtPLvh64XRx6nvJ8N9Jf18X/jvYF02gtbLcrmw/lOe7hL6/SDPDENfasw==","shasum":"b4a00f3739d13bd2c9c39d56033cf5e9ed73ad68","tarball":"https://registry.npmjs.org/2048-engine/-/2048-engine-0.1.1.tgz","fileCount":40,"unpackedSize":32032,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDvV/AcxfMXIUwdfoy2dKpv8gJRUEYfnkoe8xPFBubp/AiA9SzTsdPejYIpTCsEgGEjLhpzjsSC4SHmlurw4nrxQAg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizvdSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrzgw/+LCzyWd4x17lJWwy6tB2+yxOBsj/uKC/bXaeicV7xkCASZw8G\r\n/0T2+KshHD9ZeSSH8632Q8UvnMAbo8aosMGl3aVbM0SRXkwadA9F7Wkqlxpk\r\n6SXm4fAubaFm4SjUvgoqpFKXqjlW9tEF6nJ7MpK+rVpRqPwMYkCqBaVWUdNY\r\npBAGsciJP8V3f+Ig+2OWLsmpRl7cIkMhG9d65HXAhqzkWkW4ZQopka5SS+Lz\r\nnumRf8PJ4cgEFTHvOhiKXVx5dNJ4wloY37+iAdwfu3PjMLyBiC8JjGaK9MtV\r\neCOqe2903M0rLu6dSELvFKlhmRW4UaATDxez/PXfSTVM36gi9KBwvKrcSkUc\r\nHHkuadItztqCnEcmWuZv58MYgg6MYjFCd0yTvHdT1gdaI2/HVGygiXuwk2y7\r\nPy/V0GBuYktlO3sEaNEd9/dlTTBwLZK5tEeGVNgdwS+5V5CpTuc91XkMO6Q+\r\nlU+soRZM2iBSuO6xgn+IaSSs7J5Thfair3Rxe97fets8t49AYiasCCmUxfHp\r\n99Ay41OeYZcxUAWjWknj2BVzhag2RNYlrBzWJc6erY7vuuMDl17OPxUcBPvi\r\nq1dQ9AcB0H7OGqufgtqnY7eUrSTxu+zB8OKNNSOiiXdVc9Zt9gT8uMYL5YgK\r\nPU+fgFX8kVR7O32SiTjU57zoC+4peMxCuxc=\r\n=sp5O\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"eikhr","email":"eik.rogeberg@gmail.com"},"directories":{},"maintainers":[{"name":"eikhr","email":"eik.rogeberg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2048-engine_0.1.1_1657730897336_0.2785638457267736"},"_hasShrinkwrap":false}},"time":{"created":"2022-07-13T13:17:02.180Z","0.1.0":"2022-07-13T13:17:02.519Z","modified":"2022-07-13T16:48:18.082Z","0.1.1":"2022-07-13T16:48:18.009Z"},"maintainers":[{"name":"eikhr","email":"eik.rogeberg@gmail.com"}],"description":"Game engine for 2048 game","author":{"name":"Eik Hvattum Røgeberg"},"license":"ISC","readme":"# 2048 engine\n![Tests](https://github.com/eikhr/2048-engine/actions/workflows/main.yml/badge.svg)\n\nHandles logic for 2048 game. \n\nOriginally based on [`2048-ts-engine`](https://github.com/karelnguyen/2048-ts-engine) by Karel Nguyen, but has now been completely rewritten to support additional features.\n\n## Example\n\n```typescript\nimport { createGame, Direction } from '2048-engine';\n\nconst game = createGame();\ngame.move(Direction.UP);\ngame.move(Direction.RIGHT);\n\nconsole.log(game);\n```\nmight print:\n```js\n{\n    currentState: {\n        board: [\n            [ null, null, { value: 2, id: 0 }, { value: 4, id: 1 } ],\n            [ null, null, null, { value: 4, id: 2 } ],\n            [ null, null, { value: 4, id: 3 }, null ],\n            [ null, null, null, null ]\n        ],\n        score: 0,\n        rngNumber: 455431,\n        totalTileCount: 4,\n        status: { hasPossibleMoves: true, isWon: false }\n    },\n    boardMeta: { rows: 4, cols: 4 },\n    randomSeed: 455423,\n    moveLog: [ { type: 0, direction: 0 }, { type: 0, direction: 3 } ],\n    move: [Function: move]\n}\n```\n\n## API\n\n### `createGame`\nThe package exposes one method `createGame` that creates a new game.\n\n`createGame(gameData?) => Game`\n\nCan be supplied with `GameData` to initialize the game with.\n\n### `Game`\nThe created game object contains the following properties:\n\n- `currentState`: The current state of the game. (see `GameState`)\n- `move`: Function to make a move in the game. Takes a `Direction` as an argument and returns an updated `GameState` in addition to updating `game.currentState`\n- `boardMeta`: Metadata about the board. Contains `rows` and `cols` properties, which are the number of rows and columns in the board.\n- `randomSeed`: The random seed used to create the game. A new game created with the same random seed will be exactly the same given the same moves.\n- `moveLog`: List of all moves made in the game. Each move is a `Move` object.\n\n### `GameData`\nGameData is a subset of `Game` containing all properties except `currentState` and `move`. A new game created with the same `GameData` as an existing game will be exactly the same.\n\n### `GameState`\nThe gameState contained within `Game` contains the following properties:\n\n- `board`: The board state. A 2D array of `Tile`-objects.\n- `score`: The current score of the game.\n- `status`: object containing booleans `isWon` and `hasPossibleMoves` describing current game status.\n\n### `Tile`\nEach tile object contains an id, and its current value. The tile might also contain a `mergedId` specifying the id of the tile it was most recently merged with.\n\n- `id`: id to identify the tile, unique per game.\n- `value`: The value of the tile.\n- `mergedId`: The id of the tile it was most recently merged with. (useful for animations)\n\n","readmeFilename":"README.md"}