User Stories - OSU-CS361-W17/group12_project1 GitHub Wiki
Welcome to the group12 User Stories.
Card: As a developer I want the program to identify when a ship has been sunk and when the game has been won.
Conversation: each ship object contains its length which is the same as the number of hits required to sink it, by adding a variable to store the number of times it has been hit, sunkenness can be checked by comparing a ship's length to its hits. to check for a winner another method can call the sinkcheck for each of the player's and computer's ships and reporting a winner if all of either side's ships have been sunk.
Confirmation: it should be sufficient to make one test for sinkcheck calling the subroutine for both a sunken and non-sunkenship. one test should check the endgame identifier for spotting wins, another can check that it correctly reacts when the game should continue.
Card:
As a developer I want my user to only be able to place one of each type of ship, so that they are following the rules of battleship.
Conversation:
Battleship has five different types of ship: Carrier, Battleship, Cruiser, Submarine, and Destroyer. The rules of battleship state that you can only have one of each ship.
Hold a boolean for each ship type to test if that ship has been placed on the board. if false: allow the ship to be placed on the board if true: throw error, "nameOfShip has already been placed on the board." This also accomplishes having a maximum of five ships on the board because there are only five types of ship.
Confirmation:
One test each for each type of ship that checks if a ship has not been placed on the board, should return 0 to show the ship has not been place.
One test each for each type of ship that checks if a ship has not been placed on the board, when a ship of that type has already been placed on the board. Should return 1, to show that a ship has already been placed.
Card: As a Developer I want to make sure that there are at least five ships on the board before the User can fire a shot/start the game, to follow the rules of Battleship.
Conversation:
Battleship has five different types of ship: Carrier, Battleship, Cruiser, Submarine, and Destroyer.
If a user tries to fire a shot to start the game: Check if there are five ships on the board. This check will count the Booleans of the five ship types. If all five return true then the function returns one, allowing the shot If at least one ship returns false then the function throws an error saying not all ships have been placed on the board and it returns 1, not allowing the shot to be taken. This function only needs to be used for the first shot of the game, because it determines if the game has been set up correctly and can start.
This function needs to be created after there are Booleans for each ship type.
Confirmation:
One test can check that if all five ship's Booleans are true then the function returns true.
One test for each ship can check that if its Boolean returns false that the function also returns false.
One test can check that if all five ship's Booleans are false then the function also returns false.
Card:
As a User, I want to be able to place my ships so that I can play a game of battleship.
Conversation:
The user needs to be able to place their five ships before they can play. Battleship is just shooting at water without ships. The ships need to be placed on the board so they are not off the board. This will require a function that checks the user's input to make sure that the ship doesn't extend off of the board and returns an error message if the ship is not on the board. The ships also cannot cross each other. This will require a function that checks the spaces occupied by each ship that is already placed against the spaces that the placed ship will occupy. If they occupy the same space, then an error message is returned. If both these functions are passed then the ship will be added to the game state in the location the user placed it.
Confirmation:
One test that checks if a ship is placed off the board that the function returns an error message.
One test that tries to place two ships on the same space in various ways to make sure the second function returns an error.
One test that checks if valid ship locations are added to the game state.
Card:
As a player, I want to be able to fire at enemy ships, so that I can play the game.
Conversation:
Battleship without firing functionality is like a gallery of static boats. Clicking on the โfireโ button should activate an event. When this event is activated, the client should send an HTTP request to the server with the current game state and the row and column selected in the dropdown menu. The server should determine whether a ship has been hit, by comparing the coordinates and ship locations, and return an updated game state.
Confirmation:
One test can check that if the coordinates match a ship location, the result is a hit.
One test can check that if the coordinates match no ship locations, the result is a miss.