A simple video poker sim that allows for two of the popular scoring conditions: pairs and straights. Original prompt: https://gist.github.com/rattlion/c596bed01deca39103aeeb10e08e8536
- The user may press the “Deal” button
- A new, 52 card deck, is created and shuffled
- The top five cards from the deck are laid out horizontally on-screen
- The user chooses whether to keep or discard each card by clicking an individual card to toggle between “keep” and “discard” states.
- Design Decision: only "discard" state will be displayed in the UI, it is assumed that you are keeping a card if it is not labeled discard. This can be changed by flipping a variable in the source code (see below).
- The user may press the “Go” button
- Each discarded card is replaced with a card from the top of the deck
- The value of the resulting hand is displayed using the following scoring rules:
- Straight (500 points): Five cards of consecutive rank. Example: 9:spades: 10:spades: J:diamonds: Q:hearts: K:diamonds:
- Pair (100 points): Two cards of the same rank. Example: 5:clubs: 5:diamonds:
- The “Deal” button replaces the “go” button. The user may click "Deal" to start the next game.
To get up and running with this game please perform the following steps:
- Clone/Download branch
git clone https://github.com/justincrich/card-game
- Install dependencies
yarn install
ornpm install
- Start server with
yarn start
ornpm run start
- Open browser at
http://localhost:3000
(should open by default) - Play Game
- Testing
- testing can be performed by running
yarn test
ornpm run test
- tests are contained in
src/index.test.js
- all tests cover the basic game logic in
src/helperFunctions.js
- testing can be performed by running
- .env file in repo
- This is a bad convention, but since all I'm doing is skipping the default Create_React_App preflight with
SKIP_PREFLIGHT_CHECK
I figure it's acceptable
- This is a bad convention, but since all I'm doing is skipping the default Create_React_App preflight with
- Displaying "Keep" Label
- In
src/game.js
on line 66 changeshowLabel
totrue
- ex:
<Card {...card} key={JSON.stringify(card)} showSelectedLabel={false} discard={discardList[index]} onDiscard={() => { if (!result) { handleDiscardSelect(index); } }} />
- In
Dependency | Version | Description |
---|---|---|
React | 16.8.6 | Basic SPA library |
StyledComponents | 4.3.1 | Allows for modularized CSS/SCSS styling using React components. |