Class PlantCropsAchievement
java.lang.Object
com.csse3200.game.missions.Mission
com.csse3200.game.missions.achievements.Achievement
com.csse3200.game.missions.achievements.PlantCropsAchievement
An
Achievement
completed by planting a certain number of crops on crop tiles.-
Constructor Summary
ConstructorsConstructorDescriptionPlantCropsAchievement
(String name, int numberOfCropsToPlant) Creates aPlantCropsAchievement
. -
Method Summary
Modifier and TypeMethodDescriptionReturns a description of thePlantCropsAchievement
with the name of the achievement and the player's progress.Gives the progress of thePlantCropsAchievement
Gives a short description of thePlantCropsAchievement
showing the player's progress in the achievement.boolean
Returns true if the number of crops the player has planted is greater than or equal to the target number of plants.void
readProgress
(com.badlogic.gdx.utils.JsonValue progress) Reads in the progress of thePlantCropsAchievement
from a JsonValue.void
registerMission
(EventHandler missionManagerEvents) Registers thePlantCropsAchievement
with theMissionManager
by adding a listener to the PLANT_CROPMissionManager.MissionEvent
protected void
updateState
(String ignored) Increments the number of plants the player has planted.Methods inherited from class com.csse3200.game.missions.achievements.Achievement
write
Methods inherited from class com.csse3200.game.missions.Mission
getName, notifyUpdate
-
Constructor Details
-
PlantCropsAchievement
Creates aPlantCropsAchievement
.- Parameters:
name
- The name of thePlantCropsAchievement
numberOfCropsToPlant
- The target number of crops to plant to reach this achievement
-
-
Method Details
-
registerMission
Registers thePlantCropsAchievement
with theMissionManager
by adding a listener to the PLANT_CROPMissionManager.MissionEvent
- Specified by:
registerMission
in classMission
- Parameters:
missionManagerEvents
- A reference to theEventHandler
on theMissionManager
, with which relevant events should be listened to.
-
isCompleted
public boolean isCompleted()Returns true if the number of crops the player has planted is greater than or equal to the target number of plants.- Specified by:
isCompleted
in classMission
- Returns:
- True if the player has planted the target number of plants.
-
getDescription
Returns a description of thePlantCropsAchievement
with the name of the achievement and the player's progress.- Specified by:
getDescription
in classMission
- Returns:
- - the
PlantCropsAchievement
's description
-
getShortDescription
Gives a short description of thePlantCropsAchievement
showing the player's progress in the achievement.- Specified by:
getShortDescription
in classMission
- Returns:
- - short description of the
PlantCropsAchievement
-
readProgress
public void readProgress(com.badlogic.gdx.utils.JsonValue progress) Reads in the progress of thePlantCropsAchievement
from a JsonValue.- Specified by:
readProgress
in classMission
- Parameters:
progress
- TheJsonValue
representing the progress of theMission
as determined by the value returned ingetProgress()
.
-
getProgress
Gives the progress of thePlantCropsAchievement
- Specified by:
getProgress
in classMission
- Returns:
- - the number of crops the player has planted since creation of the
PlantCropsAchievement
.
-
updateState
Increments the number of plants the player has planted.- Parameters:
ignored
- TheString
representation of the plant type. Irrelevant for thisAchievement
.
-