org.mars_sim.msp.core.person.ai.mission
Class Mission

java.lang.Object
  extended by org.mars_sim.msp.core.person.ai.mission.Mission
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BuildingConstructionMission, BuildingSalvageMission, TravelMission

public abstract class Mission
extends Object
implements Serializable

The Mission class represents a large multi-person task There is at most one instance of a mission per person. A Mission may have one or more people associated with it.

See Also:
Serialized Form

Field Summary
static String ADD_MEMBER_EVENT
           
static String ASSOCIATED_SETTLEMENT_EVENT
           
static String CAPACITY_EVENT
           
static String DESCRIPTION_EVENT
           
static String END_MISSION_EVENT
           
static String MIN_PEOPLE_EVENT
           
static String NAME_EVENT
           
static String PHASE_DESCRIPTION_EVENT
           
static String PHASE_EVENT
           
static String REMOVE_MEMBER_EVENT
           
 
Constructor Summary
Mission(String name, Person startingPerson, int minPeople)
          Constructs a Mission object
 
Method Summary
 void addMissionListener(MissionListener newListener)
          Adds a listener
 void addPerson(Person person)
          Adds a person to the mission.
 void addPhase(String newPhase)
          Adds a phase to the mission's collection of phases.
protected  void assignTask(Person person, Task task)
          Adds a new task for a person in the mission.
 void associateAllMembersWithSettlement(Settlement settlement)
          Associate all mission members with a settlement.
 void destroy()
          Prepare object for garbage collection.
protected abstract  void determineNewPhase()
          Determines a new phase for the mission when the current phase has ended.
 void endMission(String reason)
          Finalizes the mission.
protected  void fireMissionUpdate(String updateType)
          Fire a mission update event.
protected  void fireMissionUpdate(String updateType, Object target)
          Fire a mission update event.
abstract  Settlement getAssociatedSettlement()
          Gets the settlement associated with the mission.
 Coordinates getCurrentMissionLocation()
          Gets the current location of the mission.
 String getDescription()
          Gets the mission's description.
abstract  Map<Class,Integer> getEquipmentNeededForRemainingMission(boolean useBuffer)
          Gets the number and types of equipment needed for the mission.
 int getMinPeople()
          Gets the minimum number of people required for mission.
 int getMissionCapacity()
          Gets the mission capacity for participating people.
protected  double getMissionQualification(Person person)
          Gets the mission qualification value for the person.
 String getName()
          Gets the name of the mission.
 Collection<Person> getPeople()
          Gets a collection of the people in the mission.
 int getPeopleNumber()
          Gets the number of people in the mission.
 String getPhase()
          Gets the current phase of the mission.
 String getPhaseDescription()
          Gets the description of the current phase.
 boolean getPhaseEnded()
          Checks if the current phase has ended or not.
abstract  Map<Resource,Number> getResourcesNeededForRemainingMission(boolean useBuffer)
          Gets the number and amounts of resources needed for the mission.
protected  boolean hasDangerousMedicalProblems()
          Checks to see if any of the people in the mission have any dangerous medical problems that require treatment at a settlement.
protected  boolean hasDangerousMedicalProblemsAllCrew()
          Checks to see if all of the people in the mission have any dangerous medical problems that require treatment at a settlement.
protected  boolean hasEmergency()
          Checks if the mission has an emergency situation.
protected  boolean hasEmergencyAllCrew()
          Checks if the mission has an emergency situation affecting all the crew.
 boolean hasPerson(Person person)
          Determines if a mission includes the given person
protected  boolean isCapableOfMission(Person person)
          Checks to see if a person is capable of joining a mission.
 boolean isDone()
          Determines if mission is completed.
 void performMission(Person person)
          Performs the mission.
protected  void performPhase(Person person)
          The person performs the current phase of the mission.
protected  void recruitPeopleForMission(Person startingPerson)
          Recruits new people into the mission.
 void removeMissionListener(MissionListener oldListener)
          Removes a listener
 void removePerson(Person person)
          Removes a person from the mission
 void setDescription(String description)
          Sets the mission's description.
protected  void setMinPeople(int minPeople)
          Sets the minimum number of people required for a mission.
protected  void setMissionCapacity(int newCapacity)
          Sets the mission capacity to a given value.
protected  void setName(String name)
          Sets the name of the mission.
protected  void setPhase(String newPhase)
          Sets the mission phase.
protected  void setPhaseDescription(String description)
          Sets the description of the current phase.
protected  void setPhaseEnded(boolean phaseEnded)
          Sets if the current phase has ended or not.
 void timePassing(double time)
          Time passing for mission.
 String toString()
          Gets the string representation of this mission.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME_EVENT

public static final String NAME_EVENT
See Also:
Constant Field Values

DESCRIPTION_EVENT

public static final String DESCRIPTION_EVENT
See Also:
Constant Field Values

PHASE_EVENT

public static final String PHASE_EVENT
See Also:
Constant Field Values

PHASE_DESCRIPTION_EVENT

public static final String PHASE_DESCRIPTION_EVENT
See Also:
Constant Field Values

MIN_PEOPLE_EVENT

public static final String MIN_PEOPLE_EVENT
See Also:
Constant Field Values

ASSOCIATED_SETTLEMENT_EVENT

public static final String ASSOCIATED_SETTLEMENT_EVENT
See Also:
Constant Field Values

CAPACITY_EVENT

public static final String CAPACITY_EVENT
See Also:
Constant Field Values

ADD_MEMBER_EVENT

public static final String ADD_MEMBER_EVENT
See Also:
Constant Field Values

REMOVE_MEMBER_EVENT

public static final String REMOVE_MEMBER_EVENT
See Also:
Constant Field Values

END_MISSION_EVENT

public static final String END_MISSION_EVENT
See Also:
Constant Field Values
Constructor Detail

Mission

public Mission(String name,
               Person startingPerson,
               int minPeople)
Constructs a Mission object

Parameters:
name - the name of the mission
startingPerson - the person starting the mission.
minPeople - the minimum number of people required for mission.
Throws:
MissionException - if error constructing mission.
Method Detail

addMissionListener

public final void addMissionListener(MissionListener newListener)
Adds a listener

Parameters:
newListener - the listener to add.

removeMissionListener

public final void removeMissionListener(MissionListener oldListener)
Removes a listener

Parameters:
oldListener - the listener to remove.

fireMissionUpdate

protected final void fireMissionUpdate(String updateType)
Fire a mission update event.

Parameters:
updateType - the update type.

fireMissionUpdate

protected final void fireMissionUpdate(String updateType,
                                       Object target)
Fire a mission update event.

Parameters:
updateType - the update type.
target - the event target or null if none.

toString

public String toString()
Gets the string representation of this mission.

Overrides:
toString in class Object

addPerson

public final void addPerson(Person person)
Adds a person to the mission.

Parameters:
person - to be added

removePerson

public final void removePerson(Person person)
Removes a person from the mission

Parameters:
person - to be removed

hasPerson

public final boolean hasPerson(Person person)
Determines if a mission includes the given person

Parameters:
person - person to be checked
Returns:
true if person is member of mission

getPeopleNumber

public final int getPeopleNumber()
Gets the number of people in the mission.

Returns:
number of people

getMinPeople

public final int getMinPeople()
Gets the minimum number of people required for mission.

Returns:
minimum number of people

setMinPeople

protected final void setMinPeople(int minPeople)
Sets the minimum number of people required for a mission.

Parameters:
minPeople - minimum number of people

getPeople

public final Collection<Person> getPeople()
Gets a collection of the people in the mission.

Returns:
collection of people

isDone

public final boolean isDone()
Determines if mission is completed.

Returns:
true if mission is completed

getName

public final String getName()
Gets the name of the mission.

Returns:
name of mission

setName

protected final void setName(String name)
Sets the name of the mission.

Parameters:
name - the new mission name

getDescription

public final String getDescription()
Gets the mission's description.

Returns:
mission description

setDescription

public final void setDescription(String description)
Sets the mission's description.

Parameters:
description - the new description.

getPhase

public final String getPhase()
Gets the current phase of the mission.

Returns:
phase

setPhase

protected final void setPhase(String newPhase)
Sets the mission phase.

Parameters:
newPhase - the new mission phase.
Throws:
MissionException - if newPhase is not in the mission's collection of phases.

addPhase

public final void addPhase(String newPhase)
Adds a phase to the mission's collection of phases.

Parameters:
newPhase - the new phase to add.

getPhaseDescription

public final String getPhaseDescription()
Gets the description of the current phase.

Returns:
phase description.

setPhaseDescription

protected final void setPhaseDescription(String description)
Sets the description of the current phase.

Parameters:
description - the phase description.

performMission

public void performMission(Person person)
Performs the mission.

Parameters:
person - the person performing the mission.
Throws:
MissionException - if problem performing the mission.

determineNewPhase

protected abstract void determineNewPhase()
Determines a new phase for the mission when the current phase has ended.

Throws:
MissionException - if problem setting a new phase.

performPhase

protected void performPhase(Person person)
The person performs the current phase of the mission.

Parameters:
person - the person performing the phase.
Throws:
MissionException - if problem performing the phase.

getMissionCapacity

public final int getMissionCapacity()
Gets the mission capacity for participating people.

Returns:
mission capacity

setMissionCapacity

protected final void setMissionCapacity(int newCapacity)
Sets the mission capacity to a given value.

Parameters:
newCapacity - the new mission capacity

endMission

public void endMission(String reason)
Finalizes the mission. String reason Reason for ending mission. Mission can override this to perform necessary finalizing operations.


assignTask

protected void assignTask(Person person,
                          Task task)
Adds a new task for a person in the mission. Task may be not assigned if it is effort-driven and person is too ill to perform it.

Parameters:
person - the person to assign to the task
task - the new task to be assigned

hasDangerousMedicalProblems

protected final boolean hasDangerousMedicalProblems()
Checks to see if any of the people in the mission have any dangerous medical problems that require treatment at a settlement. Also any environmental problems, such as suffocation.

Returns:
true if dangerous medical problems

hasDangerousMedicalProblemsAllCrew

protected final boolean hasDangerousMedicalProblemsAllCrew()
Checks to see if all of the people in the mission have any dangerous medical problems that require treatment at a settlement. Also any environmental problems, such as suffocation.

Returns:
true if all have dangerous medical problems

hasEmergency

protected boolean hasEmergency()
Checks if the mission has an emergency situation.

Returns:
true if emergency.

hasEmergencyAllCrew

protected boolean hasEmergencyAllCrew()
Checks if the mission has an emergency situation affecting all the crew.

Returns:
true if emergency affecting all.

recruitPeopleForMission

protected void recruitPeopleForMission(Person startingPerson)
Recruits new people into the mission.

Parameters:
startingPerson - the person starting the mission.

isCapableOfMission

protected boolean isCapableOfMission(Person person)
Checks to see if a person is capable of joining a mission.

Parameters:
person - the person to check.
Returns:
true if person could join mission.

getMissionQualification

protected double getMissionQualification(Person person)
Gets the mission qualification value for the person. Person is qualified and interested in joining the mission if the value is larger than 0. The larger the qualification value, the more likely the person will be picked for the mission.

Parameters:
person - the person to check.
Returns:
mission qualification value.
Throws:
MissionException - if error determining mission qualification.

getPhaseEnded

public final boolean getPhaseEnded()
Checks if the current phase has ended or not.

Returns:
true if phase has ended

setPhaseEnded

protected final void setPhaseEnded(boolean phaseEnded)
Sets if the current phase has ended or not.

Parameters:
phaseEnded - true if phase has ended

getAssociatedSettlement

public abstract Settlement getAssociatedSettlement()
Gets the settlement associated with the mission.

Returns:
settlement or null if none.

getResourcesNeededForRemainingMission

public abstract Map<Resource,Number> getResourcesNeededForRemainingMission(boolean useBuffer)
Gets the number and amounts of resources needed for the mission.

Parameters:
useBuffer - use time buffers in estimation if true.
Returns:
map of amount and item resources and their Double amount or Integer number.

getEquipmentNeededForRemainingMission

public abstract Map<Class,Integer> getEquipmentNeededForRemainingMission(boolean useBuffer)
Gets the number and types of equipment needed for the mission.

Parameters:
useBuffer - use time buffers in estimation if true.
Returns:
map of equipment class and Integer number.

timePassing

public void timePassing(double time)
Time passing for mission.

Parameters:
time - the amount of time passing (in millisols)
Throws:
Exception - if error during time passing.

associateAllMembersWithSettlement

public void associateAllMembersWithSettlement(Settlement settlement)
Associate all mission members with a settlement.

Parameters:
settlement - the associated settlement.

getCurrentMissionLocation

public final Coordinates getCurrentMissionLocation()
Gets the current location of the mission.

Returns:
coordinate location.
Throws:
MissionException - if error determining location.

destroy

public void destroy()
Prepare object for garbage collection.



Copyright © 2009-2013. All Rights Reserved.