Class Units


  • public class Units
    extends java.lang.Object
    • Constructor Detail

      • Units

        public Units()
    • Method Detail

      • isPrivilegedAndNoSpy

        public static boolean isPrivilegedAndNoSpy​(Unit u)
        Returns true iff u is not a spy and belongs to a privileged faction.
      • isAllied

        public static boolean isAllied​(Faction faction,
                                       Faction ally,
                                       int aState)
        Returns true if the help status for aState of the faction includes ally.
        Parameters:
        faction - The source faction
        ally - The potential ally
        aState - The help state, e.g. EresseaConstants.A_GUARD.
        Returns:
        true if the faction's alliance value for the ally includes the state.
      • isAllied

        public static boolean isAllied​(Faction faction,
                                       Faction ally,
                                       int aState,
                                       boolean any)
        Returns true if the help status for aState of the faction includes ally.
        Parameters:
        faction - The source faction
        ally - The potential ally
        aState - The help state, e.g. EresseaConstants.A_GUARD.
        any - if true, this method returns true if the state matches exactly. Otherwise only one of the states that aState is composed of must match.
        Returns:
        true if the faction's alliance value for the ally includes the state.
      • getCaptainSkillAmount

        public static int getCaptainSkillAmount​(Ship s)
        Returns the sailing skill value of the ship's owner
      • getSailingSkillAmount

        public static int getSailingSkillAmount​(Ship s)
        Returns the sailing skill sum of the ship's crew.
      • getContainerPrivilegedUnitItems

        public static java.util.Collection<Units.StatItem> getContainerPrivilegedUnitItems​(UnitContainer container)
        Returns the items of all units that are stationed in this region and belonging to a faction that has at least a privileged trust level.
        Fiete 20061224: ...and the factions with "GIVE" alliances too.
        The amount of the items of a particular item type are added up, so two units with 5 pieces of silver yield one silver item of amount 10 here.
      • getContainerAllUnitItems

        public static java.util.Collection<Units.StatItem> getContainerAllUnitItems​(UnitContainer container)
        Returns the items of all units that are stationed in this region The amount of the items of a particular item type are added up, so two units with 5 pieces of silver yield one silver item of amount 10 here.
      • getContainerUnitItems

        protected static java.util.Collection<Units.StatItem> getContainerUnitItems​(UnitContainer container,
                                                                                    java.util.Map<UnitContainer,​java.lang.ref.Reference<java.util.Map<ID,​Units.StatItem>>> map,
                                                                                    UnitFilter filter)
        Returns the items of all units that are stationed in this region and belonging to a faction that has at least a privileged trust level. The amount of the items of a particular item type are added up, so two units with 5 pieces of silver yield one silver item of amount 10 here.
      • getContainerFactionUnitItem

        public static Units.StatItem getContainerFactionUnitItem​(UnitContainer container,
                                                                 Unit unit,
                                                                 ItemType type)
        Returns an item corresponding to unit's faction's total amount of this item in unit's region. TODO is it worth moving caching it for each faction and region?