{"id":20852389,"url":"https://github.com/dimdengd/blackjack-js","last_synced_at":"2025-05-12T05:30:45.453Z","repository":{"id":57189841,"uuid":"263966184","full_name":"dimdenGD/blackjack-js","owner":"dimdenGD","description":"Library for Blackjack and Deck generation.","archived":false,"fork":false,"pushed_at":"2021-05-15T18:37:26.000Z","size":11,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-26T04:36:24.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimdenGD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-14T16:21:45.000Z","updated_at":"2024-09-11T02:44:37.000Z","dependencies_parsed_at":"2022-09-18T01:35:26.373Z","dependency_job_id":null,"html_url":"https://github.com/dimdenGD/blackjack-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimdenGD%2Fblackjack-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimdenGD%2Fblackjack-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimdenGD%2Fblackjack-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimdenGD%2Fblackjack-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimdenGD","download_url":"https://codeload.github.com/dimdenGD/blackjack-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253681870,"owners_count":21946821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T03:17:30.926Z","updated_at":"2025-05-12T05:30:44.872Z","avatar_url":"https://github.com/dimdenGD.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blackjack.js\n\nLibrary for Blackjack and Deck generation. Package on NPM: [blackjack-n-deck](https://www.npmjs.com/package/blackjack-n-deck).\n\n[Discord server](https://discord.gg/5jm5P3SJF3)\n\n## Blackjack\n\n***`new Blackjack(bet, amount)`***  \nClass for Blackjack game. Requires `bet` (default=100) argument for money and `amount` (default=1) argument for more than 52 cards.  \n*Example:*\n```js\nlet bj = new Blackjack(100, 1);\n// this function will be called every time something happens\nbj.event = event =\u003e {\n\tswitch(event) {\n\t\tcase \"init\": console.log(`Game started!`); break;\n\t\tcase \"hit\": console.log(`You hit.`); break;\n\t\tcase \"win\": console.log(`You won ${bj.bet}$!`); break;\n\t\tcase \"bust\": console.log(`You lost.`); break;\n\t\tcase \"push\": console.log(`Push.`); break;\n\t\tcase \"blackjack\": console.log(`BLACKJACK!!! +${bj.bet}$!`); break;\n\t}\n\tif(event === \"win\" || event === \"push\") console.log(`Your cards: ${bj.player.cards.map(i =\u003e i.image).join(\", \")} (${bj.player.score})\\nDealer cards: ${bj.dealer.cards.map(i =\u003e i.image).join(\", \")} (${bj.dealer.score})`);\n\telse console.log(`Your cards: ${bj.player.cards.map(i =\u003e i.image).join(\", \")} (${bj.player.score})\\nDealer cards: ${bj.dealer.cards[0].image}, ? (${bj.dealer.score})`);\n};\nbj.init();\n// playing\nbj.hit();\nbj.stand();\n```\n\n#### Blackjack.deck\n\nGame deck (Deck object).\n\n#### Blackjack.bet\n\nBet of game. Might change on blackjack or double down. Use it to get win currency amount.\n\n#### Blackjack.amount\n\nAmount of decks (from argument).\n\n#### Blackjack.status\n\n0 - playing, 1 - win, 2 - bust, 3 - push.\n\n#### Blackjack.player\n\nGame player, has `.score` and `.cards` properties.\n\n#### Blackjack.dealer\n\nGame dealer, has `.score` and `.cards` properties.\n\n### Blackjack.init()\n\nInit game. Should be called after setting up `event` function.\n\n### Blackjack.hit(noEvent)\n\nHit. `noEvent` to not get \"hit\" event.\n\n### Blackjack.stand()\n\nStand.\n\n### Blackjack.doubleDown()\n\nDouble down. Will affect `.bet`.\n\n## Deck\n\n***`new Deck(amount)`***  \nClass for generating deck of cards. Has `amount` (default=1) argument for generating more than 52 cards.  \n*Example:*\n```js\nlet deck = new Deck();\nconsole.log(deck.cards);\n```\n\n#### Deck.cards\n\nShuffled card array.  \nEvery card is an object like this:\n```js\n{\n\tfull: \"Spades Jack\"\n\timage: \"♠️J\"\n\tname: \"Jack\"\n\tshort: \"J\"\n\tsuit: \"♠️\"\n\tsuitname: \"Spades\"\n\tvalue: 10\n}\n```\n\n#### Deck.defaultCards\n\nArray used for generating full deck.\n\n#### Deck.suits\n\nArray with suit symbols.\n\n#### Deck.amount\n\nAmount of decks (from argument).\n\n### Deck.getRandomCard()\n\nGet first card from array.\n\n### Deck.getPair()\n\nGet array with 2 cards and their value.  \n`[card1, card2, totalvalue]`  \nIf both cards are aces then totalvalue becomes 2 instead of 22.\n\n# License\n\nMIT, created by [dimden](https://dimden.dev/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimdengd%2Fblackjack-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimdengd%2Fblackjack-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimdengd%2Fblackjack-js/lists"}