Web Application Project

profilemottcr
WAD-CA3-MineSweeper_Sinatra_01.pdf

WAD Ruby + TDD + Sinatra Assessment 3

Overview

In this assignment you are required to create a Web application based upon a modified version of the game Mine Sweeper. The game is to be designed for two players who play against each other. In the version you will be creating, players take the role of mine sweepers whose task it is to locate mines. Therefore, the objective is to find mines located at random locations as opposed to trying to avoid setting a mine off. Your game should use and call as many of the building blocks as possible.

IMPORTANT: To help you get started, you should use your submitted files from the previous Ruby + TDD assignment. DO NOT rename or use any other files. However, ensure you make copies of these files regularly as a backup.

wad_ms_gen_01.rb contains the code which passes the tests

wad_ms_run_01.rb contains the game engine code

wad_ms_spec_01.rb contains the test specification which your code should pass

In your game of Mine Sweeper, the computer should allow each player in turn to place a token in one of the locations. The aim of the game for each player to outwit their opponent and identify where as many of the mines are located. Only one mine can be placed at a single locate. The game will continue until all the locations have been selected or all the mines have been located. The player who locates the most mines wins.

Developing the game

The game should be developed in two stages: Stage 1 should result in a Ruby version of the game engine being created and able to be run in a command line terminal window (using STDIN and STDOUT channels); and Stage 2 should produce a Web-based version of the game engine using Ruby and Sinatra. In each case, the building blocks you created in the earlier assignment can be used to implement some of the functionality of the game.

Stage 1: involves downloading the wad_ms_01.zip file from MyAberdeen and saving it to a new folder on your university H: drive. You should extract the three files given above and copy them to a new folder called minesweeper in your workspace. You should then open the wad_ms_spec_01.rb file and replace the name “Nigel Beacham” with your name and number “123456789” with your student ID number. You should save the file to the same location. You should not change this file, move or rename it thereafter.

Within the wad_ms_gen_01.rb file you should copy and paste all the building blocks you deem necessary into the area denoted by comments.

Note: any additional methods created should also be placed in this area.

Once set up, you are required to develop the game using the command line (standard input/output) terminal command line window to enter input and display the current status of the game. DO NOT use Rails (or any other type of programming language), or create the game using a different language.

Before starting to write code, it is important that you design the game. Whilst aspects of the game have already been started for you in the form of building blocks, your design solution should represent the algorithm implementing the game’s rules, the look to feel of the game showing the interactive aspects (screen layout, interactive process, information flow), and the features implemented. The algorithm should take the form of a flow chart or structured English, and the interactive aspects should take the form of screen mock-ups and/or page flows representing how the game will work.

To run the game engine file, ensure the terminal command line prompt is set to the folder where the three files are located – minesweeper. You should then be able to run the game engine by entering the following command at the command line prompt.

ruby wad_ms_run_01.rb

WARNING: if you are using Cloud9 do not try running without options or by pressing the run button. Instead use the command: ruby wad_cf_run_01.rb –p $PORT –o $IP

When first running the game engine, the players will be asked to enter which version of the game they wish to play. Entering “1” starts the command line version and “2” starts the browser-based version. This part of the game has been already implemented for you within the game engine code. If the player does not enter “1” or “2” then the program exits.

This stage involves implementing the algorithm you designed of the game. The code must be implemented in the game engine file (wad_ms_run_01.rb) between the relevant comments.

Uncomment the method start will call these method in the wad_ms_gen_01.rb file at run time.

You are therefore required to implement the algorithm by calling the methods/code created in the wad_ms_gen_01.rb file where possible. Any additional ruby code you create (including methods, variables, etc.) should be placed in the wad_ms_run_01.rb file.

Playing the command line version of the game involves displaying a menu with the following options.

 When the “Start” option from the menu is selected, the game begins from the last state of the game. If starting the game for the first time all the settings should be reset. The Mine Sweeper frame should be displayed and player 1 prompted to choose a location.

 When the “New” option from the menu is selected, the game resets all the settings. The menu is then redisplayed ready to start the new game or exit.

 When the “Exit” option from the menu is selected, the game should call the finish method which displays the finish message and exits the program.

The player should be able to pause the game by just entering the ENTER key. Selecting the ‘Start’ option redisplays the Mine Sweeper frame and continues the game where it was interrupted.

Stage 2 involves implementing the game so it can be played within a Web browser. You are not expected to develop a new game engine. Instead, you are required to implement the browser-based version of the game by using aspects of the game engine and methods already developed in stage 1.

Good luck!

Summary

In stage 1, download and amend the required files ready to start.

When run, the command-line game should include the following features:

 A start introductory welcome message

 A message identifying who created the game

 A menu which provides the following three options o Start game start game from where last game finished o New game resets game o Exit game quit game

 An appropriate error messages if input invalid

 An appropriate message for example when the player wins or loses

 A finish message

The game is run by entering the following command: ruby [filename_run_01.rb] and selecting the command-line option (1). NB, you may need to include command line options if using Cloud9.

In stage 2, the Web-based game should cover the following features:

 A single Web page showing the status of the game

 A form on the Web page to enter options and turns

The Web-based game is run by entering the command ruby [filename_run_01.rb] and selecting the Web Browser option (2). Opening a browser and accessing the appropriate link should show the single Web page. NB, you may need to include command line options if using Cloud9.

Extra marks will also be available for creativity and innovative design. You might for example add the following optional features:

 A tally of the number of games played.

 A tally of the number of games won/lost.

 A link to a sign-up page which allows players to register and then log in to play the game with a partner.

 A file/database to keep track of the top 5 players with the best performance.

 A link to a login page which allows an administrator additional features to perform the following:

1. add/edit/delete additional players. 2. enable the game to be cleared of any players and reset to its initial default state

 A log text file which is appended each time a player plays the game.

 A stylish layout displaying the game application.

Marking criteria

CGS D: Demonstrates an acceptable level of knowledge and skills implementing stage 1 using acceptable coding conventions such as naming, commenting and indentation.

CGS C: Demonstrates a good level of knowledge and skills implementing stage 1 using good coding conventions such as naming, commenting and indentation.

CGS B: Demonstrates a very good level of knowledge and skills implementing stages 1 and 2 using very good coding conventions such as naming, commenting and indentation.

CGS A: Demonstrates an excellent level of knowledge and skills implementing stages 1 and 2 using excellent coding conventions such as naming, commenting and indentation.

Note: A CGS score of A1 will be awarded only if the game is deemed to be of a standard eligible for publication on the Web. For this the system should provide all the requested features, contain no spelling / grammatical errors, have an easy to use user interface and contain a manual explaining how to install, run and maintain the game.

What to submit

A single .zip file, containing all the files needed to run your game application including the specification file. The zip file must also include a manual [Student_Name_ID_manual.pdf] containing details of how to install, run and maintain the game. It should be a single file and include:

 System requirements and installation instructions (i.e. software required to run and maintain the game).

 A description of how to use the features implemented in your application.

 Screenshots illustrating the functionalities.

Note: Your design may contain more features than you implement. Design details should be placed in an appendix of the manual. In such cases extras marks can be awarded.

How to submit both parts (a zip file and printed report)

 Your zip file containing the application files, specification file and manual should be named yourfullname-wadca3.zip (NB: replace yourfullname with your full name) and submitted electronically to the myAberdeen assignment page by selecting the heading ‘WAD Assignment 3’.

 IMPORTANT: only zip files submitted to MyAberdeen will be marked. Zip files emailed to the tutor will not be marked.