Skip to content

icefire1/hazardhulen.io

 
 

Repository files navigation

HazardHulen.IO

BlackJack

by: Anders Bundgaard - [email protected], Casper Beese Nielsen - [email protected], Oliver Vestergaard - [email protected], Simon Hjortshøj Larsen - [email protected], Steen Schütt - [email protected] & Thomas Lemqvist - [email protected].

Get pdf Version

A pdf version of the documentation is located in the Documentation/tex folder.

The software

HazardHulen.io is a multiplayer blackjack table, where players can bet virtual currency to participate in a round of blackjack. The game uses the same ruleset as regular blackjack played in casinos, with a few details left out for simplicity. Players play against an artificial intelligence which acts as the dealer, and win double their bet if they beat the AI. If a player loses, his bet is lost. All players get a set amount of virtual money when they join the table, and have to place a bet of at least a minimum amount to play. If a player does not place a bet within a certain time period in between rounds, he is labeled as inactive, and cannot take part in the next round.

Technology

This section describes the technologies used to implement this system.

Client side

The client is written in HTML and jQuery, which uses socket.io, which is a web socket library, to connect to the server.

Server side

The server is written in JavaScript and uses socket.io to communicate with the clients.

The server utilizes the duplex connection, provided by socket.io to synchronize the state of the game across all clients

UML Sequence Diagram

UML Sequence Diagram

The sequence diagram, shown above, shows all calls made between the server and the client.

The server is responsible for synchronizing the table across all clients. It uses the table object (as seen in the object diagram below) for this, in the updateTable method.

UML Object Diagram

UML Class Diagram

The object diagram contains the two key objects used in this project, Table and Player.

* The types set in the fields in the objects, are not according to UML standards.

Walkthrough of Key code-snippets

The Connection between the Client and Server

var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);

// ... omitted for brevity

server.listen(13337);

The code snippet above is responsible for making the serve serve the clients the last line, sets the port, on which is listened on for requests to the server.

var port = 13337;

// ... omitted for brevity,

var socket = io.connect("http://localhost:" + port + "/");

The code snippet above is taken from the client, and makes it connect to the server, in this case it connects to the localhost, on the port 13337.

The Calls from the Client to the Server

io.on('connection', function (client) {

  // ... omitted for brevity

    client.emit('setId', id);
    client.emit('updateTableState', table);

    client.on('joinTable', function () {

      // ... omitted for brevity

    });

  // ... omitted for brevity

});

The code snippet above is taken from the server, and it is responsible for taking commands from the client.

How to run

To run the server, you have to have npm (it can be downloaded along with node here: https://nodejs.org/en/download/).

Run the following commands to start the server:

    $ npm install

Install bower by running this command, in the command line to install bower: (from: https://bower.io)

    $ npm install -g bower

To start the server, now you simply just has to run the following command.

    $ npm start

Now the server should be up and running.

To connect a client to the server, go to http://localhost:13337/

References

npm Packages

Helpful Links

Information about Blackjack

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 53.1%
  • JavaScript 46.9%