Package mekhq.campaign.parts
Class Refit
java.lang.Object
mekhq.campaign.parts.Part
mekhq.campaign.parts.Refit
- All Implemented Interfaces:
megamek.common.ITechnology
,IAcquisitionWork
,IPartWork
,IWork
This object tracks the refit of a given unit into a new unit. It has fields for the current entity and the new
entity, and it uses these to calculate various characteristics of the refit.
It can then also be used to track the actual refit process, by attaching it to a Unit.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Proxy Armor that references a certain IDstatic class
Proxy Part that references a certain ID.static class
Proxy Person that references a specific IDNested classes/interfaces inherited from class mekhq.campaign.parts.Part
Part.PartPersonRef, Part.PartRef, Part.PartUnitRef
Nested classes/interfaces inherited from interface megamek.common.ITechnology
megamek.common.ITechnology.AvailabilityValue, megamek.common.ITechnology.Era, megamek.common.ITechnology.Faction, megamek.common.ITechnology.FactionAffiliation, megamek.common.ITechnology.TechBase, megamek.common.ITechnology.TechRating
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Fields inherited from class mekhq.campaign.parts.Part
brandNew, campaign, childParts, daysToArrival, daysToWait, hits, id, mode, name, omniPodded, parentPart, quality, quantity, resources, shorthandedMod, skillMin, TA_GENERIC, TA_POD, tech, unit, unitTonnage, unitTonnageMatters, usedForRefitPlanning, workingOvertime
Fields inherited from interface megamek.common.ITechnology
DATE_ES, DATE_NONE, DATE_PS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Actually order the parts we need for this refitvoid
addRefitKitParts
(int transitDays) Fixes up some special parts and clears the shopping list when we've found the refit kitvoid
addTimeSpent
(int time) void
begin()
Begins the refit after it's been calculated and configured.void
Do all the grunt work to determine what parts are being added, removed, moved, and what other manipulations are happening in this refit.void
cancel()
Aborts this refit and releases the various marked parts to be used for other purposes.Is there anything blocking the refit?clone()
You can't clone a refitfail
(int rating) You failed to find the kitfind
(int transitDays) You found the refit kit, now attempt to purchase itvoid
fix()
We don't do thisvoid
fixReferences
(Campaign campaign) Make sure all of our units' parts are properly accounted forstatic Refit
generateInstanceFromXML
(Node wn, megamek.Version version, Campaign campaign, Unit unit) Recreates a refit from the save dataWe don't use thisWe don't use thisWe don't use thisWe don't use thisWe don't use thisint
A refit has the same base and actual timeThis is the value of the part that may be affected by characteristics and campaign optionsmegamek.common.TargetRoll
Get acquisition difficulty based on hardest to find part in the kitmegamek.common.TargetRoll
getAllMods
(Person tech) int
A refit has the same base and actual timegetCost()
getDesc()
This should never come up for usGet the details for this item.getDetails
(boolean includeRepairDetails) Get the details for this item.int
int
Refits have no locationRefits have no locationThere is no missing part version of a refitgetName()
megamek.common.Entity
We are the new equipmentDeprecated.- If only used in a Test file, do we need it?Deprecated.- If only used in a Test file, do we need it?megamek.common.Entity
int
static String
getRefitClassName
(int refitClass) String[]
getShoppingListReport
(int quantity) int
We don't do short handednessint
Anyone can do a refit, even if it's a bad idea.Sticker price is the value of the part according to the rulebooksgetTech()
megamek.common.TechAdvancement
Tech Advancement doesn't matter for refit kitsmegamek.common.ITechnology.TechBase
Tech base is basically irrelevant for a refit kitint
We don't do thismegamek.common.ITechnology.TechRating
We don't have a tech ratingint
getTime()
int
int
double
Refits don't have a weightgetUnit()
boolean
boolean
We don't do overtimeboolean
boolean
Gets a value indicating whether this refit is a custom job.boolean
isExtinctIn
(int year, boolean clan, megamek.common.ITechnology.Faction techFaction) Refits are a meta item that never goes extinctboolean
isIntroducedBy
(int year, boolean clan, megamek.common.ITechnology.Faction techFaction) Refits are a meta item that has no introductionboolean
isRightTechType
(String skillType) We don't care what tech type it is, at least not hereboolean
We don't do salvageboolean
boolean
isSamePartType
(Part part) We don't compare refitsboolean
kitFound()
protected void
We handle this in generateInstanceFromXMLboolean
We always need fixing until the refit is donevoid
Orders armor that is required for this refitboolean
void
reCalc()
Used after loading from a save.void
remove
(boolean salvage) We don't do thisvoid
Goes through the required parts and marks them as reserved in the warehousevoid
We don't do thisvoid
Reset time spent on this refit to zero minutes.void
Writes the configuration for the new side of the refit to a .mtf or .blk file in the customs directory.void
setShorthandedMod
(int i) We don't do short handednessvoid
void
setWorkedOvertime
(boolean b) We don't do overtimesucceed()
void
Suggest a new name for the unit being refit.void
updateConditionFromEntity
(boolean checkForDestruction) We don't do thisvoid
We don't do thisvoid
writeToXML
(PrintWriter pw, int indent) Dumps this object into XML for the save fileMethods inherited from class mekhq.campaign.parts.Part
addChildPart, adjustCostsForCampaignOptions, adjustCostsForCampaignOptions, calcYearAvailability, cancelReservation, canChangeWorkMode, canNeverScrap, changeQuantity, checkScrappable, copyBaseData, decrementDaysToWait, decrementQuantity, doMaintenanceDamage, findPartImage, generateInstanceFromXML, getAcquisitionWork, getAllModsForMaintenance, getArrivalReport, getAvailability, getBaseAvailability, getCampaign, getChildParts, getCommonDate, getCommonDate, getCurrentModeName, getDaysToArrival, getDaysToWait, getExtinctionDate, getExtinctionDate, getExtinctionDate, getHits, getId, getIntroductionDate, getIntroductionDate, getIntroductionDate, getMode, getMRMSOptionType, getParentPart, getProductionDate, getProductionDate, getProductionDate, getPrototypeDate, getPrototypeDate, getPrototypeDate, getQuality, getQualityName, getQuantity, getQuantityName, getRefitUnit, getReintroductionDate, getReintroductionDate, getReintroductionDate, getRepairDesc, getRepairPartType, getReplacementPart, getSellableQuantity, getSimpleTechLevel, getSimpleTechLevel, getSimpleTechLevel, getStaticTechLevel, getStatus, getTechBaseName, getTechBaseName, getUndamagedValue, getUnitTonnage, hasChildParts, hasParentPart, hasReplacementPart, improveQuality, incrementQuantity, isBeingWorkedOn, isBrandNew, isClan, isClanTechBase, isInLocation, isInSupply, isIntroducedBy, isMixedTech, isMountedOnDestroyedLocation, isOmniPoddable, isOmniPodded, isPartForEquipmentNum, isPresent, isPriceAdjustedForAmount, isReservedForRefit, isReservedForReplacement, isSamePartTypeAndStatus, isSameStatus, isSpare, isTeamSalvaging, isUnitTonnageMatters, isUsedForRefitPlanning, needsMaintenance, onBadHipOrShoulder, postProcessCampaignAddition, reduceQuality, removeAllChildParts, removeChildPart, reservePart, resetDaysToWait, resetModeToNormal, resetRepairSettings, scrap, setBrandNew, setCampaign, setDaysToArrival, setHits, setId, setMode, setOmniPodded, setParentPart, setQuality, setQuantity, setRefitUnit, setReplacementPart, setReservedBy, setSkillMin, setUnit, setUsedForRefitPlanning, toString, writeToXMLBegin, writeToXMLEnd
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface mekhq.campaign.work.IAcquisitionWork
decrementDaysToWait, decrementQuantity, getAvailability, getDaysToWait, getQuantity, getQuantityName, getTotalBuyCost, incrementQuantity, resetDaysToWait
Methods inherited from interface mekhq.campaign.work.IPartWork
cancelAssignment
Methods inherited from interface megamek.common.ITechnology
calcEraAvailability, calcEraAvailability, calcYearAvailability, calcYearAvailability, findMinimumRulesLevel, findMinimumRulesLevel, getAdvancedRange, getAdvancedRange, getCodeFromIOAbbr, getCodeFromMMAbbr, getEraAvailabilityName, getEraAvailabilityName, getExperimentalRange, getExperimentalRange, getExtinctionRange, getExtinctionRange, getFullRatingName, getFullRatingName, getSimpleLevel, getSimpleLevel, getSimpleLevel, getStandardRange, getStandardRange, getTechLevel, getTechLevel, getTechRatingName, isAvailableIn, isAvailableIn, isAvailableIn, isExtinct, isExtinct, isExtinct, isIntroLevel, isLegal, isLegal, isUnofficial
-
Field Details
-
NO_CHANGE
public static final int NO_CHANGE- See Also:
-
CLASS_OMNI
public static final int CLASS_OMNI- See Also:
-
CLASS_A
public static final int CLASS_A- See Also:
-
CLASS_B
public static final int CLASS_B- See Also:
-
CLASS_C
public static final int CLASS_C- See Also:
-
CLASS_D
public static final int CLASS_D- See Also:
-
CLASS_E
public static final int CLASS_E- See Also:
-
CLASS_F
public static final int CLASS_F- See Also:
-
WORKHOUR
public static final int WORKHOUR- See Also:
-
WORKDAY
public static final int WORKDAY- See Also:
-
WORKWEEK
public static final int WORKWEEK- See Also:
-
WORKMONTH
public static final int WORKMONTH- See Also:
-
-
Constructor Details
-
Refit
public Refit()Blank refit constructor. Probably should not be used. -
Refit
public Refit(Unit oldUnit, megamek.common.Entity newEntity, boolean custom, boolean refurbish, boolean saveFile) Standard Refit Constructor- Parameters:
oldUnit
- - The unit that is to be refitnewEntity
- - The target design for the unit to be refit intocustom
- - Is this custom work vs using a factory refit kitrefurbish
- - Are we refurbishing this unit rather than refitting itsaveFile
- - Does the new unit need to be saved to disk
-
-
Method Details
-
isSameArmorType
public boolean isSameArmorType()- Returns:
- Is the old unit using the same armor type as the new unit
-
getRefitClassName
- Parameters:
refitClass
- - the integer representing the refit class- Returns:
- the printable name of the refit class
-
getRefitClassName
- Returns:
- the printable name of our refit class
-
getRefitClass
public int getRefitClass()- Returns:
- the integer representing our refit class
-
getCost
- Returns:
- The cost of carrying out this refit
-
getOldUnitParts
Deprecated.- If only used in a Test file, do we need it?Returns a mutable list of parts for the old unit in the refit. This is intended to be mutated only beCampaign
when merging parts.This is only used by RefitTest.java
- Returns:
- A mutable
List
of old parts in the refit. - Since:
- 0.50.04
-
getNewUnitParts
Deprecated.- If only used in a Test file, do we need it?Returns a mutable list of parts for the new unit in the refit. This is intended to be mutated only beCampaign
when merging parts.This is only used by RefitTest.java
- Returns:
- A mutable
List
of new part IDs in the refit. - Since:
- 0.50.04
-
getShoppingList
- Returns:
- A list of parts required to make this refit happen
-
getShoppingListDescription
- Returns:
- Printable list of shopping items for display
-
getTime
public int getTime()- Returns:
- the time this refit will take
-
calculate
public void calculate()Do all the grunt work to determine what parts are being added, removed, moved, and what other manipulations are happening in this refit. -
begin
Begins the refit after it's been calculated and configured.- Throws:
megamek.common.loaders.EntityLoadingException
IOException
-
reserveNewParts
public void reserveNewParts()Goes through the required parts and marks them as reserved in the warehouse -
partsInTransit
public boolean partsInTransit()- Returns:
- if any of our parts are still in transit.
-
acquireParts
public boolean acquireParts()Actually order the parts we need for this refit- Returns:
- true when the shopping list is empty and there's nothing left to buy
-
orderArmorSupplies
public void orderArmorSupplies()Orders armor that is required for this refit -
getExistingArmorSupplies
- Returns:
- Armor that's in our warehouse already, if there is any
-
cancel
public void cancel()Aborts this refit and releases the various marked parts to be used for other purposes.TODO: WeaverThree - Is it safe to call this on an un-started refit? Looks like no.
-
saveCustomization
public void saveCustomization() throws megamek.common.loaders.EntityLoadingExceptionWrites the configuration for the new side of the refit to a .mtf or .blk file in the customs directory.- Throws:
megamek.common.loaders.EntityLoadingException
-
getOriginalEntity
public megamek.common.Entity getOriginalEntity()- Returns:
- The entity we're refitting FROM
-
getNewEntity
public megamek.common.Entity getNewEntity()- Returns:
- The entity that we're refitting TO.
-
getOriginalUnit
- Returns:
- The unit we're refitting FROM
-
hasFailedCheck
public boolean hasFailedCheck()- Returns:
- Have we failed a refit check? If so, the quality of the parts will decrease. unless it's a refurbishment, at least.
-
needsFixing
public boolean needsFixing()We always need fixing until the refit is done- Specified by:
needsFixing
in interfaceIWork
-
getDifficulty
public int getDifficulty()- Specified by:
getDifficulty
in interfaceIWork
- Returns:
- The difficulty modifier for our refit class
-
getAllMods
- Specified by:
getAllMods
in interfaceIWork
- Overrides:
getAllMods
in classPart
- Parameters:
tech
- - a Person whose attribute may modify this roll- Returns:
- a TargetRoll describing all of our difficulty modifiers
-
succeed
-
fail
-
resetTimeSpent
public void resetTimeSpent()Reset time spent on this refit to zero minutes.- Specified by:
resetTimeSpent
in interfaceIPartWork
- Overrides:
resetTimeSpent
in classPart
-
getPartName
- Specified by:
getPartName
in interfaceIPartWork
- Overrides:
getPartName
in classPart
- Returns:
- Name of the refit item
-
getAcquisitionName
- Specified by:
getAcquisitionName
in interfaceIAcquisitionWork
- Returns:
- Name of the refit item
-
getName
-
getSkillMin
public int getSkillMin()Anyone can do a refit, even if it's a bad idea. The skill required doesn't change.- Specified by:
getSkillMin
in interfaceIPartWork
- Overrides:
getSkillMin
in classPart
- Returns:
- EXP_GREEN
-
getBaseTime
public int getBaseTime()A refit has the same base and actual time- Specified by:
getBaseTime
in interfaceIPartWork
- Returns:
- minutes to complete refit
-
getActualTime
public int getActualTime()A refit has the same base and actual time- Specified by:
getActualTime
in interfaceIPartWork
- Overrides:
getActualTime
in classPart
- Returns:
- minutes to complete refit
-
getTimeSpent
public int getTimeSpent()- Specified by:
getTimeSpent
in interfaceIPartWork
- Overrides:
getTimeSpent
in classPart
- Returns:
- how many minutes have already been spent on this refit
-
getTimeLeft
public int getTimeLeft()- Specified by:
getTimeLeft
in interfaceIPartWork
- Overrides:
getTimeLeft
in classPart
- Returns:
- how many minutes are left to go on this refit
-
addTimeSpent
public void addTimeSpent(int time) - Specified by:
addTimeSpent
in interfaceIPartWork
- Overrides:
addTimeSpent
in classPart
- Parameters:
time
- - minutes to add to time spent on this refit
-
getTech
-
setTech
-
hasWorkedOvertime
public boolean hasWorkedOvertime()We don't do overtime- Specified by:
hasWorkedOvertime
in interfaceIPartWork
- Overrides:
hasWorkedOvertime
in classPart
- Returns:
- false
-
setWorkedOvertime
public void setWorkedOvertime(boolean b) We don't do overtime- Specified by:
setWorkedOvertime
in interfaceIPartWork
- Overrides:
setWorkedOvertime
in classPart
- Parameters:
b
- - ignored
-
getShorthandedMod
public int getShorthandedMod()We don't do short handedness- Specified by:
getShorthandedMod
in interfaceIPartWork
- Overrides:
getShorthandedMod
in classPart
-
setShorthandedMod
public void setShorthandedMod(int i) We don't do short handedness- Specified by:
setShorthandedMod
in interfaceIPartWork
- Overrides:
setShorthandedMod
in classPart
-
updateConditionFromEntity
public void updateConditionFromEntity(boolean checkForDestruction) We don't do this- Specified by:
updateConditionFromEntity
in interfaceIPartWork
- Parameters:
checkForDestruction
- - ignored
-
updateConditionFromPart
public void updateConditionFromPart()We don't do this- Specified by:
updateConditionFromPart
in interfaceIPartWork
-
fix
public void fix()We don't do this -
remove
public void remove(boolean salvage) We don't do this -
getMissingPart
There is no missing part version of a refit- Specified by:
getMissingPart
in interfaceIPartWork
- Returns:
- null
-
getDesc
This should never come up for us -
getDetails
Get the details for this item. Always includes repair details that don't exist here.- Specified by:
getDetails
in interfaceIPartWork
- Overrides:
getDetails
in classPart
- Returns:
- Full details string
-
getDetails
Get the details for this item. Repair details optional but don't exist here.- Specified by:
getDetails
in interfaceIPartWork
- Overrides:
getDetails
in classPart
- Parameters:
includeRepairDetails
- - ignored- Returns:
- Full details string
-
getUnit
-
isSalvaging
public boolean isSalvaging()We don't do salvage- Specified by:
isSalvaging
in interfaceIPartWork
- Overrides:
isSalvaging
in classPart
- Returns:
- false
-
checkFixable
Is there anything blocking the refit?- Specified by:
checkFixable
in interfaceIPartWork
- Returns:
- String detailing blockers
-
writeToXML
Dumps this object into XML for the save file- Specified by:
writeToXML
in classPart
- Parameters:
pw
- - output writerindent
- - current indent level in the XML
-
generateInstanceFromXML
@Nullable public static Refit generateInstanceFromXML(Node wn, megamek.Version version, Campaign campaign, Unit unit) Recreates a refit from the save data- Parameters:
wn
- - our XML nodeversion
- - save file version ?campaign
- - campaign we're loading intounit
- - unit this refit is attached to- Returns:
- a brand-new Refit
-
reCalc
public void reCalc()Used after loading from a save. -
getNewEquipment
We are the new equipment- Specified by:
getNewEquipment
in interfaceIAcquisitionWork
-
getAcquisitionDesc
We don't use this- Specified by:
getAcquisitionDesc
in interfaceIAcquisitionWork
-
getAcquisitionDisplayName
We don't use this- Specified by:
getAcquisitionDisplayName
in interfaceIAcquisitionWork
-
getAcquisitionExtraDesc
We don't use this- Specified by:
getAcquisitionExtraDesc
in interfaceIAcquisitionWork
-
getAcquisitionBonus
We don't use this- Specified by:
getAcquisitionBonus
in interfaceIAcquisitionWork
-
getAcquisitionPart
We don't use this- Specified by:
getAcquisitionPart
in interfaceIAcquisitionWork
-
getStickerPrice
Description copied from interface:IPartWork
Sticker price is the value of the part according to the rulebooks- Specified by:
getStickerPrice
in interfaceIPartWork
- Returns:
- Cost of carrying otu the refit (mostly relevant for refurbishment)
-
getActualValue
Description copied from class:Part
This is the value of the part that may be affected by characteristics and campaign options- Specified by:
getActualValue
in interfaceIPartWork
- Overrides:
getActualValue
in classPart
- Returns:
- Cost of carrying otu the refit (mostly relevant for refurbishment)
-
getBuyCost
- Specified by:
getBuyCost
in interfaceIAcquisitionWork
- Returns:
- Cost of carrying otu the refit (mostly relevant for refurbishment)
-
addRefitKitParts
public void addRefitKitParts(int transitDays) Fixes up some special parts and clears the shopping list when we've found the refit kit- Parameters:
transitDays
- - How long will it take to acquire kit
-
find
You found the refit kit, now attempt to purchase it- Specified by:
find
in interfaceIAcquisitionWork
- Parameters:
transitDays
- - how long it's going to take to get here- Returns:
- string for report explaining how it went
-
failToFind
You failed to find the kit- Specified by:
failToFind
in interfaceIAcquisitionWork
- Returns:
- string describing this
-
getAllAcquisitionMods
public megamek.common.TargetRoll getAllAcquisitionMods()Get acquisition difficulty based on hardest to find part in the kit- Specified by:
getAllAcquisitionMods
in interfaceIAcquisitionWork
- Returns:
- TargetRoll describing modifiers to roll
-
getNewArmorSupplies
-
resetOvertime
public void resetOvertime()We don't do this- Specified by:
resetOvertime
in interfaceIPartWork
- Overrides:
resetOvertime
in classPart
-
getTechLevel
public int getTechLevel()We don't do this- Specified by:
getTechLevel
in interfaceIAcquisitionWork
- Overrides:
getTechLevel
in classPart
- Returns:
- TechConstants tech level
-
getTechBase
public megamek.common.ITechnology.TechBase getTechBase()Tech base is basically irrelevant for a refit kit- Specified by:
getTechBase
in interfaceIAcquisitionWork
- Specified by:
getTechBase
in interfacemegamek.common.ITechnology
- Overrides:
getTechBase
in classPart
-
isRightTechType
We don't care what tech type it is, at least not here- Specified by:
isRightTechType
in interfaceIPartWork
- Overrides:
isRightTechType
in classPart
-
suggestNewName
public void suggestNewName()Suggest a new name for the unit being refit. Only works for infantry. -
getShoppingListReport
- Specified by:
getShoppingListReport
in interfaceIAcquisitionWork
- Overrides:
getShoppingListReport
in classPart
- Parameters:
quantity
- - ignored- Returns:
- string for report about listing this refit
-
getTonnage
public double getTonnage()Refits don't have a weight- Specified by:
getTonnage
in classPart
- Returns:
- 0
-
getTechRating
public megamek.common.ITechnology.TechRating getTechRating()We don't have a tech rating- Specified by:
getTechRating
in interfacemegamek.common.ITechnology
- Overrides:
getTechRating
in classPart
- Returns:
- 0
-
isSamePartType
We don't compare refits- Specified by:
isSamePartType
in classPart
- Returns:
- false
-
loadFieldsFromXmlNode
We handle this in generateInstanceFromXML- Specified by:
loadFieldsFromXmlNode
in classPart
- Parameters:
wn
- - ignored
-
clone
You can't clone a refit -
isCustomJob
public boolean isCustomJob()Gets a value indicating whether this refit is a custom job. If false, this is a Refit Kit (CamOps 212).\- Returns:
- is custom job?
-
kitFound
public boolean kitFound()- Returns:
- Has a refit kit for this refit been found (if applicable).
-
getLocationName
Refits have no location- Specified by:
getLocationName
in classPart
- Returns:
- null
-
getLocation
public int getLocation()Refits have no location- Specified by:
getLocation
in interfaceIPartWork
- Returns:
- LOC_NONE
-
getTechAdvancement
public megamek.common.TechAdvancement getTechAdvancement()Tech Advancement doesn't matter for refit kits- Specified by:
getTechAdvancement
in classPart
- Returns:
- TA_GENERIC
-
isBeingRefurbished
public boolean isBeingRefurbished()- Returns:
- are we doing a refurbishment?
-
isIntroducedBy
public boolean isIntroducedBy(int year, boolean clan, megamek.common.ITechnology.Faction techFaction) Refits are a meta item that has no introduction- Specified by:
isIntroducedBy
in interfaceIAcquisitionWork
- Returns:
- should probably always be true
-
isExtinctIn
public boolean isExtinctIn(int year, boolean clan, megamek.common.ITechnology.Faction techFaction) Refits are a meta item that never goes extinct- Specified by:
isExtinctIn
in interfaceIAcquisitionWork
- Returns:
- should probably always be false
-
fixReferences
Make sure all of our units' parts are properly accounted for- Overrides:
fixReferences
in classPart
- Parameters:
campaign
- - campaign that owns the parts
-