public class Goal extends java.lang.Object implements RouteListener
Constructor and Description |
---|
Goal(org.json.simple.JSONObject goalJSON) |
Goal(Station startStation,
Station finalStation,
int noOfStations,
java.lang.String cargo,
int reward)
Initializes the goal.
|
Modifier and Type | Method and Description |
---|---|
void |
assignTrain(Train train)
Assigns a goal to a train and registers listeners
|
int |
calculatePoints()
Used to calculate how many points to add to a player's score upon completion of goal
EstimateOptimalDuration = how many turns it would take train to travel goal's optimal route at base speed
CurrentGoalDuration = how many turns it actually took the train
reward = length of optimal journey
|
int |
estimateOptimalDuration()
Used to estimate how many turns it would take the train (assigned to the goal) to travel the goal's optimal route at its base speed
|
java.lang.String |
getCargo() |
int |
getCurrentGoalDuration() |
java.lang.String |
getFStation() |
Station |
getFStationObject() |
int |
getReward() |
java.lang.String |
getSStation() |
Station |
getSStationObject() |
java.lang.String |
getStartDate() |
int |
getTimeConstraint() |
java.lang.String |
getTimeConstraintString()
Returns the number of stations a player ha to pass through.
|
Train |
getTrain() |
java.lang.Boolean |
goalComplete()
Called when the goal is successfully complete
|
void |
goalFailed()
Called when the goal is failed (only quantifiable goals can be failed)
|
void |
incrementCurrentGoalDuration()
Should be called at the end of each turn
|
boolean |
isAbsolute() |
boolean |
isQuantifiable() |
boolean |
isSpecial() |
void |
setActor(GoalActor actor) |
void |
setSpecial(boolean special) |
void |
setTimeConstraint(int timeConstraint) |
void |
stationPassed(Station station,
Train train)
Listener trigger when a train passes a station
|
java.lang.String |
toJSON() |
public static GoalActor goalActor
public Goal(org.json.simple.JSONObject goalJSON)
public Goal(Station startStation, Station finalStation, int noOfStations, java.lang.String cargo, int reward)
startStation
- The Station the goal starts fromfinalStation
- The Station the goal ends atnoOfStations
- The maximum number of station the train should pass.
Value 0 means there is no time constraint.cargo
- The type of cargo the train is carrying. (Currently not used)reward
- The reward (currently Gold) you get for completing the Goalpublic java.lang.String toJSON()
public boolean isSpecial()
public java.lang.String getSStation()
public Station getSStationObject()
public java.lang.String getFStation()
public Station getFStationObject()
public int getReward()
public java.lang.String getStartDate()
public void setActor(GoalActor actor)
public java.lang.String getCargo()
public void assignTrain(Train train)
train
- The train to assign topublic Train getTrain()
public java.lang.Boolean goalComplete()
public void goalFailed()
public void stationPassed(Station station, Train train)
stationPassed
in interface RouteListener
public void setSpecial(boolean special)
public int getCurrentGoalDuration()
public void incrementCurrentGoalDuration()
public int calculatePoints()
public int estimateOptimalDuration()
public boolean isQuantifiable()
public boolean isAbsolute()
public java.lang.String getTimeConstraintString()
public int getTimeConstraint()
public void setTimeConstraint(int timeConstraint)