GithubHelp home page GithubHelp logo

shtwzrd / battlechat Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 2.1 MB

A simple web-based Battleship client/server

Home Page: https://battlechat-dev.herokuapp.com

License: GNU General Public License v3.0

Java 23.65% HTML 1.62% CSS 2.12% JavaScript 72.61%

battlechat's People

Contributors

fqde-inc avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

battlechat's Issues

Requirement: Minimum concurrent matches

User story

As a Stakeholder,
I would like to be sure that the server can handle at least 16 simultaneous games,
so that at least 32 people can play Battleship simultaneously

Acceptance test
Prerequisites The server is started
Expected Input At least 16 matches are in progress
Expected Output The service remains responsive

Requirement: Battleship Placement Phase

User story

As a Player,
I would like to be able to place my Battleships at the start of the match,
so that I have control over the arrangement of my fleet.

Acceptance test
Prerequisites Phase 1 of the game has started, and Player has chosen a ship to place
Expected Input Player chooses a square to place the ship
Expected Output Ship appears at the selected square

Requirement: Real-time in-game chat capability

User story

As a Player,
I would like to have the ability to communicate with my opponent,
so that I can say rude things to him.

Acceptance test
Prerequisites Player is in a game
Expected Input Player writes a message and sends it
Expected Output message shows in chat for all participants

Requirement: Error messages on invalid requests

User story

As a client-side developer,
I would like for the server to return informative error messages when I issue requests that cannot be honored,
so that debugging front-end development is not opaque.

Acceptance test
Prerequisites It's not the player's turn
Expected Input Client code sends a firing GameMessage
Expected Output The Server sends an Error GameMessage that explains that it wasn't the player's turn

Client-side validation for battleship placement

The client needs some understanding of what qualifies as a valid placement of battleships, so that it can provide the user with immediate feedback about invalid placements, or disallow them entirely, allowing for a better user experience.

This also prevents the server from having to validate individual ship placements all the time, reducing load.

Requirement: Ignore functionality

User story

As a Player,
I would like to be able to ignore the other player’s chat messages,
so that they can’t hurt my feelings.

Acceptance test
Prerequisites The player is in a match
Expected Input The player clicks a button or inputs a command indicating they would like to ignore their opponent
Expected Output The game no longer displays messages from the other player

Requirement: Forfeitting a match

User story

As a Player,
I would like the possibility to give up(forfeit/surrender) a match,
so that I'm not forced to play through a one-sided match.

Acceptance test
Prerequisites It's the player's turn
Expected Input Player clicks a button or enters a command indicating they'd like to forfeit the game
Expected Output The match is over and the other player wins

Define interfaces between Client and Server

Figure out what the data looks like for the models sent over the wire

Needs:
Ship-placement models (sent Client to Server)
Firing models (sent Client to Server)
Valid firing locations (sent Server to Client)
Ship listings (sent Server to Client, at start of placement phase)
Game status messages (sent Server to Client, to inform Client of placement versus playerX firing turn, player Y firing turn, player X win, player Y win, etc)
Chat messages (sent Client to Server, then Server to Clients)

Requirement: Timed turns

User story

As a Player,
I would like there to be a time limit on moves,
so that I don’t have to wait til the end of time for a slow opponent.

Acceptance test
Prerequisites Player has their turn
Expected Input Player does not make a move for 60 seconds
Expected Output The player's turn is skipped and it becomes the other player's turn

Requirement: Win/Lose notification

User story

As a Player,
I would like to be notified when I win or lose,
so that I know when the game is over.

Acceptance test
Prerequisites A game has been played to completion, meaning that one player no longer has any ships
Expected Input A state representing a completed game
Expected Output The game displays a notification indicating who won, and no longer accepts firing commands

Requirement: 'Low latency' and client-side feedback

User story

As a Player,
I would like the game to respond to my actions in less than 2 seconds most of the time,
so that the game feels responsive and not frustrating.

Acceptance test
Prerequisites Player is in a game
Expected Input Player performs some action, such as attempting to fire on a square
Expected Output The game returns some form of feedback with a maximum of 2 seconds, on average

Requirement: Ship rotation during placement phase

User story

As a Player,
I would like to be able to rotate a ship I place,
so that I can hide my submarines even better.

Acceptance Test
Prerequisites Player has placed or is placing a ship
Expected Input Player chooses to rotate the ship
Expected Output If the ship was oriented horizontally, it is now vertical. Or the inverse.

Requirement: Real-time event logging

User story

As a Player,
I would like to see a log over the moves made,
so that I can keep track of my enemy's actions.

Acceptance test
Prerequisites At least one Event has occurred
Expected Input An Event, such as a ship placement or a firing command
Expected Output The result of the Event is written visibly to the screen, eg. "Player 1 fired at G5: MISS"

Requirement: Turn-based combat

User story

As a Player,
I would like assurance that only one player can fire at a time,
so that the rules of the game are enforced.

Acceptance test
Prerequisites The placement phase of the game is complete
Expected Input Player attempts to fire when it is the other player's turn
Expected Output The action is not allowed

Requirement: Firing Phase

User story

As a Player,
I would like to be able to easily choose a target to fire at in the combat round,
so that I have control over where my fleet fires.

Acceptance test
Prerequisites Phase 2 of the game has started
Expected Input Player clicks where they'd like to fire
Expected Output Game displays the square as either a hit or a miss and marks it

Basic matchmaking and session creation

The server needs to maintain a collection of sessions.

When a player joins a game, there are two possibilities:

  • there is a session with only one player connected to it. In this case, the player is connected to that session, which is then considered filled.
  • there is no unfilled sessions, in which case a new session is created and the player is connected to that one.

Requirement: Web-based user-interface

User story

As a Player,
I would like to be able to access the game via my web browser,
so that I can easily play from anywhere, without needing to install any special software.

Acceptance test
Prerequisites The server is running, Player has a web browser and an internet connection
Expected Input The Player navigates to the URL for the Battlechat service
Expected Output Page loads and the Player is able to enter a game

Server-side domain logic for how ships can be placed

The server-side code needs to implement domain knowledge of what a valid ship configuration looks like.

The rules are as follows:

  • A configuration consists of 4 ships
  • Ships are 1-unit wide
  • A fleet contains ships with exactly one ship with 2, 3, 4 and 5 units in length
  • ships may be placed horizontally or vertically
  • ships may not intersect one another
  • all portions of a ship must be located within the game grid
  • #26

Start placement phase when a session is filled

When a session contains two people, the server should send a message to both players that the game is beginning and the server will then become receptive to ship placement commands.

Requirement: Mark areas where a ship has been hit

User story

As a Player,
I would like to be able to see where my shots have hit the enemy,
so that I can keep track of the enemy ships my fleet has hit.

Acceptance test
Prerequisites Player has fired at least one shot that was a hit and one shot that was a miss
Expected Input A game state in which the above prerequisite is met
Expected Output The square that was hit and the square that was a miss are visually distinguishable

Requirement: Mark areas that have been fired upon

User story

As a Player,
I would like to be able to see where my fleet has already shot at,
so that I can keep track of where to shoot next and avoid wasting shots.

Acceptance test
Prerequisites Player has fired at least one shot
Expected Input Player chooses to fire their shot on a square that they've already hit
Expected Output The ability to select that square is disabled

Create mockup of battleship game page

Make a plain html page to test the client-side code on, for quicker iteration in UI design and ease of client-side code testing.

@TheMightyMarm is assigned.

Server-side validation of Battleship placements

When the client has finished placing their ships onto the board, the configuration of ships should be POSTed to the server (via /session//placement or similar), and the server should return HTTP Status Code 200 if it's valid or 400 if invalid.

If the configuration is valid, the server's gamestate should be updated accordingly.

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.