Class BoardManager

java.lang.Object
  extended by BoardManager

public class BoardManager
extends java.lang.Object

This class manages the display, and game-play for a stratego game


Constructor Summary
BoardManager()
           
 
Method Summary
 int calculateColumn(int X)
          This Method takes a X value and calculates the column it falls under
 int calculateRow(int Y)
          This Method takes a Y value and calculates the Row it falls in
 int calculateX(int column)
          This Method takes a column and calculates its stating X value
 int calculateY(int row)
          This Method takes a column and calculates its stating Y value
 boolean canBlueMove()
          This Method checks if any of Blue's units can move
 boolean canRedMove()
          This Method checks if any of red's units can move
 void deityMode()
          This Method calls the deityMode Method on the selected unit
 void drawBoard()
          This Method redraws the game board
 void flagReveal()
          This Method calls the flagReveal Method in the StrategoBoard class
 void gameOver()
          This Method checks which player (if any) won, and calls the appropriate method from the Stratego Game class
 int getGameState()
          This Method returns the integer representation of the game state
 StrategoPiece getSelectedPiece()
          This Method returns the active StrategoPiece Object
 StrategoBoard getStrategoBoard()
          This Method returns the active StrategoBoard Object
 void hideBlue()
          This Method sets all of blues units to be hidden
 void hideRed()
          This Method sets all of reds units to be hidden
 void killUnit()
          This Method destroys the selected unit as though it were destroyed in battle
 void moveSelectedPiece(int row, int column)
          This Method checks if the selected piece could move to the given square
 void newGame()
          This Method Starts a new game of Stratego, clearing out the board and switching to placement mode, resetting both UnitsToPlace vectors
 void paintComponent(java.awt.Graphics g)
          This Method draws the grid lines on the background image
 void passTurn()
          This Method switches players turns.
 void placeUnitInSelectedSquare()
          This Method prompts the user for which unit to place in the selected square placing and removing it from the UnitsToPlace Vector it if possible, notifying the user why not otherwise
 void playGame()
          This Method starts the main Gameplay loop, waiting on input from the current player, and switching turns after.
 void removeplaceUnitFromSelectedSquare()
          This Method removes the unit from the selected square, returning it to the UnitsToPlace Vector
 void resetSelecetedPiece()
          This Method sets the selected piece to null and the former row and columns to -1
 void returnSelecetedPiece()
          This Method return the selected piece from whence it came
 void selectSquare(int x, int y)
          This Method sets the square at the x and y coords as the selected square
 void setGameState(int newState)
          This Method sets the game state
 void setSelectedPiece(StrategoPiece piece, int row, int column)
          This Method makes the given piece the selected one, and saves its former row and column
 void showBlue()
          This Method sets all of blues units to be visible
 void showRed()
          This Method sets all of reds units to be visible
 void updateSelectedPiece(int x, int y)
          This Method redraws the selected Piece
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoardManager

public BoardManager()
Method Detail

calculateX

public int calculateX(int column)
This Method takes a column and calculates its stating X value

Parameters:
column - the column to calculate the starting X value of
Returns:
returns the the starting X value of a column

calculateY

public int calculateY(int row)
This Method takes a column and calculates its stating Y value

Parameters:
row - the row to calculate the starting Y value of
Returns:
returns the the starting Y value of a row

calculateRow

public int calculateRow(int Y)
This Method takes a Y value and calculates the Row it falls in

Parameters:
Y - the Y value to calculate the row from
Returns:
returns the the row

calculateColumn

public int calculateColumn(int X)
This Method takes a X value and calculates the column it falls under

Parameters:
X - the X value to calculate the column value of
Returns:
returns the the Column

setSelectedPiece

public void setSelectedPiece(StrategoPiece piece,
                             int row,
                             int column)
This Method makes the given piece the selected one, and saves its former row and column

Parameters:
piece - the StrategoPiece being selected
row - the row the piece is in
column - the column the piece is in

resetSelecetedPiece

public void resetSelecetedPiece()
This Method sets the selected piece to null and the former row and columns to -1


updateSelectedPiece

public void updateSelectedPiece(int x,
                                int y)
This Method redraws the selected Piece

Parameters:
x - the new X value
y - the new Y value

returnSelecetedPiece

public void returnSelecetedPiece()
This Method return the selected piece from whence it came


moveSelectedPiece

public void moveSelectedPiece(int row,
                              int column)
This Method checks if the selected piece could move to the given square

Parameters:
row - the row to move to
column - the new column to move to

paintComponent

public void paintComponent(java.awt.Graphics g)
This Method draws the grid lines on the background image

Parameters:
g - the background image in Graphics format

getGameState

public int getGameState()
This Method returns the integer representation of the game state

Returns:
returns the integer representation of the game state

setGameState

public void setGameState(int newState)
This Method sets the game state

Parameters:
newState - the game state to change to

getStrategoBoard

public StrategoBoard getStrategoBoard()
This Method returns the active StrategoBoard Object

Returns:
returns the StrategoBoard Object

getSelectedPiece

public StrategoPiece getSelectedPiece()
This Method returns the active StrategoPiece Object

Returns:
returns the StrategoPiece Object

drawBoard

public void drawBoard()
This Method redraws the game board


deityMode

public void deityMode()
This Method calls the deityMode Method on the selected unit


flagReveal

public void flagReveal()
This Method calls the flagReveal Method in the StrategoBoard class


killUnit

public void killUnit()
This Method destroys the selected unit as though it were destroyed in battle


selectSquare

public void selectSquare(int x,
                         int y)
This Method sets the square at the x and y coords as the selected square

Parameters:
x - the x coordinate
y - the y coordinate

placeUnitInSelectedSquare

public void placeUnitInSelectedSquare()
This Method prompts the user for which unit to place in the selected square placing and removing it from the UnitsToPlace Vector it if possible, notifying the user why not otherwise


removeplaceUnitFromSelectedSquare

public void removeplaceUnitFromSelectedSquare()
This Method removes the unit from the selected square, returning it to the UnitsToPlace Vector


newGame

public void newGame()
This Method Starts a new game of Stratego, clearing out the board and switching to placement mode, resetting both UnitsToPlace vectors


playGame

public void playGame()
This Method starts the main Gameplay loop, waiting on input from the current player, and switching turns after.


passTurn

public void passTurn()
This Method switches players turns.


hideRed

public void hideRed()
This Method sets all of reds units to be hidden


hideBlue

public void hideBlue()
This Method sets all of blues units to be hidden


showRed

public void showRed()
This Method sets all of reds units to be visible


showBlue

public void showBlue()
This Method sets all of blues units to be visible


canRedMove

public boolean canRedMove()
This Method checks if any of red's units can move


canBlueMove

public boolean canBlueMove()
This Method checks if any of Blue's units can move


gameOver

public void gameOver()
This Method checks which player (if any) won, and calls the appropriate method from the Stratego Game class