public abstract class PuzzleInstance extends java.util.Observable implements java.util.Observer, DrawableGraphProblem
Constructor and Description |
---|
PuzzleInstance()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addDoppelganger(Vertex ganger,
java.awt.Point p,
int num,
boolean connectDoppelToGanger) |
void |
addGraph(java.awt.Point p,
Graph g) |
void |
addGraphWithData(java.awt.Point p,
GraphWithData g) |
void |
addToSelected(java.util.ArrayList<Vertex> verts) |
boolean |
addToSelected(Vertex v) |
void |
addVertex(java.awt.Point coordinates) |
boolean |
canRedo() |
boolean |
canUndo() |
void |
checkAndHandlePuzzleCompletion()
Checks if the game is completed, if it is start a timer to show the game completed dialog when it goes off.
|
void |
clearAllSelections()
Clears the currently selected vertex by setting it to null.
|
void |
clearHistory()
This method clears both histories completely so that no events remain in them: both stacks are cleared
|
void |
clearTutorial() |
int |
computeGlobalPoints() |
void |
connectAllSelectedVertices()
This method creates a clique between all the selected vertices, where each vertex that is select is connected to
each other vertex in the group.
|
void |
connectToSelected(Vertex vert) |
void |
convertMovesToTutorial() |
abstract PuzzleInstance |
copyPuzzle()
Make a copy of this object, but not exactly! IMPORTANT: This copy should make a copy so that the copy's initial
settings are set to this objects current settings.
|
PuzzleInstance |
copyPuzzleSoItHasInitialStateTheSameAsMyCurrentState()
Copies the puzzle so that it has an initial state that is the same as this puzzle's current state.
|
boolean |
copyRequested() |
void |
copySelected()
This method creates a copy of the currently selected vertices, edges and all, and stores this copy in a list for
further use.
|
Vertex |
createNewVertexForPuzzle(java.awt.Point p) |
java.lang.String |
currentPuzzleDataToString()
A wrapper for encodePuzzleData that prepends the encoding character for the current problem type.
|
void |
deleteSelected()
This method deletes all the selected vertices from the graph after disconnecting them.
|
void |
disableHistory()
This method stops the gross history from recording any events that occur.
|
void |
disconnectFromSelected(Vertex vert) |
void |
disconnectSelected()
This method disconnects all the selected vertices from each other on the graph.
|
void |
doNotRecordGraphEvents()
Set recordGraphEvents to false.
|
void |
enableHistory()
This method causes the game class to allow the gross history to start recording events again.
|
void |
endGame() |
void |
forceRedo()
Redo the last move that was undone.
|
java.lang.String |
getAttemptName() |
int |
getBasePoints() |
java.lang.String |
getCurrentAnnotation() |
java.lang.String |
getCurrentMoveOverview() |
Event<?> |
getCurrentUndoableEvent() |
VertexData |
getData(Vertex v)
Calls getData(v) on the graph.
|
abstract VertexData |
getDefaultVertexDataObject() |
java.lang.String |
getDescription()
Get the description of this PuzzleInstance.
|
int |
getDiameter()
This method returns the diameter of the graph of the Puzzle.
|
int |
getDifficultyLevel() |
java.lang.String |
getEdgeDataClassName() |
java.lang.String |
getEditHelpClassName() |
java.lang.String |
getEditorClassName() |
java.lang.String |
getFamilyName() |
Vertex |
getFirstSelected()
This method gets the first vertex that is in the list of all selected vertices.
|
int |
getFirstTimeBonus() |
java.lang.String |
getGameName()
Return the name from the problems column in the DB.
|
int |
getGlobalBest()
This method returns the global best for the current puzzle.
|
GraphWithData |
getGraph()
Returns the GraphWithData that is associated with this game.
|
java.lang.String |
getHelpClassName() |
int |
getHighScoreBonus() |
int |
getImprovementBonus() |
java.lang.String |
getInstanceClassName() |
java.util.ArrayList<Vertex> |
getInterestingTutorialVertices() |
int |
getMaximumXCoordinate() |
int |
getMaximumYCoordinate() |
java.lang.String |
getMessage() |
int |
getMinimumSelectedXCoordinate() |
int |
getMinimumSelectedYCoordinate() |
int |
getMinimumXCoordinate() |
int |
getMinimumYCoordinate() |
Solution.Mode |
getMode() |
int |
getNumberOfEdges() |
int |
getNumberOfMoves() |
int |
getNumberOfVertices()
This method returns the total number of vertices that are on the graph.
|
int |
getNumberSelected()
This method returns the size of the list of selected vertices, indicating the number that have been selected.
|
int |
getOldHighScore() |
int |
getPersonalBest()
This method returns the user's personal best for the current puzzle.
|
java.lang.String |
getPlayClassName() |
abstract java.lang.String |
getProcessedSolution() |
int |
getPuzzleID()
This method just returns the game id.
|
java.lang.String |
getPuzzleInstanceName() |
java.lang.String |
getPuzzleName()
This method returns the name of the current puzzle or null if the puzzle has no name (the puzzle is newly
created).
|
abstract int |
getScore()
Return the current score of the active game.
|
java.util.ArrayList<Vertex> |
getSelectedVertices() |
Solution |
getSolution()
Returns a solution WITHOUT the UserID properly set necessarily.
|
java.lang.String |
getSolutionAsString() |
int |
getSolutionID() |
java.lang.String |
getThemeClassName() |
long |
getTimeTaken()
Returns the time that it took to complete the algorithm/puzzle.
|
Event<?> |
getTopOfUndoStack() |
abstract PuzzleInstance |
getTryItInstanceForUseOnPlayScreen()
What kind of puzzle should the TryIt button produce? Return null if Try it is not applicable
|
TutorialData |
getTutorialData() |
int |
getUserID() |
int |
getVertexIndex(Vertex v)
Get the index of a given vertex
|
java.util.ArrayList<Vertex> |
getVertices()
This method returns a list of all vertices that currently make up the graph.
|
Puzzle.VisibilityType |
getVisibility() |
java.util.ArrayList<Vertex> |
getVisibleSources() |
void |
goToNextEvent() |
boolean |
grossHistoryDeleteLastEvent() |
Event<?> |
grossHistoryGetLastAddedEvent() |
Event<?> |
grossHistoryGetNextEvent() |
int |
grossHistoryGetNextEventIndex() |
boolean |
grossHistoryIsSaved() |
boolean |
grossHistoryIteratorAtBeginning() |
boolean |
grossHistoryIteratorAtEnd() |
Event<?> |
grossHistoryNext() |
Event<?> |
grossHistoryPrevious() |
void |
grossHistorySetSaved(boolean saved) |
int |
grossHistorySize() |
void |
grossHistoryToBeginning() |
void |
grossHistoryToEnd() |
java.lang.String |
initialPuzzleDataToString()
This method is similar to encodeData except that it returns the data as it was in the beginning.
|
abstract boolean |
isCurrentStateValidSolution()
Each instance needs to determine when the solution is valid.
|
abstract boolean |
isEventForThisPuzzleType(Event<?> e)
Return true iff this event is of type T.
|
boolean |
isFinishable() |
boolean |
isInReplayOrEditTutorialMode() |
boolean |
isLocked()
This method sets whether or not the game is locked.
|
boolean |
isLowerScoreBetter() |
boolean |
isPlayable() |
boolean |
isSaved()
Returns whether or not the game has been saved.
|
boolean |
isShowIndices() |
abstract boolean |
isSolutionRefinable()
For optimization problems, for instance, this will return true.
|
boolean |
isSpecialCopyOK() |
boolean |
isTutorial()
Check if the current problem is a tutorial puzzle.
|
boolean |
isValidToTranslationSelection(java.awt.Point change) |
boolean |
isVisibleSource(Vertex visibleSource) |
void |
makeCurrentStateInitialState()
set the current state of the graph to its initial state.
|
void |
moveGraphEnded(java.awt.Point p)
Tells the game that the series of moves is over.
|
void |
moveSelectedVerticesEnded(java.awt.Point p)
Tells the game that the series of moves is over.
|
void |
moveStarted(java.awt.Point p)
Tell the game that a series of moves has started.
|
void |
pasteAndConnectCopyOfSelected(int x,
int y)
Paste the subgrapgh corresponding to the copiedList, adding an edge between the corresponding vertices in the
original list and the new copy.
|
void |
pasteCopyOfSelected(int x,
int y)
This method "pastes" the list of copies vertices onto the graph.
|
void |
performEvents(java.util.ArrayList<Event<?>> eventList) |
void |
performEvents(java.lang.String events)
Take in a string, break it up, and parse it so that it can determine what kind of events were originally fired.
|
boolean |
performTutorialEvents() |
void |
reallySetLocked(boolean flag)
This is needed to lock in Edit mode when there is a tutorial.
|
void |
recordGraphEvents()
Set recordGraphEvents to true.
|
void |
redo()
Allows redoing of events that are "no longer on undo queue" (They are there but hidden).
|
void |
removeFromSelected(java.util.ArrayList<Vertex> toClear)
If the vertices in the list are in the list "selection" they will be deselected.
|
void |
removeFromSelected(Vertex v)
Removes the vertex from the selected list.
|
void |
resetVerticesToInitialLocations()
Reset the vertices to their initial locations.
|
void |
restart()
Causes the game to be started over for the user by reseting all the information to the initial configuration.
|
void |
runAlgorithms()
Notifies the listeners that this algorithm should be run by supplying them with a ClickCheckButtonEvent.
|
void |
runuTryIt() |
void |
selectAll() |
void |
sendAlgorithmResult(boolean r) |
void |
sendMeaninglessEvent() |
void |
setAttemptName(java.lang.String attemptName) |
boolean |
setData(Vertex v,
VertexData vd)
Callse setData(v, vd) on the graph
|
void |
setDefaultData(Vertex vert) |
void |
setDescription(java.lang.String description)
Set the description of this PuzzleInstance.
|
void |
setFinishable(boolean isLockable) |
void |
setGlobalBest(int global)
This method sets the global best for the current puzzle.
|
void |
setGraph(Graph graph)
This method sets the graph for this PuzzleInstance.
|
void |
setInReplayOrEditTutorialMode(boolean inReplayMode)
Set the mode.
|
void |
setLocked(boolean flag)
This method checks to see whether or not the game is locked, meaning that the user is forbbiden from interacting
with it.
|
void |
setMessage(java.lang.String message) |
void |
setMode(Solution.Mode mode) |
void |
setPersonalBest(int pers)
This method sets the players personal best score.
|
void |
setPlayable(boolean isPlayable)
Set the puzzle to playable.
|
void |
setPuzzle(Puzzle dbPuzzle)
This method sets the game name and game id from the passed in game object.
|
void |
setPuzzleID(int gameID) |
void |
setPuzzleName(java.lang.String puzzleName) |
void |
setSaved(boolean saved)
Sets whether or not this game has been saved.
|
void |
setShowIndices(boolean showIndices) |
void |
setSolutionData(java.lang.String data)
Set the solution data to the given string.
|
void |
setSolutionID(int solutionID) |
void |
setSolutionInformation(Solution solution)
This method sets the solution data, such as the time taken by the user, and the previous score set by the user
during their last play through.
|
void |
setUserID(int userID) |
void |
setVisibleSources(java.util.ArrayList<Vertex> visibleSource) |
void |
startTimer()
This method both initializes the timer and causes it to start when it is called.
|
void |
stopTimer()
This method causes the timer to stop if it has been initialized.
|
void |
stringToPuzzleData(java.lang.String configuration)
This method parses the parameter string into the game details.
|
void |
submit()
Notifies the listeners that the submit button has been clicked.
|
void |
toggleSelected(Vertex v) |
abstract boolean |
tryItResultsAreBinding()
Return true only if Try It mode, using the type from getTryItInstance, will produce a result that is AWLAYS valid
for the puzzle type.
|
void |
tutorialModeEnabled(boolean b)
Set isTutorial to the given boolean.
|
void |
undo()
Undo the last RecordableEvent.
|
abstract java.lang.String |
uniqueIdentifier(Vertex v)
Return a string that represents the data related to the given Vertex in a way that is different if the data is
different.
|
void |
update(java.util.Observable o,
java.lang.Object arg) |
abstract void |
updateStateBasedOnAlgorithmResult(java.lang.String algorithmResult)
Updates the algorithm's state based on the algorithm result.
|
void |
updateTimeTaken()
Sets timeTaken to the current time - start time.
|
abstract boolean |
usesAlgorithms()
If the game related to this problem requires running algorithms, this should return true.
|
public abstract boolean isCurrentStateValidSolution()
public abstract boolean usesAlgorithms()
public abstract void updateStateBasedOnAlgorithmResult(java.lang.String algorithmResult)
algorithmResult
- a boolean that describes the result of the algorithm.public abstract boolean isSolutionRefinable()
public abstract PuzzleInstance getTryItInstanceForUseOnPlayScreen()
public abstract boolean tryItResultsAreBinding()
public abstract boolean isEventForThisPuzzleType(Event<?> e)
e
- public abstract PuzzleInstance copyPuzzle()
public abstract int getScore()
public abstract java.lang.String getProcessedSolution()
public abstract VertexData getDefaultVertexDataObject()
public abstract java.lang.String uniqueIdentifier(Vertex v)
public PuzzleInstance copyPuzzleSoItHasInitialStateTheSameAsMyCurrentState()
public void restart()
public java.lang.String getGameName()
public VertexData getData(Vertex v)
v
- GraphWithData.getData(cusack.hcg.graph.Vertex)
public boolean setData(Vertex v, VertexData vd)
v
- vd
- GraphWithData.setData(cusack.hcg.graph.Vertex, cusack.hcg.graph.VertexData)
public void setDefaultData(Vertex vert)
vert
- the vertex for which we will set dataGraphWithData.setDefaultData(cusack.hcg.graph.Vertex)
public void setGraph(Graph graph)
dbGraph
- The database graph that holds the necessary informationpublic void setPuzzle(Puzzle dbPuzzle)
dbPuzzle
- The game object that is passed in that holds the necessary informationpublic final java.lang.String initialPuzzleDataToString()
public final java.lang.String currentPuzzleDataToString()
public void makeCurrentStateInitialState()
public final void stringToPuzzleData(java.lang.String configuration)
configuration
- the string that will be encoded into this puzzle data.public void setSolutionInformation(Solution solution)
solution
- The database class that holds the necessary informationpublic void setSolutionData(java.lang.String data)
data
- the data to setpublic void resetVerticesToInitialLocations()
public void clearHistory()
public void disableHistory()
public void enableHistory()
public int getNumberOfMoves()
public int getDiameter()
public int getNumberOfVertices()
getNumberOfVertices
in interface DrawableGraphProblem
public int getNumberOfEdges()
getNumberOfEdges
in interface DrawableGraphProblem
public java.util.ArrayList<Vertex> getVertices()
getVertices
in interface DrawableGraphProblem
public int getVertexIndex(Vertex v)
getVertexIndex
in interface DrawableGraphProblem
v
- the vertexpublic boolean canUndo()
public boolean canRedo()
public void undo()
public void forceRedo()
public void redo()
public Vertex createNewVertexForPuzzle(java.awt.Point p)
public void addVertex(java.awt.Point coordinates)
public void addGraphWithData(java.awt.Point p, GraphWithData g)
public void addGraph(java.awt.Point p, Graph g)
p
- a point that represents an offset by which the subgraph will be added.g
- the subgraph that will be added.Graph.addSubGraph(java.awt.Point, cusack.hcg.graph.Graph)
public GraphWithData getGraph()
public boolean isTutorial()
isTutorial
in interface DrawableGraphProblem
public void tutorialModeEnabled(boolean b)
b
- the boolean to set isTutorial to.public void convertMovesToTutorial()
public void update(java.util.Observable o, java.lang.Object arg)
update
in interface java.util.Observer
public void checkAndHandlePuzzleCompletion()
public void runAlgorithms()
public void runuTryIt()
public void submit()
public void endGame()
public void startTimer()
public void stopTimer()
public long getTimeTaken()
public void updateTimeTaken()
public void recordGraphEvents()
public void doNotRecordGraphEvents()
public java.lang.String getDescription()
public void setDescription(java.lang.String description)
description
- public java.lang.String getMessage()
public void setMessage(java.lang.String message)
public boolean isInReplayOrEditTutorialMode()
public void setInReplayOrEditTutorialMode(boolean inReplayMode)
inReplayMode
- should be true if we are in replay mode.public void sendMeaninglessEvent()
public void performEvents(java.lang.String events)
events
- the string that has information about the fired eventspublic void performEvents(java.util.ArrayList<Event<?>> eventList)
eventList
- the list of events.public void setLocked(boolean flag)
flag
- true if locked, false otherwisepublic void reallySetLocked(boolean flag)
public boolean isLocked()
public boolean isPlayable()
public void setPlayable(boolean isPlayable)
isPlayable
- should be true if the puzzle is going to be playable.public boolean isFinishable()
public void setFinishable(boolean isLockable)
public boolean isSaved()
public void setSaved(boolean saved)
saved
- the savedpublic void clearAllSelections()
public void removeFromSelected(java.util.ArrayList<Vertex> toClear)
public void removeFromSelected(Vertex v)
public void toggleSelected(Vertex v)
public void addToSelected(java.util.ArrayList<Vertex> verts)
public void selectAll()
public boolean addToSelected(Vertex v)
public int getNumberSelected()
public java.util.ArrayList<Vertex> getSelectedVertices()
public Vertex getFirstSelected()
public void deleteSelected()
public void disconnectSelected()
public void connectAllSelectedVertices()
public void connectToSelected(Vertex vert)
public void disconnectFromSelected(Vertex vert)
public boolean isSpecialCopyOK()
public boolean copyRequested()
public void addDoppelganger(Vertex ganger, java.awt.Point p, int num, boolean connectDoppelToGanger)
public void copySelected()
public void pasteCopyOfSelected(int x, int y)
public void pasteAndConnectCopyOfSelected(int x, int y)
public void moveStarted(java.awt.Point p)
p
- public void moveSelectedVerticesEnded(java.awt.Point p)
p
- public void moveGraphEnded(java.awt.Point p)
p
- public java.lang.String getSolutionAsString()
public void setPersonalBest(int pers)
pers
- The score that will become this user's new personal best scorepublic void setGlobalBest(int global)
global
- The highest score overall for this puzzlepublic int getPersonalBest()
public int getGlobalBest()
public Puzzle.VisibilityType getVisibility()
public java.lang.String getPuzzleName()
public void setPuzzleName(java.lang.String puzzleName)
puzzleName
- the puzzleName to setpublic int getPuzzleID()
public void setPuzzleID(int gameID)
public java.lang.String getAttemptName()
public void setAttemptName(java.lang.String attemptName)
public int getSolutionID()
public void setSolutionID(int solutionID)
public int getMinimumXCoordinate()
public int getMaximumXCoordinate()
public int getMinimumYCoordinate()
public int getMaximumYCoordinate()
public int getMinimumSelectedXCoordinate()
public int getMinimumSelectedYCoordinate()
public boolean isValidToTranslationSelection(java.awt.Point change)
public Solution getSolution()
public int getUserID()
public void setUserID(int userID)
public int computeGlobalPoints()
public TutorialData getTutorialData()
getTutorialData
in interface DrawableGraphProblem
public void clearTutorial()
public boolean performTutorialEvents()
public Solution.Mode getMode()
public void setMode(Solution.Mode mode)
public int getBasePoints()
public int getImprovementBonus()
public int getHighScoreBonus()
public int getFirstTimeBonus()
public int getOldHighScore()
public int getDifficultyLevel()
public boolean isShowIndices()
isShowIndices
in interface DrawableGraphProblem
public void setShowIndices(boolean showIndices)
public java.lang.String getEditorClassName()
public java.lang.String getInstanceClassName()
public java.lang.String getPlayClassName()
public java.lang.String getThemeClassName()
public java.lang.String getHelpClassName()
public java.lang.String getEditHelpClassName()
public java.lang.String getPuzzleInstanceName()
public java.lang.String getEdgeDataClassName()
public java.lang.String getFamilyName()
public java.util.ArrayList<Vertex> getVisibleSources()
getVisibleSources
in interface DrawableGraphProblem
public void setVisibleSources(java.util.ArrayList<Vertex> visibleSource)
public boolean isVisibleSource(Vertex visibleSource)
public boolean isLowerScoreBetter()
public void goToNextEvent()
public void sendAlgorithmResult(boolean r)
public java.lang.String getCurrentAnnotation()
public java.lang.String getCurrentMoveOverview()
public java.util.ArrayList<Vertex> getInterestingTutorialVertices()
public boolean grossHistoryIteratorAtBeginning()
public Event<?> getTopOfUndoStack()
public Event<?> getCurrentUndoableEvent()
public boolean grossHistoryIteratorAtEnd()
public Event<?> grossHistoryGetNextEvent()
public Event<?> grossHistoryNext()
public Event<?> grossHistoryPrevious()
public boolean grossHistoryDeleteLastEvent()
public int grossHistorySize()
public void grossHistoryToBeginning()
public Event<?> grossHistoryGetLastAddedEvent()
public void grossHistoryToEnd()
public int grossHistoryGetNextEventIndex()
public boolean grossHistoryIsSaved()
public void grossHistorySetSaved(boolean saved)