diff --git a/packages/domain_layer/src/player/checkPlayerHasUnrevealedCardOfHands.test.ts b/packages/domain_layer/src/player/checkPlayerHasUnrevealedCardOfHands.test.ts new file mode 100644 index 0000000..a2d05f2 --- /dev/null +++ b/packages/domain_layer/src/player/checkPlayerHasUnrevealedCardOfHands.test.ts @@ -0,0 +1,51 @@ +import { Creature, Status } from 'card'; +import { createIdToPlayer, createPlayer } from 'player'; +import { pipe } from 'fp-ts/function'; +import O from 'fp-ts/Option'; + +import { checkPlayerHasUnrevealedCardOfHands } from './checkPlayerHasUnrevealedCardOfHands'; + +describe('checkPlayerHasUnrevealedCardOfHands', () => { + it(` + given a player + hands [ + { id: 1, status: 'UNREVEALED', creature: 'BAT' } + ] + when check player has unrevealed card + then + player has unrevealedCard + `, () => { + const hasUnrevealedCard = pipe( + { uid: '1', name: 'player1' }, + createPlayer, + createIdToPlayer, + O.map((player) => { + player.hands = [ + { id: 1, status: Status.Unrevealed, creature: Creature.Bat }, + ]; + return player; + }), + O.map(checkPlayerHasUnrevealedCardOfHands), + ); + + expect(hasUnrevealedCard).toStrictEqual(O.some(true)); + }); + + it(` + given a player + hands [ + ] + when check player has unrevealed card + then + player not has unrevealedCard + `, () => { + const hasUnrevealedCard = pipe( + { uid: '1', name: 'player1' }, + createPlayer, + createIdToPlayer, + O.map(checkPlayerHasUnrevealedCardOfHands), + ); + + expect(hasUnrevealedCard).toStrictEqual(O.some(false)); + }); +}); diff --git a/packages/domain_layer/src/player/checkPlayerHasUnrevealedCardOfHands.ts b/packages/domain_layer/src/player/checkPlayerHasUnrevealedCardOfHands.ts new file mode 100644 index 0000000..cfb9a2b --- /dev/null +++ b/packages/domain_layer/src/player/checkPlayerHasUnrevealedCardOfHands.ts @@ -0,0 +1,17 @@ +import { Player } from 'player'; +import { pipe } from 'fp-ts/function'; +import { prop } from 'remeda'; + +export interface CheckPlayerHasUnrevealedCardOfHands { + (player: Player): boolean; +} + +export const checkPlayerHasUnrevealedCardOfHands: CheckPlayerHasUnrevealedCardOfHands = + (player: Player) => + pipe( + // + player, + prop('hands'), + prop('length'), + (length) => length > 0, + ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0322425..f535a6d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -217,7 +217,7 @@ importers: devDependencies: '@vercel/style-guide': specifier: ^4.0.2 - version: 4.0.2(eslint@8.50.0)(prettier@3.0.3)(typescript@5.2.2) + version: 4.0.2(eslint@8.50.0)(prettier@3.0.3)(typescript@4.9.5) eslint-config-turbo: specifier: ^1.10.12 version: 1.10.14(eslint@8.50.0) @@ -244,7 +244,7 @@ importers: version: 0.5.1 '@turbo/gen': specifier: ^1.10.12 - version: 1.10.14(@types/node@20.6.5)(typescript@5.2.2) + version: 1.10.14(@types/node@20.6.5)(typescript@4.9.5) '@types/node': specifier: ^20.6.5 version: 20.6.5 @@ -263,6 +263,9 @@ importers: tsconfig: specifier: workspace:* version: link:../tsconfig + typescript: + specifier: ^4.5.4 + version: 4.9.5 packages/utils: {} @@ -1620,7 +1623,7 @@ packages: resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} dev: true - /@turbo/gen@1.10.14(@types/node@20.6.5)(typescript@5.2.2): + /@turbo/gen@1.10.14(@types/node@20.6.5)(typescript@4.9.5): resolution: {integrity: sha512-g7ecPx0GCCTpnbH53blBGNk6pP4LhcWiTtR0kEprGkXpiHqjYDpOydz4JFoz9IC+Hj1Z28/+M7T/GfwJAjf0FQ==} hasBin: true dependencies: @@ -1632,7 +1635,7 @@ packages: minimatch: 9.0.3 node-plop: 0.26.3 proxy-agent: 6.3.1 - ts-node: 10.9.1(@swc/core@1.3.75)(@types/node@20.6.5)(typescript@5.2.2) + ts-node: 10.9.1(@types/node@20.6.5)(typescript@4.9.5) update-check: 1.5.4 validate-npm-package-name: 5.0.0 transitivePeerDependencies: @@ -1871,7 +1874,7 @@ packages: resolution: {integrity: sha512-FYK4mlLxUUajo/mblv7EUDHku20qT6ThYNsGZsTHilcHRvIkF8WXqtZO+DVTYkpHWCaAT97LueV59H/5Ve3bGA==} dev: true - /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@5.2.2): + /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@4.9.5): resolution: {integrity: sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1883,18 +1886,18 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.8.1 - '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@4.9.5) '@typescript-eslint/scope-manager': 5.62.0 - '@typescript-eslint/type-utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/type-utils': 5.62.0(eslint@8.50.0)(typescript@4.9.5) + '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@4.9.5) debug: 4.3.4 eslint: 8.50.0 graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 semver: 7.5.4 - tsutils: 3.21.0(typescript@5.2.2) - typescript: 5.2.2 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -1927,7 +1930,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2): + /@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@4.9.5): resolution: {integrity: sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1939,10 +1942,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 - '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 5.62.0(typescript@4.9.5) debug: 4.3.4 eslint: 8.50.0 - typescript: 5.2.2 + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -1984,6 +1987,26 @@ packages: '@typescript-eslint/visitor-keys': 6.7.4 dev: true + /@typescript-eslint/type-utils@5.62.0(eslint@8.50.0)(typescript@4.9.5): + resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: '*' + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/typescript-estree': 5.62.0(typescript@4.9.5) + '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@4.9.5) + debug: 4.3.4 + eslint: 8.50.0 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/type-utils@5.62.0(eslint@8.50.0)(typescript@5.2.2): resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2014,6 +2037,27 @@ packages: engines: {node: ^16.0.0 || >=18.0.0} dev: true + /@typescript-eslint/typescript-estree@5.62.0(typescript@4.9.5): + resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/types': 5.62.0 + '@typescript-eslint/visitor-keys': 5.62.0 + debug: 4.3.4 + globby: 11.1.0 + is-glob: 4.0.3 + semver: 7.5.4 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/typescript-estree@5.62.0(typescript@5.2.2): resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2056,6 +2100,26 @@ packages: - supports-color dev: true + /@typescript-eslint/utils@5.62.0(eslint@8.50.0)(typescript@4.9.5): + resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.50.0) + '@types/json-schema': 7.0.13 + '@types/semver': 7.5.2 + '@typescript-eslint/scope-manager': 5.62.0 + '@typescript-eslint/types': 5.62.0 + '@typescript-eslint/typescript-estree': 5.62.0(typescript@4.9.5) + eslint: 8.50.0 + eslint-scope: 5.1.1 + semver: 7.5.4 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@typescript-eslint/utils@5.62.0(eslint@8.50.0)(typescript@5.2.2): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2092,7 +2156,7 @@ packages: eslint-visitor-keys: 3.4.3 dev: true - /@vercel/style-guide@4.0.2(eslint@8.50.0)(prettier@3.0.3)(typescript@5.2.2): + /@vercel/style-guide@4.0.2(eslint@8.50.0)(prettier@3.0.3)(typescript@4.9.5): resolution: {integrity: sha512-FroL+oOePzhw7n/I+f7zr4WNroGHT/+2TlW6WH9+CVSjMNsEyu7Qstj2mI5gWIBjT1Y2ZImKPppCzI2cIYmNZw==} engines: {node: '>=16'} peerDependencies: @@ -2113,25 +2177,25 @@ packages: '@babel/core': 7.22.20 '@babel/eslint-parser': 7.22.15(@babel/core@7.22.20)(eslint@8.50.0) '@rushstack/eslint-patch': 1.4.0 - '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@4.9.5) eslint: 8.50.0 eslint-config-prettier: 8.10.0(eslint@8.50.0) eslint-import-resolver-alias: 1.1.2(eslint-plugin-import@2.28.1) eslint-import-resolver-typescript: 3.6.0(@typescript-eslint/parser@5.62.0)(eslint-plugin-import@2.28.1)(eslint@8.50.0) eslint-plugin-eslint-comments: 3.2.0(eslint@8.50.0) eslint-plugin-import: 2.28.1(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-typescript@3.6.0)(eslint@8.50.0) - eslint-plugin-jest: 27.4.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.50.0)(typescript@5.2.2) + eslint-plugin-jest: 27.4.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.50.0)(typescript@4.9.5) eslint-plugin-jsx-a11y: 6.7.1(eslint@8.50.0) eslint-plugin-playwright: 0.11.2(eslint-plugin-jest@27.4.0)(eslint@8.50.0) eslint-plugin-react: 7.33.2(eslint@8.50.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.50.0) - eslint-plugin-testing-library: 5.11.1(eslint@8.50.0)(typescript@5.2.2) + eslint-plugin-testing-library: 5.11.1(eslint@8.50.0)(typescript@4.9.5) eslint-plugin-tsdoc: 0.2.17 eslint-plugin-unicorn: 43.0.2(eslint@8.50.0) prettier: 3.0.3 prettier-plugin-packagejson: 2.4.5(prettier@3.0.3) - typescript: 5.2.2 + typescript: 4.9.5 transitivePeerDependencies: - eslint-import-resolver-node - eslint-import-resolver-webpack @@ -3753,7 +3817,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@4.9.5) debug: 3.2.7 eslint: 8.50.0 eslint-import-resolver-node: 0.3.9 @@ -3783,7 +3847,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@4.9.5) array-includes: 3.1.7 array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2 @@ -3808,7 +3872,7 @@ packages: - supports-color dev: true - /eslint-plugin-jest@27.4.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.50.0)(typescript@5.2.2): + /eslint-plugin-jest@27.4.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.50.0)(typescript@4.9.5): resolution: {integrity: sha512-ukVeKmMPAUA5SWjHenvyyXnirKfHKMdOsTZdn5tZx5EW05HGVQwBohigjFZGGj3zuv1cV6hc82FvWv6LdIbkgg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -3821,8 +3885,8 @@ packages: jest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@4.9.5) + '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@4.9.5) eslint: 8.50.0 transitivePeerDependencies: - supports-color @@ -3864,7 +3928,7 @@ packages: optional: true dependencies: eslint: 8.50.0 - eslint-plugin-jest: 27.4.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.50.0)(typescript@5.2.2) + eslint-plugin-jest: 27.4.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.50.0)(typescript@4.9.5) dev: true /eslint-plugin-prettier@4.2.1(eslint-config-prettier@9.0.0)(eslint@8.50.0)(prettier@2.8.8): @@ -3918,13 +3982,13 @@ packages: string.prototype.matchall: 4.0.10 dev: true - /eslint-plugin-testing-library@5.11.1(eslint@8.50.0)(typescript@5.2.2): + /eslint-plugin-testing-library@5.11.1(eslint@8.50.0)(typescript@4.9.5): resolution: {integrity: sha512-5eX9e1Kc2PqVRed3taaLnAAqPZGEX75C+M/rXzUAI3wIg/ZxzUm1OVAwfe/O+vE+6YXOLetSe9g5GKD2ecXipw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0, npm: '>=6'} peerDependencies: eslint: ^7.5.0 || ^8.0.0 dependencies: - '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@4.9.5) eslint: 8.50.0 transitivePeerDependencies: - supports-color @@ -7575,6 +7639,37 @@ packages: yn: 3.1.1 dev: true + /ts-node@10.9.1(@types/node@20.6.5)(typescript@4.9.5): + resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 20.6.5 + acorn: 8.10.0 + acorn-walk: 8.2.0 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 4.9.5 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + dev: true + /ts-pattern@5.0.5: resolution: {integrity: sha512-tL0w8U/pgaacOmkb9fRlYzWEUDCfVjjv9dD4wHTgZ61MjhuMt46VNWTG747NqW6vRzoWIKABVhFSOJ82FvXrfA==} dev: false @@ -7626,6 +7721,16 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + /tsutils@3.21.0(typescript@4.9.5): + resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} + engines: {node: '>= 6'} + peerDependencies: + typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' + dependencies: + tslib: 1.14.1 + typescript: 4.9.5 + dev: true + /tsutils@3.21.0(typescript@5.2.2): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'}