nadavmatalon / battleships_web

Makers Academy | Week 6 | Challenge

Home Page:http://battleships-web.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#Battleships: Web Version

##Makers Academy | Week 6 | Challenge

Code Climate

Table of Contents

##Screenshots

Start Setup Play Winner

##General Description

This repo contians my answer to Week 6 Friday Challange as part of the course at Makers Academy.

The first working iteration of this app was written over a weekend, and in later iterations I've refactored both the back-end logic and front-end interface.

The app consists of the game of Battleships written in Ruby & JavaScript according to TDD (testing with Rspec & Capybara).

For more information about the game see: Wikipedia on Battleships

##Guidelines

  • The task is to write a web based battleship game in Sinatra using your knowledge and googling skills
  • When a potential player goes to the website the player will be prompted for a name to register for a new game (only if there are less than two players already registered)
  • Once registered you will be able to place your ships (you will need to show a grid and allow the players to place their ships on it; the types and numbers of ships allowed are the same for each player)
  • After the ships have been positioned, the game proceeds in a series of rounds. In each round, each player takes a turn to announce a target square in the opponent's grid which is to be shot at. The opponent announces whether or not the square is occupied by a ship, and if it is a "hit" they mark this on their own primary grid. The attacking player notes the hit or miss on their own "tracking" grid, in order to build up a picture of the opponent's fleet
  • When all of the squares of a ship have been hit, the ship is sunk, and the ship's owner announces this (e.g. "You sank my battleship!"). If all of a player's ships have been sunk, the game is over and their opponent wins
  • You will get extra credit if the game looks beautiful
  • If you want a challenge over the challenge (we haven’t covered any of this): Deploy your sinatra application on Heroku

##How to Install

To install the apo locally, clone the repo and run:

$> ch battleships_web
$> bundle instsll
$> shotgun

Then open the browser of your choice and go to:

http://localhost:9393/

##How to Play

The game of Battleships is typically played with 2 players.

The goal of each player is to be the first to sink all of the other player's ships.

The game begins with each player setting up their own board with a collection of 10 ships of different kinds (and without letting the other player peak!)

Each player set of ships consists of:

  • 1 x Battleship (covers 4 squares)
  • 2 x Cruisers (each covering 3 squares)
  • 3 x Destroyers (each covering 2 squares)
  • 4 x Submarines (each covering 1 square)

Each ship must be placed either in a vetical or horizontal position.

(additional on-screen instructions are given regarding placement of ships on the board)

After the boards are set, the players take turns attacking a single coordinate (square) on the other player's board in each turn, so as to try and hit the other player's ships.

(on-screen instructions are also given on how to attack the other player's ships)

If the attack is successful the game issues a 'ship hit' message.

When all the coordinates of a given ship are hit, it sinks and the game issues a 'ship sunk' message (it will also remove that ship from the other player's ship list so players can keep track of how many ships each player has at any given moment).

The player who manages to sink all of the other player's ships is the winner.

##See it Live on Heroku

A live version of the app can be found at:

Battleships on Heroku

As I'm using Heroku's free hosting service, the app may take a bit of time to upload
(Heroku's giros take time to wake up...), so please be patient.

##Browsers

For the best user experience, please use:

  • Mozilla Firefox (31.0 or later)

The app was also tested on:

  • Apple Safari (7.0.5)

  • Google Chrome (36.0)

However these browsers may show flickering on transitions.

##Testing

Tests were written with Rspec (3.0.4) & Capybara (2.4.1).

The tests cover both back-end logic and front-end functionality.

To run the tests in terminal, clone the repo and run:

$> ch battleships_web
$> rspec

##License

Released under the MIT license.

About

Makers Academy | Week 6 | Challenge

http://battleships-web.herokuapp.com/


Languages

Language:Ruby 85.9%Language:CSS 13.4%Language:JavaScript 0.7%