battleship's Issues
Class: Ship - I1
Class: Ship
- name : shows the name of the ship type
- length : shows the length of the ship
- health : finds health of ship
- sunk? : checks if health is == 0
- hit : brings health down by 1 when user inputs computer's cell which includes S (ship)
--TESTS--
- Create tests according to interaction pattern
**Functionality Checklist*
Main Menu:
- User is shown the main menu where they can play or quit
Setup:
- Computer can place ships randomly in valid locations
- User can enter valid sequences to place both ships
- Entering invalid ship placements prompts user to enter valid placements
Turn:
- User board is displayed showing hits, misses, sunken ships, and ships
- Computer board is displayed showing hits, misses, and sunken ships (REMOVE 'true' from computer_board.render)
- Computer chooses a random shot
- Computer does not fire on the same spot twice
- User can choose a valid coordinate to fire on
- Entering invalid coordinate prompts user to enter valid coordinate
- Both computer and player shots are reported as a hit, sink, or miss
- User is informed when they have already fired on a coordinate
- Board is updated after a turn
End Game:
- Game ends when all the computer’s ships are sunk
- Game reports who won
- Game returns user back to the Main Menu
Class Game -I3 Main Menu/Setup
Main Menu
- Welcome message:
- User "gets" method for user input per instructions
Setup
- Computer Ship Method: ships are randomly placed per placement validations
- How-to Method: Short explanation with visual rep of board and prompt for user to input cell numbers
- Player Ship Placement: ships are placed on the board INCL how-to method
- Show board to user and prompt user for next ship.
- if placement is invalid, prompt for new coordinates.
--TESTS--
Create game_test.rb file
- Welcome message displays
- How-to explanation displays
- Board displays to user
- Invalid coordinate prompt new coordinates
Iteration 4
PULL REQUEST AFTER EACH STEP
- Refactor cell obj display when taking shots ("A1", etc.)
- Create more tests for Board (render, name/letter, same)
- Create more test for Game (more robust)
- Create Turn class (turn area in Game)
- Create Runner (3 lines)
- User should be able to indicate the height and width of the board.
- Intelligent Computer > The computer should make an educated guess of what coordinate to fire on.
Class Turn - I3 Turn/ End Game
The Turn
- Displaying the Boards: When turn starts, the user is shown both boards. The user should see their ships but not the computer’s ship
- Player Shot: Player inputs cell, triggers fire_upon. If invalid, prompts for new cell.
- Computer Shot: randomly chosen by the computer, only fires on cells with "." or "S"
- Results: (Check IP for details)
- Coordinates that have already been fired upon (GOAL: prompt them again for a coordinate they haven’t fired on)
End Game
- When all user/computer ships are sunk, output is 'You won!' or " I won!'
- Returns to main menu
--TESTS--
Create test as needed
Class: Board - I2 (Placing Ships)
- place(ship_name, array_of_coordinates) : allows user to place ship at certain coordinates; Maybe, if applicable in this class if placement is invalid, prompts for new coordinates.
--TESTS--
- cells (after user places ship, test according to IP)
- ship (test that part of the ship is in the cell)
Battleship Runner
- Create runner (GOAL: 3 Lines)
Call class
Create game object
Game.start
Class: Board - I2 (Rendering the Board Test)
- Add functionality that can fire on Cells and damage Ships
--TESTS--
- Create Tests according to IP
- Update render method to add new tests that test it can render with Hits, Misses, & Sunken Ships
Class: Board - I2 (Cells)
- When we initialize a new board, we want 16 cells created and attached to corresponding board coordinates
- cells: returns a hash of coordinates attached to specific cells
--Tests--
Create a test according to interaction pattern
Class: Board -I2 (Validations)
- valid_coordinate?(coordinate): returns true/false if coordinate is on the board or not.
- valid_placement?(ship.name, an_array_of_coordinates): returns true/false if space is valid to place ship.
--Tests--
- valid_coordinate? (According to IP)
- valid_placement? (test for array same length as ship)
- valid_placement? (test the coordinates within the array are consecutive)
- valid_placement? (test that it's not diagonal)
- valid_placement? (iterate over previous test to confirm validate = true)
Class: Cell - I1
- coordinate : returns specific coordinate of cell x by y
- empty? : a '.' is at this coordinate, the cell is empty
- place_ship(shipname) : allows user to place ship on the map
- fired_upon? : return true/false if there is a hit on this cell - we want to check for X
- fire_upon : the user calls fire_upon to hit that specific cell, . => M, or S => X
- render : return a string representation of the cell to print on the board -- . , M , H, X /// Also want to include optional argument to reveal a ship in the cell
--- TEST ---
- set-up test according to interaction pattern
Class: Board - I2 (Overlapping Ships Tests)
- Add functionality in valid placement to return false when a ship is already in the cell.
--TESTS--
- Create tests according to IP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.