This project is a single-player poker game that runs in the browser and communicates with a Node.js game server.
When the game starts, both the player and the computer receive five cards. The player can replace selected cards up to two times before confirming the hand. After confirmation, the server reveals the computer's hand and determines the winner using poker hand rankings.
game_server.js- main server programdeck.js- deck management utilitiespackage.json- project dependenciespublic/index.html- browser entry pointpublic/style.css- page stylingpublic/scripts/hand.js- card rendering and card click handlingpublic/scripts/poker_game.js- main browser-side game logic
- Node.js
- npm
Install the required packages:
npm installStart the server:
node game_server.jsOpen the game in your browser:
http://localhost:8000
- Click Start Game to receive your first five cards.
- Click cards to flip them for replacement.
- Click Replace Cards to send the selected cards to the server.
- You can replace cards at most two times.
- When you are satisfied, click Confirm the Hand to finish the game.
- The server will show the computer's hand and display the winner.
The browser communicates with the server using these endpoints:
GET /start- starts a new game and returns the player's hand in JSON formatPOST /replacecards- replaces selected cards and returns the updated hand in JSON formatGET /confirm- ends the game and returns the result in JSON format
- The game uses poker hand comparison rules to decide the winner.
- The browser and server code are both part of the lab implementation.