Git Product home page Git Product logo

group12_project1's People

Contributors

asladek avatar kiefk avatar michaelhilton avatar nelsonni avatar ryanrapp14 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

group12_project1's Issues

Place Ship Function

A function that will take a user's ship location and current game state and call the Don't Cross and On the Board functions for the game state and ship location. If both return true it adds the ship to the game state in the User's specified location and returns the new game state. If either is false it will return an error message to the user explaining that it's an invalid location.

Don't Cross function

Create a function that checks a new ship's placement against the placement of previously placed ships to make sure that they are in different spaces. This function would use the direction, starting point and length of the ship to create an array of points that the ship occupies. It will then check each point of the array against similar arrays for the other ships. If a point is the same between the new ship and a past ship it returns false. Otherwise, true.

Off the Board Function

Create a function that verifies that a ship placement is not out of bounds. The function should return a false Boolean if some of a ship's spaces are off the board. If a ship's location is completely on the board it should return true. It should check this by looking at the starting coordinate and direction of the placed ship, and count the length of the ship in that direction. If this makes the x or y coordinate go past 10 then it returns false. Otherwise, true.

If user tries to start the game/ firing the first shots

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 Booleans 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.

Only one of each ship type.

When someone attempts to place a ship this function will check a Boolean attached to that ship to see if it has already been placed or not.

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, the function returns 1
if true: throw error, "nameOfShip has already been placed on the board.", and the function returns 0,
so that the ship is not placed on the board.

This also accomplishes having a maximum of five ships on the board because there are only five types of ship.

Boolean for each type of ship

These need to be created for the other issues I am working on.

These Booleans represent whether or not a ship has been placed on the board.

If the ship has already been placed on the board the Boolean will return true.

If the ship has not been placed on the board the Boolean will return false.

game over

the program should identify when all of the player's, or computer's ships have sunk

Update Boolean

If a ship can be placed, meaning that this function has been reached, then update the Boolean value of that ship to true.

Miss

When the fire coordinates do not match any ship locations, the server should interpret this as a miss.

Hit

When the fire coordinates match a ship location, the server should interpret this as a hit.

hit counter

a variable should be implemented to track how many times a ship has been hit to identify when it sinks

ship is sunk

a function is needed to check when a ship has sunk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.