Poker Hand Evaluator
A poker hand evaluator built with Angular2 and TypeScript 1.8. Its goal is to evaluate any hand and output its poker rank.
Life, like poker has an element of risk. It shouldn't be avoided. It should be faced.
Build
From the root directory of this app, run the command:
npm run-script build
Additional scripts can be found in the package.json file in the project root.
Development server
From the root directory of this app, run the command:
npm run-script server-debug
This will start the webpack-dev-server and automatically as changes are made to the source files.
Point your browser at http://localhost:3000
Running tests
Unit/integration testing
From the root directory of this app, run the command:
npm run-script test
The Karma test runner is used in conjunction with the Mocha test framework and Chai assertion library.
End-to-end testing
From the root directory of this app, run the commands:
npm run-script webdriver-update
npm run-script webdriver-setup
npm run-script test-e2e
These tests run using Protractor and are written with Mocha and Chai.
Coding guidelines
The naming and coding conventions use the TypeScript StyleGuide and Coding Conventions guide.
Important distinctions include:
- Interfaces use the suffix Interface.
Next steps and lessons learned
- Consider building from scratch using the angular-cli tool. This would at least make deployment to GitHub pages easier along with blueprints for creating components, services, classes, etc.
- Use json files to describe rank, suit, hand rankings. Here's an example describing the Royal Flush hand ranking:
{
"name": "Royal Flush",
"rank": 1,
"formula": {
"isSequence": true,
"isSameSuit": true,
"sameTwoRank": 0,
"sameThreeRank": 0,
"sameFourRank": 0,
"requiredCard": "Ace",
"tieBreaker": ""
}
}
or a command-driven approach:
{
"name": "Royal Flush",
"rank": 1,
"requirements": [{
"name": "isSequence",
"value": true
}, {
"name": "isSameSuit",
"value": true
}, {
"name": "requiredCard",
"value": "Ace"
}]
}
References
Poker
Starter project
Acknowledgements
- Big thanks to the Angular2 and TypeScript development teams.
- Hat tip to all the other libraries and developers.
- JetBrains WebStorm - love their tools!
- Thanks to Byron Knoll for his work on the poker card images.
License
MIT © Bryan Green