Class MagellanUnitImpl

    • Field Detail

      • CONFIRMEDTEMPCOMMENT

        public static final java.lang.String CONFIRMEDTEMPCOMMENT
        See Also:
        Constant Field Values
      • TAG_PREFIX_TEMP

        public static final java.lang.String TAG_PREFIX_TEMP
        grammar for ejcTag: ";ejcTempTag tag numbervalue|'stringvalue'"
        See Also:
        Constant Field Values
      • region

        protected Region region
        The region this unit is currently in.
    • Constructor Detail

      • MagellanUnitImpl

        public MagellanUnitImpl​(UnitID id,
                                GameData data)
        Kinda obvious, right?
    • Method Detail

      • getOrdersObject

        protected Orders getOrdersObject()
        Returns (or creates) the Orders object.
      • clearOrders

        @Deprecated
        public void clearOrders​(boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Clears the orders and possibly refreshes the relations
        Specified by:
        clearOrders in interface Unit
        Parameters:
        refreshRelations - if true also refresh the relations of the unit.
        See Also:
        Unit.clearOrders(boolean)
      • removeOrderAt

        @Deprecated
        public void removeOrderAt​(int i,
                                  boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Removes the order at position i and possibly refreshes the relations
        Specified by:
        removeOrderAt in interface Unit
        Parameters:
        refreshRelations - if true also refresh the relations of the unit.
        See Also:
        Unit.removeOrderAt(int, boolean)
      • removeOrder

        public boolean removeOrder​(java.lang.String order,
                                   int length)
        Description copied from interface: Unit
        Removes orders that match the given order up to a given length.
        Specified by:
        removeOrder in interface Unit
        Parameters:
        order - pattern to remove
        length - denotes the number of tokens that need to be equal for a replacement. E.g. specify 2 if order is "BENENNE EINHEIT abc" and all "BENENNE EINHEIT" orders should be replaced but not all "BENENNE" orders.
        Returns:
        true if at least one order was removed
        See Also:
        Unit.removeOrder(java.lang.String, int)
      • removeOrder

        @Deprecated
        public boolean removeOrder​(java.lang.String order,
                                   int length,
                                   boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Removes orders that match the given order up to a given length.
        Specified by:
        removeOrder in interface Unit
        Parameters:
        order - pattern to remove
        length - denotes the number of tokens that need to be equal for a replacement. E.g. specify 2 if order is "BENENNE EINHEIT abc" and all "BENENNE EINHEIT" orders should be replaced but not all "BENENNE" orders.
        refreshRelations -
        Returns:
        true if at least one order was removed
        See Also:
        Unit.removeOrder(java.lang.String, int, boolean)
      • addOrder

        public boolean addOrder​(java.lang.String order)
        Add a order to the unit's orders. This function ensures that TEMP units are not affected by the operation.
        Specified by:
        addOrder in interface Unit
        Parameters:
        order - the order to add.
        Returns:
        true if the order was successfully added.
        See Also:
        Unit.addOrder(java.lang.String)
      • addOrder

        @Deprecated
        public boolean addOrder​(java.lang.String order,
                                boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Add a order to the unit's orders. This function ensures that TEMP units are not affected by the operation.
        Specified by:
        addOrder in interface Unit
        Parameters:
        order - the new order line
        refreshRelations - if true also refresh the relations of the unit.
        Returns:
        true if the order was successfully added.
        See Also:
        Unit.addOrder(java.lang.String, boolean)
      • addOrder

        public boolean addOrder​(java.lang.String order,
                                boolean replace,
                                int length)
        Add a order to the unit's orders. This function ensures that TEMP units are not affected by the operation.
        Specified by:
        addOrder in interface Unit
        Parameters:
        order - the order to add.
        replace - if true, the order replaces any other of the unit's orders of the same type. If false the order is simply added.
        length - denotes the number of tokens that need to be equal for a replacement. E.g. specify 2 if order is "BENENNE EINHEIT abc" and all "BENENNE EINHEIT" orders should be replaced but not all "BENENNE" orders.
        Returns:
        true if the order was successfully added.
        See Also:
        Unit.addOrder(java.lang.String, boolean, int)
      • addOrder

        public void addOrder​(Order line)
        Add specified order at the end.
        Parameters:
        line -
      • addOrder

        @Deprecated
        public void addOrder​(Order line,
                             boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Description copied from interface: Unit
        Adds the order and possibly refreshes the relations
        Specified by:
        addOrder in interface Unit
        refreshRelations - if true also refresh the relations of the unit.
        See Also:
        Unit.addOrder(magellan.library.Order, boolean)
      • addOrderAt

        public void addOrderAt​(int pos,
                               java.lang.String newOrder)
        Adds the order at position i and refreshes the relations
        Specified by:
        addOrderAt in interface Unit
        Parameters:
        pos - An index between 0 and getOrders().getSize() (inclusively), or -1 to add at the end.
        newOrder -
        See Also:
        Unit.addOrderAt(int, java.lang.String)
      • addOrderAt

        @Deprecated
        public void addOrderAt​(int pos,
                               java.lang.String newOrder,
                               boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Adds the order at position i and possibly refreshes the relations
        Specified by:
        addOrderAt in interface Unit
        Parameters:
        pos - An index between 0 and getOrders().getSize() (inclusively), or -1 to add at the end.
        newOrder -
        refreshRelations - if true also refresh the relations of the unit.
        See Also:
        Unit.addOrderAt(int, java.lang.String, boolean)
      • addOrderAt

        public void addOrderAt​(int pos,
                               Order newOrder)
        Description copied from interface: Unit
        Adds the order at position i and possibly refreshes the relations
        Specified by:
        addOrderAt in interface Unit
        Parameters:
        pos - An index between 0 and getOrders().getSize() (inclusively), or -1 to add at the end
        See Also:
        Unit.addOrderAt(int, magellan.library.Order)
      • addOrderAt

        @Deprecated
        public void addOrderAt​(int pos,
                               Order newOrder,
                               boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Description copied from interface: Unit
        Adds the order at position i and possibly refreshes the relations
        Specified by:
        addOrderAt in interface Unit
        Parameters:
        pos - An index between 0 and getOrders().getSize() (inclusively), or -1 to add at the end
        refreshRelations - if true also refresh the relations of the unit.
        See Also:
        Unit.addOrderAt(int, magellan.library.Order, boolean)
      • replaceOrder

        public void replaceOrder​(int pos,
                                 Order newOrder)
        Description copied from interface: Unit
        Replaces the order at the position by the given new order.
        Specified by:
        replaceOrder in interface Unit
        Parameters:
        pos - An index between 0 and getOrders().getSize() (inclusively)
        See Also:
        Unit.replaceOrder(int, Order)
      • replaceOrder

        @Deprecated
        public void replaceOrder​(int pos,
                                 Order newOrder,
                                 boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Description copied from interface: Unit
        Replaces the order at the position by the given new order.
        Specified by:
        replaceOrder in interface Unit
        Parameters:
        pos - An index between 0 and getOrders().getSize() (inclusively)
        See Also:
        Unit.replaceOrder(int, magellan.library.Order, boolean)
      • createOrder

        public Order createOrder​(java.lang.String newOrder)
        Description copied from interface: Unit
        Parses the given order line and returns a corresponding order.
        Specified by:
        createOrder in interface Unit
        Returns:
        A new order representing order
        See Also:
        Unit.createOrder(java.lang.String)
      • addOrders

        public void addOrders​(java.util.Collection<java.lang.String> newOrders)
        Adds the orders and refreshes the relations
        Specified by:
        addOrders in interface Unit
        Parameters:
        newOrders -
        See Also:
        Unit.addOrders(java.util.Collection)
      • addOrders

        @Deprecated
        public void addOrders​(java.util.Collection<java.lang.String> newOrders,
                              boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Adds the orders and possibly refreshes the relations
        Specified by:
        addOrders in interface Unit
        Parameters:
        newOrders -
        refreshRelations - If true also refresh the relations of the unit
        See Also:
        Unit.addOrders(java.util.Collection, boolean)
      • addOrders2

        @Deprecated
        public void addOrders2​(java.util.Collection<Order> newOrders,
                               boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Description copied from interface: Unit
        Adds the orders and possibly refreshes the relations
        Specified by:
        addOrders2 in interface Unit
        refreshRelations - If true also refresh the relations of the unit
        See Also:
        Unit.addOrders2(java.util.Collection, boolean)
      • setOrders

        public void setOrders​(java.util.Collection<java.lang.String> newOrders)
        Sets the orders and refreshes the relations
        Specified by:
        setOrders in interface Unit
        Parameters:
        newOrders - my be null
        See Also:
        Unit.setOrders(java.util.Collection)
      • setOrders

        @Deprecated
        public void setOrders​(java.util.Collection<java.lang.String> newOrders,
                              boolean refreshRelations)
        Deprecated.
        relation refreshing is now done event-based
        Sets the orders and possibly refreshes the relations
        Specified by:
        setOrders in interface Unit
        Parameters:
        newOrders -
        refreshRelations - if true also refresh the relations of the unit.
        See Also:
        Unit.setOrders(java.util.Collection, boolean)
      • setOrders2

        @Deprecated
        public void setOrders2​(java.util.Collection<Order> newOrders,
                               boolean refresh)
        Deprecated.
        relation refreshing is now done event-based
        Description copied from interface: Unit
        Sets the orders and possibly refreshes the relations
        Specified by:
        setOrders2 in interface Unit
        Parameters:
        newOrders - my be null
        refresh - if true also refresh the relations of the unit.
        See Also:
        Unit.setOrders2(java.util.Collection, boolean)
      • getOrders

        @Deprecated
        public java.util.List<java.lang.String> getOrders()
        Deprecated.
        Description copied from interface: Unit
        Delivers a read-only collection of all orders of this unit.
        Specified by:
        getOrders in interface Unit
        See Also:
        Unit.getOrders()
      • getOrders2

        public Orders getOrders2()
        Description copied from interface: Unit
        Delivers a read-only collection of all orders of this unit.
        Specified by:
        getOrders2 in interface Unit
        See Also:
        Unit.getOrders2()
      • getGroup

        public Group getGroup()
        Returns the group this unit belongs to.
        Specified by:
        getGroup in interface Unit
        Returns:
        the group this unit belongs to
        See Also:
        Unit.getGroup()
      • setAlias

        public void setAlias​(UnitID id)
        Sets an alias id for this unit.
        Specified by:
        setAlias in interface Unit
        Parameters:
        id - the alias id for this unit
      • getAlias

        public UnitID getAlias()
        Returns the alias, i.e. the id of this unit it had in the last turn (e.g. after a NUMMER order).
        Specified by:
        getAlias in interface Unit
        Returns:
        the alias or null, if the id did not change.
      • getItem

        public Item getItem​(ItemType type)
        Returns the item of the specified type if the unit owns such an item, otherwise null.
        Specified by:
        getItem in interface Unit
      • setSpy

        public void setSpy​(boolean bool)
        Sets whether is unit really belongs to its unit or only pretends to do so. A unit cannot disguise itself as a different faction and at the same time be a spy of another faction, therefore, setting this attribute to true results in having the guiseFaction attribute set to null.
        Specified by:
        setSpy in interface Unit
      • isSpy

        public boolean isSpy()
        Returns whether this unit only pretends to belong to its faction. A unit cannot disguise itself as a different faction and at the same time be a spy of another faction.
        Specified by:
        isSpy in interface Unit
        Returns:
        true if the unit is identified as spy
      • setGuiseFaction

        public void setGuiseFaction​(Faction f)
        Sets the faction this unit pretends to belong to. A unit cannot disguise itself as a different faction and at the same time be a spy of another faction, therefore, setting a value other than null results in having the spy attribute set to false.
        Specified by:
        setGuiseFaction in interface Unit
      • getGuiseFaction

        public Faction getGuiseFaction()
        Returns the faction this unit pretends to belong to. If the unit is not disguised null is returned. A unit cannot disguise itself as a different faction and at the same time be a spy of another faction.
        Specified by:
        getGuiseFaction in interface Unit
      • addItem

        public Item addItem​(Item i)
        Adds an item to the unit. If the unit already has an item of the same type, the item is overwritten with the specified item object.
        Specified by:
        addItem in interface Unit
        Returns:
        the specified item i.
      • setTempID

        public void setTempID​(UnitID id)
        Sets the temp id this unit had before becoming a real unit.
        Specified by:
        setTempID in interface Unit
      • getTempID

        public UnitID getTempID()
        Returns the id the unit had when it was still a temp unit. This id is only set in the turn after the unit turned from a temp unit into to a real unit.
        Specified by:
        getTempID in interface Unit
        Returns:
        the temp id or null, if this unit was no temp unit in the previous turn.
      • setRegion

        public void setRegion​(Region r)
        Sets the region this unit is in. If this unit already has a different region set it removes itself from the collection of units in that region.
        Specified by:
        setRegion in interface HasRegion
        Specified by:
        setRegion in interface Unit
        Parameters:
        r - the new region, possibly null
      • getRegion

        public Region getRegion()
        Returns the region this unit is staying in.
        Specified by:
        getRegion in interface HasRegion
        Specified by:
        getRegion in interface Unit
        Returns:
        the region, possibly null
      • setFaction

        public void setFaction​(Faction faction)
        Sets the faction for this unit. If this unit already has a different faction set it removes itself from the collection of units in that faction.
        Specified by:
        setFaction in interface Unit
      • getFaction

        public Faction getFaction()
        Returns the faction this unit belongs to.
        Specified by:
        getFaction in interface Unit
      • setBuilding

        public void setBuilding​(Building building)
        Sets the building this unit is staying in. If the unit already is in another building this method removes it from the unit collection of that building.
        Specified by:
        setBuilding in interface Unit
      • getBuilding

        public Building getBuilding()
        Returns the building this unit is staying in.
        Specified by:
        getBuilding in interface Unit
        Returns:
        The building the unit is in, or null
      • setShip

        public void setShip​(Ship ship)
        Sets the ship this unit is on. If the unit already is on another ship this method removes it from the unit collection of that ship.
        Specified by:
        setShip in interface Unit
      • getShip

        public Ship getShip()
        Returns the ship this unit is on.
        Specified by:
        getShip in interface Unit
        Returns:
        The ship the unit is in, or null
      • setSortIndex

        public void setSortIndex​(int index)
        Sets an index indicating how instances of class are sorted in the report.
        Specified by:
        setSortIndex in interface Sorted
        Specified by:
        setSortIndex in interface Unit
      • getSortIndex

        public int getSortIndex()
        Returns an index indicating how instances of class are sorted in the report.
        Specified by:
        getSortIndex in interface Sorted
        Specified by:
        getSortIndex in interface Unit
      • setRaceNamePrefix

        public void setRaceNamePrefix​(java.lang.String prefix)
        Sets the unit dependent prefix for the race name.
        Specified by:
        setRaceNamePrefix in interface Unit
      • getRaceNamePrefix

        public java.lang.String getRaceNamePrefix()
        Returns the unit dependent prefix for the race name.
        Specified by:
        getRaceNamePrefix in interface Unit
      • getRaceName

        public java.lang.String getRaceName​(GameData gdata)
        Returns the name of this unit's race including the prefixes of itself, its faction and group if it has such and those prefixes are set.
        Specified by:
        getRaceName in interface Unit
        Parameters:
        gdata - The GameData
        Returns:
        the name or null if this unit's race or its name is not set.
      • getSimpleRealRaceName

        public java.lang.String getSimpleRealRaceName()
        Specified by:
        getSimpleRealRaceName in interface Unit
        Returns:
        The String of the RealRace. If no RealRace is known( = null) the normal raceName is returned.
      • getSimpleRaceName

        public java.lang.String getSimpleRaceName()
        Delivers the info "typ" from CR without any prefixes and translations used for displaying the according race icon
        Specified by:
        getSimpleRaceName in interface Unit
        Returns:
        Name of the race
      • tempUnits

        public java.util.Collection<TempUnit> tempUnits()
        Returns the child temp units created by this unit's orders.
        Specified by:
        tempUnits in interface Unit
      • getTempUnit

        public Unit getTempUnit​(ID key)
        Return the child temp unit with the specified ID.
        Specified by:
        getTempUnit in interface Unit
      • clearTemps

        public void clearTemps()
        Clears the list of temp units created by this unit. Clears only the caching collection, does not perform clean-up like deleteTemp() does.
        Specified by:
        clearTemps in interface Unit
      • getCompleteOrders

        public Orders getCompleteOrders()
        Returns all orders including the orders necessary to issue the creation of all the child temp units of this unit.
        Specified by:
        getCompleteOrders in interface Unit
      • getCompleteOrders

        public Orders getCompleteOrders​(boolean writeUnitTagsAsVorlageComment)
        Returns all orders including the orders necessary to issue the creation of all the child temp units of this unit.
        Specified by:
        getCompleteOrders in interface Unit
        Parameters:
        writeUnitTagsAsVorlageComment - If this is true, unit tags are also added as Vorlage comments
      • getOrderTranslation

        protected java.lang.String getOrderTranslation​(StringID orderId)
      • createTemp

        public TempUnit createTemp​(GameData gdata,
                                   UnitID key)
        Creates a new temp unit with this unit as the parent. The temp unit is fully initialised, i.e. it is added to the region units collection in the specified game data,it inherits the faction, building or ship, region, faction stealth status, group, race and combat status settings and adds itself to the corresponding unit collections.
        Specified by:
        createTemp in interface Unit
        Throws:
        java.lang.IllegalArgumentException - If key is negative
      • deleteTemp

        public void deleteTemp​(UnitID key,
                               GameData gdata)
        Removes a temp unit with this unit as the parent completely from the game data.
        Specified by:
        deleteTemp in interface Unit
      • getRelations

        public java.util.List<UnitRelation> getRelations()
        Returns a Collection over the relations this unit has to other units. The iterator returns UnitRelation objects. An empty iterator is returned if the relations have not been set up so far or if there are no relations.
        Specified by:
        getRelations in interface Related
        Specified by:
        getRelations in class MagellanRelatedImpl
        Returns:
        list of all relations
      • getRelatedUnits

        public void getRelatedUnits​(java.util.Set<Unit> units,
                                    java.util.Set<UnitRelation.ID> relations)
        Recursively retrieves all units that are related to this unit via one of the specified relations (exactly, not as subclasses).
        Specified by:
        getRelatedUnits in interface Unit
        Parameters:
        units - all units gathered so far to prevent loops.
        relations - a set of classes naming the types of relations that are eligible for regarding a unit as related to some other unit.
        See Also:
        Unit.getRelatedUnits(java.util.Set, java.util.Set)
      • getModifiedMovement

        public java.util.List<CoordinateID> getModifiedMovement()
        Returns a List of the reached coordinates of the unit's movement starting with the current region or an empty list if unit is not moving.
        Specified by:
        getModifiedMovement in interface Unit
        Returns:
        A list of coordinates, empty list means no movement
      • getModifiedSkills

        public java.util.Collection<Skill> getModifiedSkills()
        Returns the skills of this unit as they would appear after the orders for person transfers are processed.
        Specified by:
        getModifiedSkills in interface Unit
      • getModifiedUnitContainer

        public UnitContainer getModifiedUnitContainer()
        Returns the modified unit container this unit belongs to. (ship, building or null)
        Specified by:
        getModifiedUnitContainer in interface Unit
      • getSkill

        public Skill getSkill​(SkillType type)
        Returns the skill of the specified type if the unit has such a skill, else null is returned.
        Specified by:
        getSkill in interface Unit
        Parameters:
        type - null is allowed and will yield null as result
      • getSkill

        public Skill getSkill​(StringID type)
        Returns the skill of the specified type if the unit has such a skill, else null is returned.
        Specified by:
        getSkill in interface Unit
      • addSkill

        public Skill addSkill​(Skill s)
        Adds a skill to unit's collection of skills. If the unit already has a skill of the same type it is overwritten with the the new skill object.
        Specified by:
        addSkill in interface Unit
        Returns:
        the specified skill s.
      • getSkills

        public java.util.Collection<Skill> getSkills()
        Returns all skills this unit has.
        Specified by:
        getSkills in interface Unit
        Returns:
        a collection of Skill objects.
      • clearSkills

        public void clearSkills()
        Removes all skills from this unit.
        Specified by:
        clearSkills in interface Unit
      • getItems

        public java.util.Collection<Item> getItems()
        Returns all the items this unit possesses.
        Specified by:
        getItems in interface Unit
        Returns:
        a collection of Item objects.
      • setItems

        public void setItems​(java.util.Map<StringID,​Item> items)
        Description copied from interface: Unit
        Changes the items.
        Specified by:
        setItems in interface Unit
      • getItemMap

        public java.util.Map<StringID,​Item> getItemMap()
        Description copied from interface: Unit
        Returns the collection of items. Changes to this map are reflected in the unit's items.
        Specified by:
        getItemMap in interface Unit
      • clearItems

        public void clearItems()
        Removes all items from this unit.
        Specified by:
        clearItems in interface Unit
      • getModifiedItem

        public Item getModifiedItem​(ItemType type)
        Returns the item of the specified type as it would appear after the orders of this unit have been processed, i.e. the amount of the item might be modified by transfer orders. If the unit does not have an item of the specified type nor is given one by some other unit, null is returned.
        Specified by:
        getModifiedItem in interface Unit
      • getItemReserveRelations

        public java.util.Collection<ReserveRelation> getItemReserveRelations​(ItemType itemType)
        Returns a collection of the reserve relations concerning the given Item.
        Specified by:
        getItemReserveRelations in interface Unit
        Parameters:
        itemType -
        Returns:
        a collection of ReserveRelation objects.
      • getItemTransferRelations

        public java.util.List<ItemTransferRelation> getItemTransferRelations​(ItemType type)
        Returns a collection of the item relations concerning the given Item.
        Specified by:
        getItemTransferRelations in interface Unit
        Returns:
        a collection of ItemTransferRelation objects.
      • getPersonTransferRelations

        public java.util.List<PersonTransferRelation> getPersonTransferRelations()
        Returns a collection of the person relations associated with this unit
        Specified by:
        getPersonTransferRelations in interface Unit
        Returns:
        a collection of PersonTransferRelation objects.
      • getModifiedItems

        public java.util.Collection<Item> getModifiedItems()
        Returns the items of this unit as they would appear after the orders of this unit have been processed.
        Specified by:
        getModifiedItems in interface Unit
        Returns:
        a collection of Item objects.
      • getPersons

        public int getPersons()
        Description copied from interface: Unit
        Returns the number of persons in this unit.
        Specified by:
        getPersons in interface Unit
        See Also:
        Unit.getPersons()
      • getModifiedPersons

        public int getModifiedPersons()
        Returns the number of persons in this unit as it would be after the orders of this and other units have been processed since it may be modified by transfer orders.
        Specified by:
        getModifiedPersons in interface Unit
      • getModifiedCombatStatus

        public int getModifiedCombatStatus()
        Returns the new Combat Status of this unit as it would be after the orders of this unit
        Specified by:
        getModifiedCombatStatus in interface Unit
      • getModifiedGuard

        public int getModifiedGuard()
        Returns the new (expected) guard value of this unit as it would be after the orders of this unit (and the unit is still alive next turn) (@TODO: do we need a region.getModifiedGuards - List? guess and hope not)
        Specified by:
        getModifiedGuard in interface Unit
      • getModifiedUnaided

        public boolean getModifiedUnaided()
        Returns the new Unaided status of this unit as it would be after the orders of this unit
        Specified by:
        getModifiedUnaided in interface Unit
      • isWeightWellKnown

        public boolean isWeightWellKnown()
        Specified by:
        isWeightWellKnown in interface Unit
        Returns:
        true if weight is well known and NOT evaluated by Magellan
      • getWeight

        @Deprecated
        public int getWeight()
        Returns the initial overall weight of this unit (persons and items) in silver. If this information is available from the report we use this. Otherwise we call the game specific weight calculation.
        Specified by:
        getWeight in interface Unit
        Returns:
        the initial weight of the unit
      • getSimpleWeight

        public int getSimpleWeight()
        Description copied from interface: Unit
        Returns the overall weight of this unit (persons and items) in silver if it is known, otherwise -1.
        Specified by:
        getSimpleWeight in interface Unit
        See Also:
        Unit.getSimpleWeight()
      • getPayloadOnHorse

        @Deprecated
        public int getPayloadOnHorse()
        Returns the maximum payload in silver of this unit when it travels by horse. Horses, carts and persons are taken into account for this calculation. If the unit has a sufficient skill in horse riding but there are too many carts for the horses, the weight of the additional carts are also already considered.
        Specified by:
        getPayloadOnHorse in interface Unit
        Returns:
        the payload in silver, CAP_NO_HORSES if the unit does not possess horses or CAP_UNSKILLED if the unit is not sufficiently skilled in horse riding to travel on horseback.
      • getPayloadOnFoot

        @Deprecated
        public int getPayloadOnFoot()
        Returns the maximum payload in silver of this unit when it travels on foot. Horses, carts and persons are taken into account for this calculation. If the unit has a sufficient skill in horse riding but there are too many carts for the horses, the weight of the additional carts are also already considered. The calculation also takes into account that trolls can tow carts.
        Specified by:
        getPayloadOnFoot in interface Unit
        Returns:
        the payload in silver, CAP_UNSKILLED if the unit is not sufficiently skilled in horse riding to travel on horseback.
      • getLoad

        @Deprecated
        public int getLoad()
        Returns the weight of all items of this unit that are not horses or carts in silver
        Specified by:
        getLoad in interface Unit
      • getRadius

        @Deprecated
        public int getRadius()
        Returns the number of regions this unit is able to travel within one turn based on the riding skill, horses, carts and load of this unit.
        Specified by:
        getRadius in interface Unit
      • getModifiedWeight

        @Deprecated
        public int getModifiedWeight()
        Returns the overall weight (persons, items) of this unit in silver by calling the game specific calculation for the modified weight. Generally this should take care of modified persons and modified items.
        Specified by:
        getModifiedWeight in interface Unit
        Returns:
        the modified weight of the unit
      • getPassengers

        public java.util.Collection<Unit> getPassengers()
        Returns all units this unit is transporting as passengers.
        Specified by:
        getPassengers in interface Unit
        Returns:
        A Collection of transported Units
      • getCarriers

        public java.util.Collection<Unit> getCarriers()
        Returns all units indicating by their orders that they would transport this unit as a passenger (if there is more than one such unit, that is a semantical error of course).
        Specified by:
        getCarriers in interface Unit
        Returns:
        A Collection of Units carrying this one
      • getPupils

        public java.util.Collection<Unit> getPupils()
        Returns a Collection of all the units that are taught by this unit.
        Specified by:
        getPupils in interface Unit
        Returns:
        A Collection of Units taught by this unit
      • getTeachers

        public java.util.Collection<Unit> getTeachers()
        Returns a Collection of all the units that are teaching this unit.
        Specified by:
        getTeachers in interface Unit
        Returns:
        A Collection of Units teaching this unit
      • refreshRelations

        @Deprecated
        public void refreshRelations()
        Deprecated.
        relation refreshing is now done event-based
        Parses the orders of this unit and detects relations between units established by those orders. When does this method have to be called? No relation of a unit can affect an object outside the region that unit is in. So when all relations regarding a certain unit as target or source need to be determined, this method has to be called for each unit in the same region. Since relations are defined by unit orders, modified orders may lead to different relations. Therefore refreshRelations() has to be invoked on a unit after its orders were modified.
        Specified by:
        refreshRelations in interface Unit
      • refreshRelations

        @Deprecated
        public void refreshRelations​(int from)
        Deprecated.
        relation refreshing is now done event-based
        Parses the orders of this unit beginning at the fromth order and detects relations between units established by those orders. When does this method have to be called? No relation of a unit can affect an object outside the region that unit is in. So when all relations regarding a certain unit as target or source need to be determined, this method has to be called for each unit in the same region. Since relations are defined by unit orders, modified orders may lead to different relations. Therefore refreshRelations() has to be invoked on a unit after its orders were modified.
        Specified by:
        refreshRelations in interface Unit
        Parameters:
        from - Start from this line
      • toString

        public java.lang.String toString()
        Returns a String representation of this unit.
        Specified by:
        toString in interface Unit
        Overrides:
        toString in class MagellanNamedImpl
      • toString

        public java.lang.String toString​(boolean withName)
        Specified by:
        toString in interface Unit
        Parameters:
        withName -
      • extractTempUnits

        public int extractTempUnits​(GameData gdata,
                                    int tempSortIndex)
        Scans this unit's orders for temp units to create. It constructs them as TempUnit objects and removes the corresponding orders from this unit. Uses the default order locale to parse the orders.
        Specified by:
        extractTempUnits in interface Unit
        Parameters:
        tempSortIndex - an index for sorting units (required to reconstruct the original order in the report) which is incremented with each new temp unit.
        Returns:
        the new sort index. return value - sortIndex is the number of temp units read from this unit's orders.
      • extractTempUnits

        public int extractTempUnits​(GameData gdata,
                                    int tempSortIndex,
                                    java.util.Locale locale)
        Scans this unit's orders for temp units to create. It constructs them as TempUnit objects and removes the corresponding orders from this unit.
        Specified by:
        extractTempUnits in interface Unit
        Parameters:
        tempSortIndex - an index for sorting units (required to reconstruct the original order in the report) which is incremented with each new temp unit.
        locale - the locale to parse the orders with.
        Returns:
        the new sort index. return value - sortIndex is the number of temp units read from this unit's orders.
      • getTag

        public java.lang.String getTag​(java.lang.String tag)
        Description copied from interface: Taggable
        Return the value of the tag with key tag from this object.
        Specified by:
        getTag in interface Taggable
        Returns:
        The value of the tag tag or null if no such tag exists.
        See Also:
        Taggable.getTag(java.lang.String)
      • getTagMap

        public java.util.Map<java.lang.String,​java.lang.String> getTagMap()
        Description copied from interface: Taggable
        Returns a Map containing all tags and their values associated with this object.
        Specified by:
        getTagMap in interface Taggable
        See Also:
        Taggable.getTagMap()
      • hasTags

        public boolean hasTags()
        Description copied from interface: Taggable
        Returns true if there are any tags associated with this object.
        Specified by:
        hasTags in interface Taggable
        See Also:
        Taggable.hasTags()
      • getAura

        public int getAura()
        Returns the value of aura.
        Specified by:
        getAura in interface Unit
        Returns:
        Returns aura.
      • setAura

        public void setAura​(int aura)
        Sets the value of aura.
        Specified by:
        setAura in interface Unit
        Parameters:
        aura - The value for aura.
      • getAuraMax

        public int getAuraMax()
        Returns the value of auraMax.
        Specified by:
        getAuraMax in interface Unit
        Returns:
        Returns auraMax.
      • setAuraMax

        public void setAuraMax​(int auraMax)
        Sets the value of auraMax.
        Specified by:
        setAuraMax in interface Unit
        Parameters:
        auraMax - The value for auraMax.
      • hasCache

        public boolean hasCache()
        Description copied from interface: HasCache
        Returns false if this unit does not have a cache. The reverse is not always true:
        If this method returns false, a subsequent call to getCache() will always create a new cache.
        If this method returns true, a subsequent call to getCache() may or may not create a new cache.
        Specified by:
        hasCache in interface HasCache
        See Also:
        HasCache.hasCache()
      • getCache

        public Cache getCache()
        Returns the value of cache.
        Specified by:
        getCache in interface HasCache
        Returns:
        Returns cache.
      • setCache

        public void setCache​(Cache cache)
        Sets the value of cache.
        Specified by:
        setCache in interface HasCache
        Parameters:
        cache - The value for cache.
      • getCombatSpells

        public java.util.Map<ID,​CombatSpell> getCombatSpells()
        Returns the value of combatSpells.
        Specified by:
        getCombatSpells in interface Unit
        Returns:
        Returns combatSpells.
      • setCombatSpells

        public void setCombatSpells​(java.util.Map<ID,​CombatSpell> combatSpells)
        Sets the value of combatSpells.
        Specified by:
        setCombatSpells in interface Unit
        Parameters:
        combatSpells - The value for combatSpells.
      • getCombatStatus

        public int getCombatStatus()
        Returns the value of combatStatus.
        Specified by:
        getCombatStatus in interface Unit
        Returns:
        Returns combatStatus.
      • setCombatStatus

        public void setCombatStatus​(int combatStatus)
        Sets the value of combatStatus.
        Specified by:
        setCombatStatus in interface Unit
        Parameters:
        combatStatus - The value for combatStatus.
      • getComments

        public java.util.List<java.lang.String> getComments()
        Returns the value of comments.
        Specified by:
        getComments in interface Unit
        Returns:
        Returns comments.
      • setComments

        public void setComments​(java.util.List<java.lang.String> comments)
        Sets the value of comments.
        Specified by:
        setComments in interface Unit
        Parameters:
        comments - The value for comments.
      • getEffects

        public java.util.List<java.lang.String> getEffects()
        Returns the value of effects.
        Specified by:
        getEffects in interface Unit
        Returns:
        Returns effects.
      • setEffects

        public void setEffects​(java.util.List<java.lang.String> effects)
        Sets the value of effects.
        Specified by:
        setEffects in interface Unit
        Parameters:
        effects - The value for effects.
      • getFamiliarmageID

        public ID getFamiliarmageID()
        Returns the value of familiarmageID.
        Specified by:
        getFamiliarmageID in interface Unit
        Returns:
        Returns familiarmageID.
      • setFamiliarmageID

        public void setFamiliarmageID​(ID familiarmageID)
        Sets the value of familiarmageID.
        Specified by:
        setFamiliarmageID in interface Unit
        Parameters:
        familiarmageID - The value for familiarmageID.
      • getFollows

        public Unit getFollows()
        Returns the value of follows.
        Specified by:
        getFollows in interface Unit
        Returns:
        Returns follows.
      • setFollows

        public void setFollows​(Unit follows)
        Sets the value of follows.
        Specified by:
        setFollows in interface Unit
        Parameters:
        follows - The value for follows.
      • getGuard

        public int getGuard()
        Returns the value of guard.
        Specified by:
        getGuard in interface Unit
        Returns:
        Returns guard.
      • setGuard

        public void setGuard​(int guard)
        Sets the value of guard.
        Specified by:
        setGuard in interface Unit
        Parameters:
        guard - The value for guard.
      • getHealth

        public java.lang.String getHealth()
        Returns the value of health.
        Specified by:
        getHealth in interface Unit
        Returns:
        Returns health.
      • setHealth

        public void setHealth​(java.lang.String health)
        Sets the value of health.
        Specified by:
        setHealth in interface Unit
        Parameters:
        health - The value for health.
      • isHideFaction

        public boolean isHideFaction()
        Returns the value of hideFaction.
        Specified by:
        isHideFaction in interface Unit
        Returns:
        Returns hideFaction.
      • setHideFaction

        public void setHideFaction​(boolean hideFaction)
        Sets the value of hideFaction.
        Specified by:
        setHideFaction in interface Unit
        Parameters:
        hideFaction - The value for hideFaction.
      • isHero

        public boolean isHero()
        Returns the value of isHero.
        Specified by:
        isHero in interface Unit
        Returns:
        Returns isHero.
      • setHero

        public void setHero​(boolean isHero)
        Sets the value of isHero.
        Specified by:
        setHero in interface Unit
        Parameters:
        isHero - The value for isHero.
      • isStarving

        public boolean isStarving()
        Returns the value of isStarving.
        Specified by:
        isStarving in interface Unit
        Returns:
        Returns isStarving.
      • setStarving

        public void setStarving​(boolean isStarving)
        Sets the value of isStarving.
        Specified by:
        setStarving in interface Unit
        Parameters:
        isStarving - The value for isStarving.
      • isOrdersConfirmed

        public boolean isOrdersConfirmed()
        Returns the value of ordersConfirmed.
        Specified by:
        isOrdersConfirmed in interface Unit
        Returns:
        Returns ordersConfirmed.
      • setOrdersConfirmed

        public void setOrdersConfirmed​(boolean ordersConfirmed)
        Sets the value of ordersConfirmed.
        Specified by:
        setOrdersConfirmed in interface Unit
        Parameters:
        ordersConfirmed - The value for ordersConfirmed.
      • getPrivDesc

        public java.lang.String getPrivDesc()
        Returns the value of privDesc.
        Specified by:
        getPrivDesc in interface Unit
        Returns:
        Returns privDesc.
      • setPrivDesc

        public void setPrivDesc​(java.lang.String privDesc)
        Sets the value of privDesc.
        Specified by:
        setPrivDesc in interface Unit
        Parameters:
        privDesc - The value for privDesc.
      • getRace

        public Race getRace()
        Description copied from interface: Unit
        Returns race.
        Warning: This should the real race but could be the disguised race!
        Specified by:
        getRace in interface Unit
        Returns:
        Returns race.
        See Also:
        Unit.getRace()
      • setRace

        public void setRace​(Race race)
        Sets the value of race.
        Specified by:
        setRace in interface Unit
        Parameters:
        race - The value for race.
      • getDisguiseRace

        public Race getDisguiseRace()
        Description copied from interface: Unit
        Returns the disguised race or null if unit has no race disguise.
        Specified by:
        getDisguiseRace in interface Unit
        Returns:
        the disguised race or null if unit has no race disguise.
        See Also:
        Unit.getDisguiseRace()
      • setRealRace

        public void setRealRace​(Race realRace)
        Sets the value of realRace.
        Specified by:
        setRealRace in interface Unit
        Parameters:
        realRace - The value for realRace.
      • getSiege

        public Building getSiege()
        Returns the value of siege.
        Specified by:
        getSiege in interface Unit
        Returns:
        Returns siege.
      • setSiege

        public void setSiege​(Building siege)
        Sets the value of siege.
        Specified by:
        setSiege in interface Unit
        Parameters:
        siege - The value for siege.
      • getSpells

        public java.util.Map<ID,​Spell> getSpells()
        Returns the value of spells.
        Specified by:
        getSpells in interface Unit
        Returns:
        Returns spells.
      • setSpells

        public void setSpells​(java.util.Map<ID,​Spell> spells)
        Sets the value of spells.
        Specified by:
        setSpells in interface Unit
        Parameters:
        spells - The value for spells.
      • getStealth

        public int getStealth()
        Returns the value of stealth.
        Specified by:
        getStealth in interface Unit
        Returns:
        Returns stealth.
      • setStealth

        public void setStealth​(int stealth)
        Sets the value of stealth.
        Specified by:
        setStealth in interface Unit
        Parameters:
        stealth - The value for stealth.
      • isUnaided

        public boolean isUnaided()
        Returns the value of unaided.
        Specified by:
        isUnaided in interface Unit
        Returns:
        Returns unaided.
      • setUnaided

        public void setUnaided​(boolean unaided)
        Sets the value of unaided.
        Specified by:
        setUnaided in interface Unit
        Parameters:
        unaided - The value for unaided.
      • getUnitMessages

        public java.util.List<Message> getUnitMessages()
        Returns the value of unitMessages.
        Specified by:
        getUnitMessages in interface Unit
        Returns:
        Returns unitMessages.
      • setUnitMessages

        public void setUnitMessages​(java.util.List<Message> unitMessages)
        Sets the value of unitMessages.
        Specified by:
        setUnitMessages in interface Unit
        Parameters:
        unitMessages - The value for unitMessages.
      • setPersons

        public void setPersons​(int persons)
        Sets the value of persons.
        Specified by:
        setPersons in interface Unit
        Parameters:
        persons - The value for persons.
      • setSkills

        public void setSkills​(java.util.Map<StringID,​Skill> skills)
        Sets the value of skills.
        Specified by:
        setSkills in interface Unit
        Parameters:
        skills - The value for skills.
      • setWeight

        public void setWeight​(int weight)
        Sets the value of weight.
        Specified by:
        setWeight in interface Unit
        Parameters:
        weight - The value for weight.
      • getSkillMap

        public java.util.Map<StringID,​Skill> getSkillMap()
        Description copied from interface: Unit
        Returns the skills of the unit. Changes to the result are reflected in the unit's skills!
        Specified by:
        getSkillMap in interface Unit
        See Also:
        Unit.getSkillMap()
      • getPastMovement

        public java.util.List<CoordinateID> getPastMovement​(GameData gdata)
        this function inspects travelthru an travelthruship to find the movement in the past
        Specified by:
        getPastMovement in interface Unit
        Returns:
        List of coordinates from start to end region.
      • isPastMovementPassive

        public boolean isPastMovementPassive​(GameSpecificStuff gameSpecificStuff)
        Description copied from interface: Unit
        Checks if the unit's movement was passive (transported or shipped).
        Specified by:
        isPastMovementPassive in interface Unit
        Returns:
        true if the unit's movement was passive (transported or shipped).
      • reparseOrders

        public void reparseOrders()
        Description copied from interface: Unit
        Invoke the order parser again on all orders.
        Specified by:
        reparseOrders in interface Unit
        See Also:
        Unit.reparseOrders()
      • detach

        public void detach()
        Description copied from interface: Unit
        Detach a unit from the active report, i.e. remove it from its region, faction and other containers.
        Specified by:
        detach in interface Unit
        See Also:
        Unit.detach()
      • isDetailsKnown

        public boolean isDetailsKnown()
        Description copied from interface: Unit
        Returns true iff the all attributes of the unit are known. So it should be true the units of the owner of a server report and false for all others.
        Specified by:
        isDetailsKnown in interface Unit
        See Also:
        Unit.isDetailsKnown()