Package com.csse3200.game.missions
Class Mission
java.lang.Object
com.csse3200.game.missions.Mission
- Direct Known Subclasses:
Achievement,Quest
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringgetName()abstract Objectabstract Stringabstract booleanReturns a boolean value representing whether theMissionhas been completed.voidNotifies theMissionManagerthat thisMissionhas been completed ifisCompleted()returns true, else do nothing.abstract voidreadProgress(com.badlogic.gdx.utils.JsonValue progress) Sets the internal progress of theMissionbased on theJsonValueprovided.abstract voidregisterMission(EventHandler missionManagerEvents) Registers theMissionto theMissionManager, by adding all event listeners to the service which theMissionneeds to listen to in order to update its state.
-
Constructor Details
-
Method Details
-
getName
-
registerMission
Registers theMissionto theMissionManager, by adding all event listeners to the service which theMissionneeds to listen to in order to update its state.- Parameters:
missionManagerEvents- A reference to theEventHandleron theMissionManager, with which relevant events should be listened to.
-
isCompleted
public abstract boolean isCompleted()Returns a boolean value representing whether theMissionhas been completed.- Returns:
- A boolean value representing whether the
Missionhas been completed.
-
getDescription
Returns aStringdescription of theMission. This can involve an explanation of what the player needs to do to complete theMission, and may dynamically change depending on the progress the player has made. For instance, you might choose to include in your description: "You have currently harvested X out of N plants". -
getShortDescription
Returns a shortStringdescription of theMission. This description should be at most around 50 characters. This might simply contain progress information on theMission, or a shortened form ofgetDescription(). -
notifyUpdate
public void notifyUpdate()Notifies theMissionManagerthat thisMissionhas been completed ifisCompleted()returns true, else do nothing. You should call this method whenever you update the state of yourMission. If the event has already been triggered on theMissionManagerfor thisMission, it will not re-trigger the event, unless this method detects theMissionhaving become incomplete. -
readProgress
public abstract void readProgress(com.badlogic.gdx.utils.JsonValue progress) Sets the internal progress of theMissionbased on theJsonValueprovided. TheJsonValueprovided should match the sameJsonValue.ValueTypereturned bygetProgress(). AnExceptionmight be raised otherwise (depending on the methods you use to get the state of theJsonValue).- Parameters:
progress- TheJsonValuerepresenting the progress of theMissionas determined by the value returned ingetProgress().
-
getProgress
Gets the progress of theMissionas anObject, which contains all relevant information about the internal progress of theMission. All stats which dynamically change should be stored in thisObjectin some way (i.e., all non-final values). Since this value will need to be read later usingreadProgress(JsonValue)as aJsonValue, you should make sure the returnedObject's serialisation is known to you. This is easy for primitive types, lists, and maps, so try to make the data that you actively track of primitive type (or a list/map of primitive types). Note that forQuests, you do not need to store the time to expiry or whether the reward has been collected - you only need to store the changing state specific to theQuest.- Returns:
- An
Object, which stores the internal progress of theMission. ThisObjectshould be serialisable, and the data should be able to be read as aJsonValueinreadProgress(JsonValue).
-