Class ArchetypeType

  • All Implemented Interfaces:
    java.lang.Iterable<ArchetypeAttributeSection>

    public class ArchetypeType
    extends java.lang.Object
    implements java.lang.Iterable<ArchetypeAttributeSection>
    Contains the data of one Gridarta Object-Type. The data is read from a definitions file called 'types.xml'. It is mainly used as info-base for the arch-attribute GUI.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArchetypeType​(@NotNull java.lang.String typeName, int typeNo, @NotNull java.lang.String display, boolean map, int @Nullable [] inv, boolean allowsAllInv, @Nullable java.lang.String description, @Nullable java.lang.String use, @NotNull ArchetypeAttributesDefinition typeAttributes)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addArchetypeAttribute​(@NotNull java.lang.String sectionName, @NotNull ArchetypeAttribute archetypeAttribute)
      Adds an ArchetypeAttribute to this archetype type.
      void addAttributeSection​(@NotNull ArchetypeAttributeSection newArchetypeAttributeSection)
      @NotNull java.lang.String getDescription()
      Returns the description.
      @NotNull java.lang.String getDisplayName​(@NotNull Attributes baseObject)
      Returns a description of this type.
      int @Nullable [] getInv()
      Returns which archetype types allow this archetype type in their inventories.
      @NotNull java.lang.String getTypeName()
      Returns the type name (artificial).
      int getTypeNo()
      Returns the type number.
      @NotNull java.lang.String getUse()
      Returns the usage notes.
      boolean hasAttribute()
      Returns whether this archetype type defines at least one archetype attribute.
      boolean hasAttributeKey​(@NotNull java.lang.Comparable<java.lang.String> key)
      Returns whether an attribute key is defined.
      boolean hasTypeAttributes()
      Returns whether any type attributes are defined.
      boolean isAllowsAllInv()
      Returns whether this archetype type allows any inventory game objects, regardless whether these types have "inv" specifications.
      boolean isMap()
      Returns whether this archetype is allowed on maps.
      @NotNull java.util.Iterator<ArchetypeAttributeSection> iterator()  
      boolean matches​(@NotNull BaseObject<?,​?,​?,​?> baseObject)
      Checks whether a BaseObject matches all type attributes.
      @NotNull java.lang.String toString()  
      void toString​(@NotNull java.lang.StringBuilder sb)
      Appends a string representation of this instance to a StringBuilder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • ArchetypeType

        public ArchetypeType​(@NotNull
                             @NotNull java.lang.String typeName,
                             int typeNo,
                             @NotNull
                             @NotNull java.lang.String display,
                             boolean map,
                             int @Nullable [] inv,
                             boolean allowsAllInv,
                             @Nullable
                             @Nullable java.lang.String description,
                             @Nullable
                             @Nullable java.lang.String use,
                             @NotNull
                             @NotNull ArchetypeAttributesDefinition typeAttributes)
        Creates a new instance.
        Parameters:
        typeName - the type name (artificial)
        typeNo - the type number
        display - additional description text
        map - whether this archetype type is allowed on maps
        inv - which archetype types allow this archetype type in their inventories or null for no restrictions
        allowsAllInv - whether this archetype type allows any inventory game objects, whether these types have "inv" specifications
        description - the description
        use - the usage notes
        typeAttributes - the list of additional attributes
    • Method Detail

      • addAttributeSection

        public void addAttributeSection​(@NotNull
                                        @NotNull ArchetypeAttributeSection newArchetypeAttributeSection)
        Adds an ArchetypeAttributeSection. If the section already exists appends the new attributes to the existing section.
        Parameters:
        newArchetypeAttributeSection - the section to add
      • hasAttribute

        public boolean hasAttribute()
        Returns whether this archetype type defines at least one archetype attribute.
        Returns:
        whether at least one archetype attribute exists
      • getTypeNo

        public int getTypeNo()
        Returns the type number.
        Returns:
        the type number
      • getTypeName

        @NotNull
        public @NotNull java.lang.String getTypeName()
        Returns the type name (artificial).
        Returns:
        the type name
      • isMap

        public boolean isMap()
        Returns whether this archetype is allowed on maps.
        Returns:
        whether this archetype is allowed on maps
      • getInv

        public int @Nullable [] getInv()
        Returns which archetype types allow this archetype type in their inventories.
        Returns:
        the allowed environment types or null for no restrictions
      • isAllowsAllInv

        public boolean isAllowsAllInv()
        Returns whether this archetype type allows any inventory game objects, regardless whether these types have "inv" specifications.
        Returns:
        whether this archetype type allows any inventory game objects
      • getDescription

        @NotNull
        public @NotNull java.lang.String getDescription()
        Returns the description.
        Returns:
        the description
      • getUse

        @NotNull
        public @NotNull java.lang.String getUse()
        Returns the usage notes.
        Returns:
        the usage notes
      • matches

        public boolean matches​(@NotNull
                               @NotNull BaseObject<?,​?,​?,​?> baseObject)
        Checks whether a BaseObject matches all type attributes.
        Parameters:
        baseObject - the base object to check
        Returns:
        whether the base object matches
      • hasTypeAttributes

        public boolean hasTypeAttributes()
        Returns whether any type attributes are defined.
        Returns:
        whether any type attributes are defined
      • hasAttributeKey

        public boolean hasAttributeKey​(@NotNull
                                       @NotNull java.lang.Comparable<java.lang.String> key)
        Returns whether an attribute key is defined.
        Parameters:
        key - the attribute key
        Returns:
        whether the attribute key is defined
      • toString

        @NotNull
        public @NotNull java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public void toString​(@NotNull
                             @NotNull java.lang.StringBuilder sb)
        Appends a string representation of this instance to a StringBuilder.
        Parameters:
        sb - the string builder
      • getDisplayName

        @NotNull
        public @NotNull java.lang.String getDisplayName​(@NotNull
                                                        @NotNull Attributes baseObject)
        Returns a description of this type.
        Parameters:
        baseObject - the base object to describe
        Returns:
        the description
      • addArchetypeAttribute

        public void addArchetypeAttribute​(@NotNull
                                          @NotNull java.lang.String sectionName,
                                          @NotNull
                                          @NotNull ArchetypeAttribute archetypeAttribute)
        Adds an ArchetypeAttribute to this archetype type.
        Parameters:
        sectionName - the name of the section to add to
        archetypeAttribute - the archetype attribute to add