Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
blackjack-engine
Advanced tools
There are many possible configuration. We are implementing Standard and Custom options so that you can easily combine flags to create games according with your skill/needs.
decks
, default is 1
standOnSoft17
, turn On/Off the "Soft 17" rule, default true
double
, ability to double after deal, default any
none
not allowedany
any allowed9or10
9or10or11
9thru15
split
, On/Off the possibility to split after deal, default true
doubleAfterSplit
, On/Off the possibility to double after split (split and double must be "on"), default true
surrender
, on/off the ability to surrender after deal, default true
insurance
, on/off the ability of ensuring a hand, default true
If you are using npm, to get the last version:
yarn add blackjack-engine
npm install blackjack-engine
Once obtained the library just require Game
and actions
.
const blackjack = require('blackjack-engine')
const actions = blackjack.actions
const Game = blackjack.Game
At this point you can initialize a new game by calling the Game constructor
.
const game = new Game()
In this cases, no state is passed to the constructor:
dispatch
actions to alter the stateAt any moment we can require the current state of the game by calling the getState()
.
console.dir(game.getState())
The content of the state and its schema depends on the stage of the game. In this case we initialized the game without any precedent state, so we will receive something like this:
For the moment the only thing we should note is that the field stage
tells us "game is ready".
The only way to mutate the state of the game is to dispatch actions. Some actions are required by the "user", some other actions are dispatched by the engine to "complete" the game.
NOTE: In a real game, players and dealer are allowed to "do actions". The engine will "impersonate the dealer" at some point, depending on the last action and the state.
// stage is "ready"
console.log(game.getState().stage)
// call an action to mutate the state
game.dispatch(actions.deal())
// stage has changed
console.log(game.getState().stage)
Based on Marco Casula's project.
see the /src/actions.js
Engine exposes actions, once invoked, the state of the game is changed. The following list represent the actions that can be dispatched by from the public API.
And, those are actions that are internally called in determinate stages by the engine itself.
See the /src/game.ts
The stage represent a moment in the game. The stage is directly related with the action allowed in that particular moment.
Current available stages for players are:
The game logic is implemented into /src/engine.ts
.
There is a specific design limitation currently in the code.
NOTE: If you are interested in the random components, check out the shuffle()
function.
Run tests by calling yarn test
or npm test
Jest will care about the following tasks:
♠10 ♦1 ♥5 ♣6 ♠11 ♦10
at the and of the deckrestore
, deal
, split
, insurance
and finally stand
stage
is 'done' at the endIf you specify the finalWin
the test will compare the final winning.
FAQs
NodeJs, multi-player, blackjack engine
The npm package blackjack-engine receives a total of 2 weekly downloads. As such, blackjack-engine popularity was classified as not popular.
We found that blackjack-engine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.