Documentation - JosoIce/Group7Battleship GitHub Wiki

Battleship project documentation

Team Members:

Chee Yao, 101977163 Josiah Sonsie, 101094376 Rory Free, 102119869

Bugs

  • When user tries to click on the grid during setup, the ship doesn't register on the location of the click. Instead, it registers somewhere else.
  • Can't click on the vertical arrow button.
  • Play button sometimes work and sometimes don't.
  • Potential sound bug?????

Extension ideas

  • New background picture
  • New SoundTrack
  • Different colour scheme
  • Better battleship pictures / icon
  • Better font
  • Touchscreen support

Code Base - Description

Folder 'src':

DeploymentController.vb

This file controls deployment of ships onto the battlefield in the early phases of the game. This file may have bugs as deployment controls are less than perfect.

Methods:

  • HandleDeploymentInput
  • DoDeployClick
  • DrawDeployment
  • GetShipMouseIsOver

DiscoveryController.vb

This file controls the main phase of the game, in which each player attacks other players' fields until one loses their ships. This does everything from handling input to drawing the game during this phase.

Methods:

  • HandleDiscoveryInput
  • DoAttack
  • DrawDiscovery

EndingGameController.vb

This is quite self-explanatory, controlling the phase at the end of the game.

Methods:

  • DrawEndOfGame
  • HandleEndOfGameInput

GameController.vb

The game controller controls the game at every stage, on a wider scale. It has properties that store game state info and player info.

Methods:

  • StartGame
  • EndGame
  • PlayHitSequence
  • PlayMissSequence
  • AttackCompleted
  • EndDeployment
  • Attack
  • AIAttack
  • CheckAttackResult
  • HandleUserInput
  • DrawScreen
  • AddNewState (These states are explained in GameState.vb)
  • SwitchState
  • EndCurrentState
  • SetDifficulty

GameLogic.vb

This is the main method of the project. Very simple file that calls the methods that run the game.

Methods:

  • Main

GameResources.vb

Self-explanatory, this file has methods to load the resources of the game to be shown everywhere they are used. Stores certain variables in the "Game" methods e.g. GameFont simply returns _Font. Handles certain utilities such as in ShowMessage.

Methods:

  • LoadFonts
  • LoadSounds
  • LoadMusic
  • GameFont
  • GameImage
  • GameMusic
  • LoadResources
  • ShowLoadingScreen
  • PlaySwinGameIntro
  • ShowMessage
  • NewFont (These 'New' methods allow new resources to be loaded)
  • NewImage
  • NewTransparentColorImage (and a version with the other spelling)
  • NewSound
  • NewMusic
  • FreeFonts
  • FreeImages

GameState.vb

Contains a single Enum of all GameStates, to help the game know what stage players are at. These are for the most part self-explanatory.

Possible GameStates:

  • ViewingMainMenu
  • ViewingGameMenu
  • ViewingHighScores
  • AlteringSettings
  • Deploying (Players are deploying their ships)
  • Discovering (Players are attempting to locate each other's ships)
  • EndingGame
  • Quitting

HighScoreController.vb

This file acts as the controller for high score data. It contains the methods for displaying and collecting this data.

Methods:

  • LoadScores
  • SaveScores
  • DrawHighScores
  • HandleHighScoreInput
  • ReadHighScore

MenuController.vb

This controller handles the menu. It contains methods for drawing the menu, and processing menu input, including the game menu, main menu, and settings menu.

  • HandleMainMenuInput
  • HandleSetupMenuInput
  • HandleGameMenuInput
  • HandleMenuInput
  • DrawMainMenu
  • DrawGameMenu
  • DrawSettings
  • DrawButtons (And a default variant which draws the buttons on 0,0)
  • IsMouseOverButton
  • IsMouseOverMenu
  • PerformMenuAction
  • PerformMainMenuAction
  • PerformSetupMenuAction
  • PerformGameMenuAction

UtilityFunctions.vb

This file includes multiple methods that draw elements on the screen, such as the ships, explosions, etc. The comments also describe ways in which this file interacts with the mouse.

Methods:

  • IsMouseInRectangle
  • DrawField
  • DrawCustomField
  • DrawBackground
  • DrawMessage
  • AddExplosion
  • AddSplash
  • AddAnimation
  • UpdateAnimations
  • DrawAnimations
  • DrawAnimationSequence

Folder: 'src/Model'

AIHardPlayer.vb

This file is the class for the more difficult AI player. It inherits from the AIPlayer class, but with an added understanding of how ships can continue in one direction once two adjacent ship tiles are discovered, increasing the game's difficulty. It contains the class Target, the AI's approximation of the ship that was fired at.

Methods:

  • GenerateCoords <<override>>
  • TargetCoords
  • SearchCoords
  • ProcessShot <<override>>
  • ProcessDestroy (Processes the fact that enemy ships are destroyed)
  • RemoveShotsAround (Removes the planned shots around ships that were destroyed)
  • ProcessHit
  • ReOrderTargets (Handles targeting priority)
  • AddTarget

AIMediumPlayer.vb

This is another variant of AIPlayer, that is slightly more intelligent than its parent class. This version is able to acknowledge the existence of a ship, rather than firing randomly.

Methods:

  • GenerateCoords <<override>>
  • TargetCoords
  • SearchCoords
  • ProcessShot <<override>>
  • AddTarget

AIOption.vb

An enumeration of the three different AI difficulties. (Easy, Medium, Hard)

AIPlayer.vb

This is the easy version of the AI, and is what all the other AI levels inherit from. This essentially just shoots randomly. This inherits from the Player class. It also contains a protected class "Location".

Methods:

  • GenerateCoords <<abstract>>
  • ProcessShot <<abstract>>
  • Attack <<override>>
  • Delay

AttackResult.vb

This file gives the result of a shot. Does not contain any relevant methods.

BattleShipsGame.vb

This file controls the game at a high level, controlling elements such as adding players to the game, making sure both players have deployed all of their ships before starting, and checking if either player has won at any point.

Methods:

  • AttackComletedHandler
  • AttackCompletedHandler
  • AddDeployedPlayer
  • CompleteDeployment
  • Shoot

Direction.vb

An enumeration of the different directions that a ship can be oriented (LeftRight, UpDown)

ISeaGrid.vb

This file is the interface for the SeaGrid object.

Player.vb

This is the class for each player, and what AIPlayer inherits from. It contains properties for the player's grids, along with booleans that show the player's status in the game.

Methods:

  • GetShipEnumerator
  • GetEnumerator
  • Attack
  • Shoot
  • RandomizeDeployment (For AI)

ResultOfAttack.vb

Enumeration of possible attack results. (Hit, Miss, Destroyed, ShotAlready, GameOver)

SeaGrid.vb

This is the class representing the grid that ships are deployed on.

Methods:

  • AddShip
  • HitTile

SeaGridAdapter.vb

This file essentially handles changes in the sea grid.

Methods:

  • MyGrid_Changed
  • HitTile

Ship.vb

This is the object that stores all the information about the ship. It therefore contains many properties about the status of the ship, its name (described below), its position, etc.

  • AddTile
  • Remove
  • Hit
  • Deployed

ShipName.vb

This is an enumeration of all the ship names. These are given numbers based on their length (none (0), tug (1), Submarine (2), Destroyer (3), Battleship (4), AircraftCarrier (5))

Tile.vb

This class represents a specific tile on the grid, has properties for its location, and boolean properties for whether it has been shot, and whether it has a ship on it. Along with this, it has a property that returns a TileView (described below) that describes what the tile should look like on the grid.

Methods

  • ClearShip (removes ships from tile)
  • Shoot

TileView.vb

An enumeration of the different kinds of graphics that can be displayed on a given tile. (Sea, Miss, Ship, Hit)

Code Base - Documentation

Model folder

AIHardPlayer.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

AIMediumPlayer.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

AIOption.vb

Documentation – Does not have documentation but self-explanatory

Usefulness – ?

AIPlayer.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

AttackResult.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

TileView.vb

Documentation – Sufficient to explain the purpose of the each method

Usefulness – True

Tile.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

Ship.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

Shipname.vb

Documentation – Does not exist

Usefulness – False

SeaGridAdapter.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

SeaGrid.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

ResultOfAttack.vb

Documentation – Does not have documentation but self-explanatory

Usefulness – ?

Player.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

ISeaGrid.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

Direction.vb

Documentation – Does not have documentation but self-explanatory

Usefulness – ?

BattleShipsGames.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods.

Usefulness – True

SRC Folder

DeploymentController.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness - True

DiscoveryController.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness - True

EndingGameController.vb Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness – True

GameController.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness – True

GameLogic.vb

Documentation – None but file small enough that code is self-explanatory

Usefulness – N/A

GameResources.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness - True

GameState.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness - True

HighScoreController.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness - True

MenuControlelr.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness - True

UtilityFunctions.vb

Documentation – Sufficient to explain the purpose of the document, and briefly describes the functions of the methods. Goes into more detail where necessary

Usefulness - True