Class shipSpec
A shipSpec defines the hull and the engine and weapons the ship is equipped with. It does this by listing the various specs that make up this shipSpec.
These properties are fixed and thus have no setter methods since there is no in-game reason to change them or create them. Objects are initialised by loading XML via XStream.
- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IntegerThe base number of days to construct this type of ship.List the spec of items that compose this shipSpec.private static org.slf4j.Loggerprivate org.jscience.physics.amount.Amount<org.jscience.economics.money.Money>The base cost of constructing this item. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class name.moore.kevin.ze.XMLdata.XMLbase
defaultXMLmessage, duplicatedXMLmessage, getDescription, getKey, getSpec, missingXMLmessage
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
money
@XStreamConverter(SingleValueMoneyConverter.class) private org.jscience.physics.amount.Amount<org.jscience.economics.money.Money> moneyThe base cost of constructing this item.This may be modified by factors considered in the construction logic. It is always an exact value, no decimals.
Optional element in XML<money>. Defaults to zero if not provided. -
daystobuild
The base number of days to construct this type of ship.This value may be changed by construction systems which take into account things such as a damaged factory. The engines,weapons etc fitted to a ship also have a daystobuild, consider this an extra 'project management' time - the more complex the ship the more complex the coordination becomes.
Optional element in XML<daystobuild>. Defaults to 1. -
equipment
List the spec of items that compose this shipSpec.The XML specifies elements with a String value that needs a bit of interpretation...
A List is used because we want to preserve the ordering of the equipment. The first bay element is considered bay #1. This allows us to match up with the hullSpec understanding of a bay.
The value is in the format [key],[type] where key is a String specification eg "E01" and type is the class type the specification applies to eg "engine". So "E01,engine" says this ship has an engine of specification E01.
We could store the type as the proper Class eg name.moore.kevin.ze.config.hullSpec but this seems longwinded and relies on knowing the internal code packages. So use a shorted String and do the conversion to a Class later.
Once we have parsed the XML the List will need converting to reference the actual EntityIds of the specifications. This stored as a 'container' component of the shipSpec entity.
- See Also:
hullSpec
-
-
Constructor Details
-
shipSpec
public shipSpec()
-
-
Method Details
-
getMoney
public org.jscience.physics.amount.Amount<org.jscience.economics.money.Money> getMoney()- Returns:
-
getDaystobuild
- Returns:
-
getEquipment
- Returns:
-
readResolve
Description copied from class:XMLbaseCalled automatically when loading from XML as part of JDK serialisation.Used to do some validation of that incoming XML by asserting that properties are set and have defaults as required. Output warning messages if a default is applied. Output error messages if a required XML element is missing and return null to indicate an invalid object.
- Overrides:
readResolvein classXMLbase- Returns:
- null if we can't create a valid object
-
getEntityClass
Description copied from class:XMLbaseDerived classes have to override this and say what class eg engine.class they are. This allows us to use this base class but discover the derived class.- Specified by:
getEntityClassin classXMLbase- Returns:
-