Class Message

java.lang.Object
  |
  +--PrintSuperClass
        |
        +--MessageTemplate
              |
              +--Message

public class Message
extends MessageTemplate

Used to by battleship simulator to send message to each player,


Each message can have upto four fields:
message ID (Integer),  name descriptive string name of message
details (Integer) and Class Pointer - class pointer to additional information        
public class Messages - Methods:

public String getName( ) returns message String name
public int get( )        returns current message ID
public int getDetails( ) returns details of current message
public Object getClassPointer( ) returns current class object pointer

public void setMessageName provides self documenting code

public boolean isMessageName() returns true if message is set

deprecated replaces with setMessageName
private void setDetails( ) sets details of current message
public boolean set( int mID ) sets message ID

Note System has Three Modes of Play:

Head to Head Combat Mode - Message Sent to makeMove

IDHeadToHead get ready getDetails has games to be played
IDPlaceShip class pointer has ship class to place ships on
IDNewGame    return first move, getDetails has games left
During Play
IDHit, IDMiss (return next move)
IDWin, IDLost (wait for IDNewGame)
IDSunk getDetails has ship index
IDTooManyMoves exceeded allowable attempts, details has #moves

Single User Test Mode - Message Sent to makeMove

IDSingleUser just get ready
IDNewGame,  (return your first move)
IDHit, IDMiss, (return you next move)
IDSunk, (return next move)
IDWin,  IDTooManyMoves, - Next message will be IDNewGame

Note on IDSunk and IDWin, your ship at Sea board will have the HITCHAR
replaced with the upper case ship code, i.e., Destroyer is 'D'

getDetails
returns Ship code of sunk sunk on IDSUNK
returns number of games to still to play on IDSingleUser, and IDNewGame

Simulation Mode
Multiple players each must play a 1000 games to finish,
This is followed by 100games against a benchMark Player
each player is given a actual performance rating


int getDetails( )
auxiliary info: NewSeries GameTypePointer Simulation vs RoundRobin
NewGame GameCount, ShipPointer
Sunk type of ShipSunk
SeriesOver GameOverResults-Pointer
Object getClassPointer( )
returns class Pointer

checkAuthenication( PlayerPtr )
returns true if message was sent from battleShip and you are the 
intended receiver


Field Summary
static int IDHeadToHead
           
static int IDHeadToHeadDone
           
static int IDHit
           
static int IDLost
           
static int IDMiss
           
static int IDNewGame
           
static int IDPerformanceRating
           
static int IDPlaceShips
           
static int IDPlaceShipsFailed
           
static int IDSeriesRating
           
static int IDSingleUser
           
static int IDSingleUserDone
           
static int IDSunk
           
static int IDTooManyMoves
           
static int IDTournament
           
static int IDTournamentDone
           
static int IDUnknown
           
static int IDWin
           
static int IDYourOpponents
           
static int IDYourShipHit
           
static int IDYourShipNearHit
           
static int IDYourShipSunk
           
static int IDYourWorstBoard
           
 
Fields inherited from class MessageTemplate
classPtr, details, msgID
 
Constructor Summary
Message(int mid, java.lang.Object cp, Player p)
           
 
Method Summary
 boolean checkAuthenication(Player forMe)
          prohibits any changes in player using checkAuthenication
 java.lang.String getName()
           
 boolean isGameOver()
           
 boolean isHeadToHead()
           
 boolean isHeadToHeadDone()
           
 boolean isHit()
           
 boolean isLost()
           
 boolean isMiss()
           
 boolean isNewGame()
           
 boolean isPlaceShips()
           
 boolean isSingleUser()
           
 boolean isSingleUserDone()
           
 boolean isSunk()
           
 boolean isTooManyMoves()
           
 boolean isTournament()
           
 boolean isTournamentDone()
           
 boolean isWin()
           
 boolean isYourShipHit()
           
 boolean isYourShipNearHit()
           
 boolean isYourShipSunk()
           
 boolean set(int mID)
          Deprecated. replaces with setMessageName
 void setHeadToHead(int ngames, Player opp)
           
 void setHeadToHeadDone()
          at end of a head to head combat, IDHeadToHeadDone is sent to both players data from head to head combat is added to SeriesRating link list
 void setHit(int moves)
           
 void setLost(int moves)
           
 void setMiss(int moves)
           
 void setNewGame(int ngames, Player opp)
          Used by battleship simulator to set the message IDNewGame,
 void setPerformanceRating()
          Vital Statisitics Skill now has updated performance rating
 void setPlaceShips(Ships ships)
           
 void setPlaceShipsFailed()
          Player is given five attempts to place ships
 void setSeriesRating()
          at End of HeadToHead tournament series, IDSeriesRating message is sent to each player
 void setSingleUser(int ngames)
           
 void setSingleUserDone()
          at end of singleUserTestMode, IDSingleUserDone is sent to player
 void setSunk(int shipID)
           
 void setTooManyMoves(int moves, Ships failed)
           
 void setTournament(int ngames)
          Start Tournament mode,
 void setTournamentDone()
          at End of tournament mode, IDTournamentDone is sent to each player
 void setUnknown()
          Used by battleship simulator to set an Unknown Message
 void setWin(int moves)
          Used by battleship simulator to set the message IDWin,
 void setYourShipHit(int coordinate, Ships atSea)
           
 void setYourShipNearHit(int coordinate, Ships atSea)
           
 void setYourShipSunk(int shipID, Ships atSea)
           
 void setYourWorstBoard(int moves, Ships failed)
           
 java.lang.String toString()
           
 
Methods inherited from class MessageTemplate
checkAuthenication, copy, get, getClassPointer, getDetails, getRecipient, getSignature, print, println, setAuthenication, setClassPointer
 
Methods inherited from class PrintSuperClass
print, print, print, println, println, println
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IDUnknown

public static final int IDUnknown

IDWin

public static final int IDWin

IDLost

public static final int IDLost

IDSunk

public static final int IDSunk

IDNewGame

public static final int IDNewGame

IDHit

public static final int IDHit

IDMiss

public static final int IDMiss

IDHeadToHead

public static final int IDHeadToHead

IDTournament

public static final int IDTournament

IDSingleUser

public static final int IDSingleUser

IDPlaceShips

public static final int IDPlaceShips

IDTooManyMoves

public static final int IDTooManyMoves

IDPlaceShipsFailed

public static final int IDPlaceShipsFailed

IDYourShipSunk

public static final int IDYourShipSunk

IDYourShipHit

public static final int IDYourShipHit

IDYourShipNearHit

public static final int IDYourShipNearHit

IDYourWorstBoard

public static final int IDYourWorstBoard

IDPerformanceRating

public static final int IDPerformanceRating

IDYourOpponents

public static final int IDYourOpponents

IDSeriesRating

public static final int IDSeriesRating

IDTournamentDone

public static final int IDTournamentDone

IDSingleUserDone

public static final int IDSingleUserDone

IDHeadToHeadDone

public static final int IDHeadToHeadDone
Constructor Detail

Message

public Message(int mid,
               java.lang.Object cp,
               Player p)
Method Detail

setUnknown

public void setUnknown()
Used by battleship simulator to set an Unknown Message

setWin

public void setWin(int moves)
Used by battleship simulator to set the message IDWin,
Parameters:
moves - is the number of game moves, details is set to moves

setLost

public void setLost(int moves)

setSunk

public void setSunk(int shipID)

setNewGame

public void setNewGame(int ngames,
                       Player opp)
Used by battleship simulator to set the message IDNewGame,
Parameters:
details - is set to the number of games left to be playerd
opp - is set to your opponent

setHit

public void setHit(int moves)

setMiss

public void setMiss(int moves)

setHeadToHead

public void setHeadToHead(int ngames,
                          Player opp)

setTournament

public void setTournament(int ngames)
Start Tournament mode,
Parameters:
playerList, - is set to head of link list or Players

setSingleUser

public void setSingleUser(int ngames)

setPlaceShips

public void setPlaceShips(Ships ships)
Parameters:
ships - is pointer to ship-board you must place ships on

setTooManyMoves

public void setTooManyMoves(int moves,
                            Ships failed)
Parameters:
moves - is set to number of moves in game
failed - is set to ship image of board you failed on

setPlaceShipsFailed

public void setPlaceShipsFailed()
Player is given five attempts to place ships

setYourShipHit

public void setYourShipHit(int coordinate,
                           Ships atSea)
Parameters:
details - is set singleton coordinate of location just hit
atSea - is the ship board you created, has updates

setYourShipSunk

public void setYourShipSunk(int shipID,
                            Ships atSea)
Parameters:
details - is set to ID of ship just sunk
atSea - is set to your current status of ships at Sea

setYourShipNearHit

public void setYourShipNearHit(int coordinate,
                               Ships atSea)
Parameters:
details - is set to singleton coordinate locaion of near hit
atSea - is set to your current status of ships at Sea Caveat not implemented

setYourWorstBoard

public void setYourWorstBoard(int moves,
                              Ships failed)
Parameters:
moves - is set to number of moves for your worst game in singleUserTestMode classPointer Ships is set to a copy of this board

setPerformanceRating

public void setPerformanceRating()
Vital Statisitics Skill now has updated performance rating

setSeriesRating

public void setSeriesRating()
at End of HeadToHead tournament series, IDSeriesRating message is sent to each player

setTournamentDone

public void setTournamentDone()
at End of tournament mode, IDTournamentDone is sent to each player

setHeadToHeadDone

public void setHeadToHeadDone()
at end of a head to head combat, IDHeadToHeadDone is sent to both players data from head to head combat is added to SeriesRating link list

setSingleUserDone

public void setSingleUserDone()
at end of singleUserTestMode, IDSingleUserDone is sent to player

checkAuthenication

public boolean checkAuthenication(Player forMe)
prohibits any changes in player using checkAuthenication

getName

public java.lang.String getName()
Overrides:
getName in class MessageTemplate
Returns:
returns descriptive String name of current Message

toString

public java.lang.String toString()
Overrides:
toString in class MessageTemplate

isWin

public boolean isWin()
Returns:
returns true if current message is IDWin

isLost

public boolean isLost()

isSunk

public boolean isSunk()

isNewGame

public boolean isNewGame()

isHit

public boolean isHit()

isMiss

public boolean isMiss()

isHeadToHead

public boolean isHeadToHead()

isTournament

public boolean isTournament()

isSingleUser

public boolean isSingleUser()

isPlaceShips

public boolean isPlaceShips()

isTooManyMoves

public boolean isTooManyMoves()

isYourShipHit

public boolean isYourShipHit()

isYourShipSunk

public boolean isYourShipSunk()

isYourShipNearHit

public boolean isYourShipNearHit()

isTournamentDone

public boolean isTournamentDone()

isSingleUserDone

public boolean isSingleUserDone()

isHeadToHeadDone

public boolean isHeadToHeadDone()

set

public boolean set(int mID)
Deprecated. replaces with setMessageName


isGameOver

public boolean isGameOver()