# Online Card Game with Node.js and Socket.io – Episode 7

Source: https://tpiros.dev/blog/online-card-game-with-node-js-and-socket-io-episode-7

For those of you who've been following along, this is the one you've been waiting for. After [six previous posts](http://tamaspiros.co.uk/category/online-card-game/) about an online card game, I'm finally releasing the code.

Take the codebase with a pinch of salt. It's not the prettiest JavaScript you'll ever read, and I know there are things in there that don't work as expected. But I got a lot of emails from you asking to see it, so here it is.

Let's walk through the basics. Once you've checked out the [repository from GitHub](https://github.com/tpiros/online-cardgame), follow these steps to get it running:

1. `npm install && bower install` will install the appropriate node packages such as `socket.io` and `express` as well as the required 'frontend' CSS and JS libraries (jQuery and Bootstrap)
2. Edit `server.js` and make sure that the port is suitable for your needs (by default the application launches on port 8080).
3. Edit `client.js` and make sure that you connect to the IP/port that you've set up in the previous step
4. Execute `node server.js`

That should be it. Navigate to the IP/port combination you specified, and you'll see a window asking for a Player's name. Enter it, then wait for a second player to join the "battle".

A few things worth flagging:

- The room ID is hardcoded to `1`. That needs to change, and I'll get to it when time allows.
- There's literally no handling for when a client disconnects (on purpose or by accident). Not ideal.
- Rooms and tables can't be created yet. That's coming.

The card images are pulled from Wikipedia. I'm still waiting on the right icons from [Font Awesome](https://github.com/FortAwesome/Font-Awesome/issues/606#issuecomment-26700743). Once those land, I'll be able to generate my own cards with CSS.

Constructive feedback is welcome.
