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 String
getName()
abstract Object
abstract String
abstract boolean
Returns a boolean value representing whether theMission
has been completed.void
Notifies theMissionManager
that thisMission
has been completed ifisCompleted()
returns true, else do nothing.abstract void
readProgress
(com.badlogic.gdx.utils.JsonValue progress) Sets the internal progress of theMission
based on theJsonValue
provided.abstract void
registerMission
(EventHandler missionManagerEvents) Registers theMission
to theMissionManager
, by adding all event listeners to the service which theMission
needs to listen to in order to update its state.
-
Constructor Details
-
Method Details
-
getName
-
registerMission
Registers theMission
to theMissionManager
, by adding all event listeners to the service which theMission
needs to listen to in order to update its state.- Parameters:
missionManagerEvents
- A reference to theEventHandler
on theMissionManager
, with which relevant events should be listened to.
-
isCompleted
public abstract boolean isCompleted()Returns a boolean value representing whether theMission
has been completed.- Returns:
- A boolean value representing whether the
Mission
has been completed.
-
getDescription
Returns aString
description 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 shortString
description 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 theMissionManager
that thisMission
has 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 theMissionManager
for thisMission
, it will not re-trigger the event, unless this method detects theMission
having become incomplete. -
readProgress
public abstract void readProgress(com.badlogic.gdx.utils.JsonValue progress) Sets the internal progress of theMission
based on theJsonValue
provided. TheJsonValue
provided should match the sameJsonValue.ValueType
returned bygetProgress()
. AnException
might be raised otherwise (depending on the methods you use to get the state of theJsonValue
).- Parameters:
progress
- TheJsonValue
representing the progress of theMission
as determined by the value returned ingetProgress()
.
-
getProgress
Gets the progress of theMission
as anObject
, which contains all relevant information about the internal progress of theMission
. All stats which dynamically change should be stored in thisObject
in 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 forQuest
s, 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
. ThisObject
should be serialisable, and the data should be able to be read as aJsonValue
inreadProgress(JsonValue)
.
-