Class Scenario
- All Implemented Interfaces:
IPlayerSettings
- Direct Known Subclasses:
AtBScenario
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected megamek.common.planetaryConditions.Atmosphereprotected megamek.common.planetaryConditions.AtmosphericTaintLists of enemy forcesprotected List<BotForceStub> protected megamek.common.planetaryConditions.Fogprotected floatprotected megamek.common.planetaryConditions.Lightplanetary conditions parametersstatic final intstatic final intstatic final intstatic final intprotected megamek.common.planetaryConditions.Weatherprotected megamek.common.planetaryConditions.Wind -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBotForce(BotForce botForce, Campaign c) voidaddForces(int fid) voidvoidaddPlayerTransportRelationship(UUID transportId, UUID cargoId) Adds a transport-cargo pair to the internal transport relationship store.voidaddSalvageFormation(int forceId) voidaddSalvageTech(UUID personId) voidbooleanDetermines whether a unit is eligible to deploy to the scenario.booleancanDeployForces(Vector<Formation> formations, Campaign c) Determines whether a list of forces is eligible to deploy to the scenario.booleancanDeployUnits(Vector<Unit> units, Campaign campaign) Determines whether a list of units is eligible to deploy to the scenario.booleanDetermines whether this scenario is ready for deployment preparation: it is current, has a deployed force, and meets its required personnel and unit constraints.booleanDetermines whether this scenario can be started now.booleanbooleanvoidclearAllFormationsAndPersonnel(Campaign campaign) voidvoidbooleancontainsPlayerUnit(UUID uid) voidconvertToStub(Campaign campaign, ScenarioStatus status) Converts this scenario to a stubmegamek.common.planetaryConditions.PlanetaryConditionsCreate a PlanetaryConditions object from variablesstatic ScenariogenerateInstanceFromXML(Node wn, Campaign c, megamek.Version version) voidmegamek.common.planetaryConditions.Atmospheremegamek.common.planetaryConditions.AtmosphericTaintmegamek.common.planetaryConditions.BlowingSandintstatic StringgetBoardTypeName(int i) getBotForce(int i) getDate()megamek.common.planetaryConditions.EMIgetEMI()getEntityStub(Node wn) megamek.common.planetaryConditions.FoggetFog()floatbooleanReturns the name of this object as an HTML hyperlink.intgetId()Gets the IDs of units deployed to this scenario individually.megamek.common.planetaryConditions.LightgetLight()intgetLoot()getMap()intintmegamek.common.planetaryConditions.Windmegamek.common.planetaryConditions.WindgetName()intintintintintintintintdoubleintGet a List of all traitor Units in this scenario.megamek.common.planetaryConditions.Weathermegamek.common.planetaryConditions.WindgetWind()booleanbooleanbooleanbooleanisAssigned(Unit unit, Campaign campaign) booleanThis indicates that the scenario should not be displayed in the briefing tab.booleanisCrisis()booleanisFriendlyUnit(megamek.common.units.Entity entity, Campaign campaign) booleanbooleanbooleanGiven a Person's id, is that person a traitor in this ScenariobooleanTests whether a given entity is a traitor in this Scenario by checking external id values.booleanprotected voidloadFieldsFromXmlNode(Node wn, megamek.Version version, Campaign campaign) voidreadPlanetaryConditions(megamek.common.planetaryConditions.PlanetaryConditions planetaryConditions) Read the values from a PlanetaryConditions object into the Scenario variables for planetary conditions.voidremoveBotForce(int i) voidremoveFormation(int fid) voidremoveSalvageFormation(List<Integer> forceIds) voidremoveSalvageTechs(List<UUID> personIds) voidremoveUnit(UUID uid) voidvoidsetAtmosphere(megamek.common.planetaryConditions.Atmosphere atmosphere) voidsetAtmosphericTaint(megamek.common.planetaryConditions.AtmosphericTaint atmosphericTaint) voidsetBlowingSand(megamek.common.planetaryConditions.BlowingSand blow) voidsetBoardType(int boardType) voidsetBotForces(List<BotForce> bf) voidsetCloaked(boolean cloaked) voidvoidvoidvoidsetEMI(megamek.common.planetaryConditions.EMI emi) voidsetExternalIDLookup(HashMap<String, megamek.common.units.Entity> externalIDLookup) Deprecated, for removal: This API element is subject to removal in a future version.voidsetFog(megamek.common.planetaryConditions.Fog fog) voidsetGravity(float gravity) voidsetHasTrack(boolean b) voidsetId(int i) voidsetIsCrisis(boolean isCrisis) voidsetLight(megamek.common.planetaryConditions.Light light) voidsetLinkedScenarioID(int ScenarioID) voidvoidsetMapSizeX(int mapSizeX) voidsetMapSizeY(int mapSizeY) voidsetMaxWindStrength(megamek.common.planetaryConditions.Wind strength) voidsetMinWindStrength(megamek.common.planetaryConditions.Wind strength) voidsetMissionId(UUID i) voidvoidvoidsetScenarioObjectives(List<ScenarioObjective> scenarioObjectives) voidsetShiftWindDirection(boolean b) voidsetShiftWindStrength(boolean b) voidsetStartingAnyNWx(int startingAnyNWx) voidsetStartingAnyNWy(int startingAnyNWy) voidsetStartingAnySEx(int startingAnySEx) voidsetStartingAnySEy(int startingAnySEy) voidsetStartingPos(int start) voidsetStartOffset(int startOffset) voidsetStartWidth(int startWidth) voidsetStatus(ScenarioStatus status) voidsetStratConRoadEntryEdges(List<Integer> stratConRoadEntryEdges) voidvoidsetStratConUrban(boolean stratConUrban) voidsetStratConUrbanization(double stratConUrbanization) voidsetStratConWaterAdjacent(boolean stratConWaterAdjacent) voidsetTemperature(int temperature) voidsetUsingFixedMap(boolean usingFixedMap) voidsetWeather(megamek.common.planetaryConditions.Weather weather) voidsetWind(megamek.common.planetaryConditions.Wind wind) voidwriteToXML(PrintWriter pw, int indent) protected intwriteToXMLBegin(PrintWriter pw, int indent) protected voidwriteToXMLEnd(PrintWriter pw, int indent)
-
Field Details
-
S_DEFAULT_ID
public static final int S_DEFAULT_ID- See Also:
-
T_GROUND
public static final int T_GROUND- See Also:
-
T_ATMOSPHERE
public static final int T_ATMOSPHERE- See Also:
-
T_SPACE
public static final int T_SPACE- See Also:
-
botForces
Lists of enemy forces -
botForcesStubs
-
light
protected megamek.common.planetaryConditions.Light lightplanetary conditions parameters -
weather
protected megamek.common.planetaryConditions.Weather weather -
wind
protected megamek.common.planetaryConditions.Wind wind -
fog
protected megamek.common.planetaryConditions.Fog fog -
atmosphere
protected megamek.common.planetaryConditions.Atmosphere atmosphere -
atmosphericTaint
protected megamek.common.planetaryConditions.AtmosphericTaint atmosphericTaint -
gravity
protected float gravity
-
-
Constructor Details
-
Scenario
public Scenario() -
Scenario
-
-
Method Details
-
getName
-
getHyperlinkedName
Returns the name of this object as an HTML hyperlink.The hyperlink is formatted with a "SCENARIO:" protocol prefix followed by the object's ID. This allows UI components that support HTML to render the name as a clickable link, which can be used to navigate to or focus on this specific object when clicked.
- Returns:
- An HTML formatted string containing the object's name as a hyperlink with its ID
- Since:
- 0.50.05
-
setName
-
getStratConScenarioType
-
setStratConScenarioType
-
getDescription
-
setDesc
-
getReport
-
setReport
-
getStatus
-
setStatus
-
isCrisis
public boolean isCrisis() -
setIsCrisis
public void setIsCrisis(boolean isCrisis) -
getDate
-
setDate
-
getLinkedScenario
public int getLinkedScenario() -
setLinkedScenarioID
public void setLinkedScenarioID(int ScenarioID) -
hasObjectives
public boolean hasObjectives() -
getScenarioObjectives
-
setScenarioObjectives
-
isCloaked
public boolean isCloaked()This indicates that the scenario should not be displayed in the briefing tab. -
setCloaked
public void setCloaked(boolean cloaked) -
getStartingPos
public int getStartingPos()- Specified by:
getStartingPosin interfaceIPlayerSettings
-
setStartingPos
public void setStartingPos(int start) - Specified by:
setStartingPosin interfaceIPlayerSettings
-
getStartOffset
public int getStartOffset()- Specified by:
getStartOffsetin interfaceIPlayerSettings
-
setStartOffset
public void setStartOffset(int startOffset) - Specified by:
setStartOffsetin interfaceIPlayerSettings
-
getStartWidth
public int getStartWidth()- Specified by:
getStartWidthin interfaceIPlayerSettings
-
setStartWidth
public void setStartWidth(int startWidth) - Specified by:
setStartWidthin interfaceIPlayerSettings
-
getStartingAnyNWx
public int getStartingAnyNWx()- Specified by:
getStartingAnyNWxin interfaceIPlayerSettings
-
setStartingAnyNWx
public void setStartingAnyNWx(int startingAnyNWx) - Specified by:
setStartingAnyNWxin interfaceIPlayerSettings
-
getStartingAnyNWy
public int getStartingAnyNWy()- Specified by:
getStartingAnyNWyin interfaceIPlayerSettings
-
setStartingAnyNWy
public void setStartingAnyNWy(int startingAnyNWy) - Specified by:
setStartingAnyNWyin interfaceIPlayerSettings
-
getStartingAnySEx
public int getStartingAnySEx()- Specified by:
getStartingAnySExin interfaceIPlayerSettings
-
setStartingAnySEx
public void setStartingAnySEx(int startingAnySEx) - Specified by:
setStartingAnySExin interfaceIPlayerSettings
-
getStartingAnySEy
public int getStartingAnySEy()- Specified by:
getStartingAnySEyin interfaceIPlayerSettings
-
setStartingAnySEy
public void setStartingAnySEy(int startingAnySEy) - Specified by:
setStartingAnySEyin interfaceIPlayerSettings
-
setBoardType
public void setBoardType(int boardType) -
getBoardType
public int getBoardType() -
getMapSizeX
public int getMapSizeX() -
setMapSizeX
public void setMapSizeX(int mapSizeX) -
getMapSizeY
public int getMapSizeY() -
setMapSizeY
public void setMapSizeY(int mapSizeY) -
getMap
-
setMap
-
getMapForDisplay
-
isUsingFixedMap
public boolean isUsingFixedMap() -
setUsingFixedMap
public void setUsingFixedMap(boolean usingFixedMap) -
getLight
public megamek.common.planetaryConditions.Light getLight() -
setLight
public void setLight(megamek.common.planetaryConditions.Light light) -
getWeather
public megamek.common.planetaryConditions.Weather getWeather() -
setWeather
public void setWeather(megamek.common.planetaryConditions.Weather weather) -
getWind
public megamek.common.planetaryConditions.Wind getWind() -
setWind
public void setWind(megamek.common.planetaryConditions.Wind wind) -
getFog
public megamek.common.planetaryConditions.Fog getFog() -
setFog
public void setFog(megamek.common.planetaryConditions.Fog fog) -
getAtmosphere
public megamek.common.planetaryConditions.Atmosphere getAtmosphere() -
setAtmosphere
public void setAtmosphere(megamek.common.planetaryConditions.Atmosphere atmosphere) -
getAtmosphericTaint
public megamek.common.planetaryConditions.AtmosphericTaint getAtmosphericTaint()- Returns:
- how safe the air is to breathe where this scenario is fought, never
null
-
setAtmosphericTaint
public void setAtmosphericTaint(@Nullable megamek.common.planetaryConditions.AtmosphericTaint atmosphericTaint) - Parameters:
atmosphericTaint- the air to fight this scenario in, ornullfor breathable air. A scenario always has some air recorded, becausewriteToXML(java.io.PrintWriter, int)asks it for the name to save.
-
getTemperature
public int getTemperature() -
setTemperature
public void setTemperature(int temperature) -
getGravity
public float getGravity() -
setGravity
public void setGravity(float gravity) -
setEMI
public void setEMI(megamek.common.planetaryConditions.EMI emi) -
getEMI
public megamek.common.planetaryConditions.EMI getEMI() -
setBlowingSand
public void setBlowingSand(megamek.common.planetaryConditions.BlowingSand blow) -
getBlowingSand
public megamek.common.planetaryConditions.BlowingSand getBlowingSand() -
canWindShiftDirection
public boolean canWindShiftDirection() -
setShiftWindDirection
public void setShiftWindDirection(boolean b) -
canWindShiftStrength
public boolean canWindShiftStrength() -
setShiftWindStrength
public void setShiftWindStrength(boolean b) -
getMaxWindStrength
public megamek.common.planetaryConditions.Wind getMaxWindStrength() -
setMaxWindStrength
public void setMaxWindStrength(megamek.common.planetaryConditions.Wind strength) -
getMinWindStrength
public megamek.common.planetaryConditions.Wind getMinWindStrength() -
setMinWindStrength
public void setMinWindStrength(megamek.common.planetaryConditions.Wind strength) -
createPlanetaryConditions
public megamek.common.planetaryConditions.PlanetaryConditions createPlanetaryConditions()Create a PlanetaryConditions object from variables- Returns:
- PlanetaryConditions object
-
readPlanetaryConditions
public void readPlanetaryConditions(megamek.common.planetaryConditions.PlanetaryConditions planetaryConditions) Read the values from a PlanetaryConditions object into the Scenario variables for planetary conditions. This is necessary because MekHQ has XML and MegaMek doesn't.- Parameters:
planetaryConditions- A PlanetaryConditions object
-
getDeploymentLimit
-
setDeploymentLimit
-
getPlayerTransportLinkages
-
addPlayerTransportRelationship
Adds a transport-cargo pair to the internal transport relationship store.- Parameters:
transportId- the UUID of the transport objectcargoId- the UUID of the cargo being transported
-
getId
public int getId() -
setId
public void setId(int i) -
getMissionId
-
setMissionId
-
getForceIDs
-
getForces
-
getSalvageFormations
-
removeSalvageFormation
-
addSalvageFormation
public void addSalvageFormation(int forceId) -
clearSalvageFormations
public void clearSalvageFormations() -
getSalvageTechs
-
addSalvageTech
-
removeSalvageTechs
-
clearSalvageTechs
public void clearSalvageTechs() -
getIndividualUnitIDs
Gets the IDs of units deployed to this scenario individually. -
addForces
public void addForces(int fid) -
addUnit
-
containsPlayerUnit
-
removeUnit
-
removeFormation
public void removeFormation(int fid) -
clearAllFormationsAndPersonnel
-
convertToStub
Converts this scenario to a stub -
generateStub
-
getForceStub
-
isAssigned
-
getBotForces
-
setBotForces
-
addBotForce
-
getBotForce
-
removeBotForce
public void removeBotForce(int i) -
getNumBots
public int getNumBots() -
getBotForcesStubs
-
getTraitorUnits
Get a List of all traitor Units in this scenario. This function just combines the results from BotForce#getTraitorUnits across all BotForces.- Parameters:
c- - A Campaign pointer- Returns:
- a List of traitor Units
-
isTraitor
Tests whether a given entity is a traitor in this Scenario by checking external id values. This should also be usable against entities that are ejected pilots from the original traitor entity.- Parameters:
en- a MegaMek Entityc- a Campaign pointer- Returns:
- a boolean indicating whether this entity is a traitor in this Scenario.
-
isTraitor
Given a Person's id, is that person a traitor in this Scenario- Parameters:
personId- - a UUID giving a person's id in the campaign- Returns:
- a boolean indicating if this person is a traitor in the Scenario
-
getExternalIDLookup
-
setExternalIDLookup
@Deprecated(since="0.51.0", forRemoval=true) public void setExternalIDLookup(HashMap<String, megamek.common.units.Entity> externalIDLookup) Deprecated, for removal: This API element is subject to removal in a future version. -
canDeploy
Determines whether a unit is eligible to deploy to the scenario. If a ScenarioDeploymentLimit is present the unit type will be checked to make sure it is valid. The function also checks to see if the unit is a traitor unit which will disallow deployment.- Parameters:
unit- - The Unit to be deployedcampaign- - a pointer to the Campaign- Returns:
- true if the unit is eligible, otherwise false
-
canDeployUnits
Determines whether a list of units is eligible to deploy to the scenario.- Parameters:
units- - a Vector made up of Units to be deployedcampaign- - a pointer to the Campaign- Returns:
- true if all units in the list are eligible, otherwise false
-
canDeployForces
Determines whether a list of forces is eligible to deploy to the scenario.- Parameters:
formations- list of forcesc- the campaign that the forces are part of- Returns:
- true if all units in all forces in the list are eligible, otherwise false
-
includesRequiredPersonnel
-
includesRequiredUnits
-
canStartScenario
Determines whether this scenario can be started now. The base implementation applies only the readiness checks incanPrepareScenario(Campaign); subclasses may override it to impose additional restrictions, such as requiring the current date to match the scenario's scheduled date (seeAtBScenario).- Parameters:
c- the campaign this scenario belongs to- Returns:
trueif the scenario can be started
-
canPrepareScenario
Determines whether this scenario is ready for deployment preparation: it is current, has a deployed force, and meets its required personnel and unit constraints.This readiness check intentionally excludes any date-based restriction. In the base
ScenarioimplementationcanStartScenario(Campaign)simply delegates to this method, but subclasses such asAtBScenariomay overridecanStartScenarioto additionally require that the scenario be launched on its scheduled date. BecausecanPrepareScenarionever applies such a restriction, it is suitable for gating preparation actions (adjusting the deployment, exporting or printing the assigned force) that players should be able to perform ahead of the scenario's date.- Parameters:
c- the campaign this scenario belongs to- Returns:
trueif the scenario is current and its deployment requirements are met
-
writeToXML
-
writeToXMLBegin
-
writeToXMLEnd
-
loadFieldsFromXmlNode
protected void loadFieldsFromXmlNode(Node wn, megamek.Version version, Campaign campaign) throws ParseException - Throws:
ParseException
-
generateInstanceFromXML
-
getEntityStub
-
getLoot
-
addLoot
-
resetLoot
public void resetLoot() -
isFriendlyUnit
-
getHasTrack
public boolean getHasTrack() -
setHasTrack
public void setHasTrack(boolean b) -
getStratConRoadEntryEdges
- Returns:
- the hex directions (0-5) in which a StratCon sector road leaves this scenario's hex; empty when the scenario is not on a road
-
setStratConRoadEntryEdges
-
isStratConWaterAdjacent
public boolean isStratConWaterAdjacent()- Returns:
trueif this StratCon scenario's hex borders open water (coast, lakeshore, or riverbank)
-
setStratConWaterAdjacent
public void setStratConWaterAdjacent(boolean stratConWaterAdjacent) -
isStratConUrban
public boolean isStratConUrban()- Returns:
trueif this StratCon scenario's hex holds a city (which overlays any base terrain)
-
setStratConUrban
public void setStratConUrban(boolean stratConUrban) -
getStratConUrbanization
public double getStratConUrbanization()- Returns:
- how built-up this StratCon scenario's city is, 0.0 (hamlet) to 1.0 (dense metropolis); only meaningful
when
isStratConUrban()istrue
-
setStratConUrbanization
public void setStratConUrbanization(double stratConUrbanization) -
getBoardTypeName
-