This exam can be developed individually or in pairs.
The game of Pig is a very simple jeopardy dice game in which two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player’s turn, the player is faced with two decisions:
Using Ruby and the Sinatra DSL, write a web application that allows playing the Game of Pig between multiple simultaneous pairs of users connected to the same network.
When a user connects to the web server for the first time, she must be allowed to choose between creating a new game or joining an existing one. Once two users are linked to the same game, it can start and proceed according to the rules described in the introduction section above.
Given that some of the web pages will need to be refreshed automatically every few seconds (given that the state of the game will be updated during the turn of the other player), you can use the Refresh
HTTP header in your responses. In Sinatra, this is accomplished like this:
get '/whatever' do # Return an array with: status, headers hash, and response body. [200, {"Refresh" => "5"}, erb(:whatever)] end
This code refreshes the current requested resource after 5 seconds. Alternatively, you can use client-side JavaScript code to produce a similar effect.
Using the Online Assignment Delivery System (SETA), deliver a tarball file called exam3.tgz
containing the directory with your full application. Additionally, the application will be personally assessed on Friday, November 15 during the class session.