de.hagenah.diplomacy.diptool
Class DipGame

java.lang.Object
  extended by de.hagenah.diplomacy.game.Game
      extended by de.hagenah.diplomacy.diptool.DipGame
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class DipGame
extends Game

A game.

See Also:
Serialized Form

Method Summary
 DiaryEntry createDiaryEntry(Person from, int number, java.lang.String text, Phase phase)
          Creates a new diary entry (if the diary entry doesn't already exist)
 Message createMessage(boolean anonymous, Person from, boolean toallbut, java.util.Collection to, boolean faketoallbut, java.util.Collection faketo, java.lang.String text, java.util.Date date)
          Creates a new message (if the message doesn't already exist)
 Turn createTurn(int number, Phase phase, java.util.Date turndate)
          Retrieves the specified turn.
 void deleteDiaryEntry(DiaryEntry entry)
          Deletes a diary entry.
 void deleteMessage(Message msg)
          Removes the message msg.
 MessageFilter getFilter()
          Returns the current message filter.
 java.util.List getFilteredDiaryEntries(int number)
          Returns a (ordered) list with the messages for the specified turn.
 java.util.List getFilteredMessages(int number)
          Returns a (ordered) list with the messages for the specified turn.
 DipGameGroup getGroup()
          Returns the group
protected  Turn internCreateTurn(int number, Phase phase)
          Creates a Turn object
 void rollback(int number, boolean removeallorders)
          Rolls the game back to the turn number.
 void setFilter(MessageFilter filter)
          Sets a new message filter.
 void setTurnDate(int number, java.util.Date turndate)
          Sets the date of the turn.
 
Methods inherited from class de.hagenah.diplomacy.game.Game
areMessagesCached, compareTo, equals, getComment, getDescription, getDiaryEntries, getDiaryEntry, getDiaryEntryTurn, getIdentity, getJudge, getLastPhase, getMap, getMessages, getMessageTurn, getMostRecentTurn, getName, getOptions, getParameter, getParameters, getParameterValue, getPersonInfo, getSpecialCenters, getSpecialPhaseCenters, getTurn, getTurn, getTurnDate, getTurnIndex, getTurns, getVictors, hashCode, hasOption, hasParameterFlag, processTurns, setComment, setIdentity, setLastPhase, setOptions, setParameters, setPersonInfo, setVictors, toString, wasConceded
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getGroup

public DipGameGroup getGroup()
Returns the group


internCreateTurn

protected Turn internCreateTurn(int number,
                                Phase phase)
Creates a Turn object

Overrides:
internCreateTurn in class Game

createTurn

public Turn createTurn(int number,
                       Phase phase,
                       java.util.Date turndate)
Retrieves the specified turn. If it does not exist it is created.

Overrides:
createTurn in class Game
Parameters:
number - The number of the phase (>=Turn.NUMBER_FIRST).
phase - The phase (!=null).
turndate - The date of the turn (can be null if unknown)
Returns:
The turn (!=null)

rollback

public void rollback(int number,
                     boolean removeallorders)
Rolls the game back to the turn number.

Overrides:
rollback in class Game
Parameters:
number - The number of the turn to rollback to
removeallorders - true: all orders of the turn number are removed, false: only the NMR orders are removed and the result flags of the other orders are cleared.

createDiaryEntry

public DiaryEntry createDiaryEntry(Person from,
                                   int number,
                                   java.lang.String text,
                                   Phase phase)
Creates a new diary entry (if the diary entry doesn't already exist)

Overrides:
createDiaryEntry in class Game
Parameters:
from - The person that created the diary entry (can be null if unknown)
number - The number of the diary entry (-1 if unknown)
text - The diary entry text (\n as line separator)
phase - The phase in which the diary entry was created
Returns:
The created diary entry or null if the diary entry already existed

deleteDiaryEntry

public void deleteDiaryEntry(DiaryEntry entry)
Deletes a diary entry.

Overrides:
deleteDiaryEntry in class Game
Parameters:
entry - The diary entry to delete.

createMessage

public Message createMessage(boolean anonymous,
                             Person from,
                             boolean toallbut,
                             java.util.Collection to,
                             boolean faketoallbut,
                             java.util.Collection faketo,
                             java.lang.String text,
                             java.util.Date date)
Creates a new message (if the message doesn't already exist)

Overrides:
createMessage in class Game
Parameters:
anonymous - Is the message anonymous (grey)?
from - The person that sent the message (can be null if unknown)
toallbut - false → the message was sent to to, true → the message was send to all but to (if to is an empty list it was a broadcast message).
to - The interpretation depends on toallbut (can be null if unknown)
faketoallbut - false → the message was faked to faketo, true → the message was faked to all but faketo (if faketo is an empty list it was a faked broadcast message).
faketo - The interpretation depends on faketoallbut (cannot be null)
text - The message text (\n as line separator)
date - The date of the message (can be null)
Returns:
The created message or null if the message already existed or wasn't added

deleteMessage

public void deleteMessage(Message msg)
Removes the message msg.

Overrides:
deleteMessage in class Game
Parameters:
msg - The message to delete

getFilter

public MessageFilter getFilter()
Returns the current message filter.

Returns:
The current filter

setFilter

public void setFilter(MessageFilter filter)
Sets a new message filter.

Parameters:
filter - The new filter

getFilteredMessages

public java.util.List getFilteredMessages(int number)
Returns a (ordered) list with the messages for the specified turn.

Parameters:
number - The number of the turn
Returns:
The messages

getFilteredDiaryEntries

public java.util.List getFilteredDiaryEntries(int number)
Returns a (ordered) list with the messages for the specified turn.

Parameters:
number - The number of the turn
Returns:
The messages

setTurnDate

public void setTurnDate(int number,
                        java.util.Date turndate)
Sets the date of the turn. If the date is not between existing dates it is ignored.

Overrides:
setTurnDate in class Game
Parameters:
number - The number of the turn
turndate - The date of the turn (can be null to clear the date)