This is a project aimed to develop all of your skills so far. It is designed to be challenging for most learners on the Makers immersive course.
Your assignment is to design and test-drive a terminal-based Battleships game. A small amount of code is already written, to get you started and show you the approach to building and testing terminal user-interfaces using mocking.
How to get started:
; bundle install
; rspec # All tests should pass
; ruby run.rb # This will give you a few prompts and then an error
You might want to start by reading through the existing code, and then
test-driving out the Game
class to the point where running ruby run.rb
gets
to the end of its sequence without any errors.
After that, pick a few user stories from below, design your classes, and start test-driving.
Here are the user stories to implement:
As a player
So that I can prepare for the game
I would like to place a ship in a board location
As a player
So that I can play a more interesting game
I would like to have a range of ship sizes to choose from
As a player
So the game is more fun to play
I would like a nice command line interface that lets me enter ship positions and
shots using commands (rather than using IRB to interact with objects)
As a player
So that I can create a layout of ships to outwit my opponent
I would like to be able to choose the directions my ships face in
As a player
So that I can have a coherent game
I would like ships to be constrained to be on the board
As a player
So that I can have a coherent game
I would like ships to be constrained not to overlap
As a player
So that I can win the game
I would like to be able to fire at my opponent's board
As a player
So that I can refine my strategy
I would like to know when I have sunk an opponent's ship
As a player
So that I know when to finish playing
I would like to know when I have won or lost
As a player
So that I can consider my next shot
I would like to be able to see my hits and misses so far
As a player
So that I can play against a human opponent
I would like to play a two-player game
How was this resource?
๐ซ ๐ ๐ ๐ ๐
Click an emoji to tell us.