Class RegionResource

  • All Implemented Interfaces:
    Unique

    public class RegionResource
    extends java.lang.Object
    implements Unique
    A class representing a resource and its attributes in a region. The id of RegionResource objects is numerical and does not change between reports of different turns, it can therefore be used for merging reports. In order to access a resource in a region this id proves unuseful, though. Instead, the id of the resource's type makes more sense as it also satisfies the uniqueness condition within a region.
    • Constructor Summary

      Constructors 
      Constructor Description
      RegionResource​(ID id, ItemType type)
      Constructs a new region resource with the specified id and type.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAttribute​(java.lang.String key, java.lang.String value)  
      boolean containsAttribute​(java.lang.String key)  
      boolean equals​(java.lang.Object o)
      Indicates whether some other object is "equal to" this one based on the ID of this object
      int getAmount()
      Returns the amount of the resource visible or available.
      java.lang.String getAttribute​(java.lang.String key)  
      java.util.List<java.lang.String> getAttributeKeys()  
      int getAttributeSize()  
      Date getDate()
      Returns the Date, the ressource info was last updated.
      ID getID()
      Returns the id uniquely identifying this resource.
      java.lang.String getName()
      This method is a shortcut for calling this.getType().getName()
      int getSkillLevel()
      Returns the minimum skill level that is required to access this resource.
      ItemType getType()
      Returns the type of this resource.
      int hashCode()
      Returns a hash code value for the object based on the ID of this object.
      static void merge​(GameData curGD, RegionResource curRes, GameData newGD, RegionResource newRes, boolean sameTurn)
      Merges the information of curRes into newRes.
      void setAmount​(int amount)
      Sets the amount of the resource visible or available.
      void setDate​(int Round)
      Specifies the round, in which the information was "new"
      void setID​(ID id)
      This method allows to set the id of this resource even after object creation.
      void setSkillLevel​(int level)
      Sets the minimum skill level that is required to access this resource.
      void setType​(ItemType type)
      Specifies the type of the resource.
      java.lang.String toString()
      Returns a string representation of this resource object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RegionResource

        public RegionResource​(ID id,
                              ItemType type)
        Constructs a new region resource with the specified id and type. There is no default constructor in order to enforce a valid id and type set for every RegionResource object.
    • Method Detail

      • setID

        public void setID​(ID id)
        This method allows to set the id of this resource even after object creation. It should be use with care as ids are often used as map keys or similar objects and changing them will have non-obvious side effects.
        Throws:
        java.lang.IllegalArgumentException - DOCUMENT-ME
      • getID

        public ID getID()
        Returns the id uniquely identifying this resource.
        Specified by:
        getID in interface Unique
      • setType

        public void setType​(ItemType type)
        Specifies the type of the resource. Semantically, only a small range of item types are valid for a resource (iron, trees, etc.) Note that the type may server as a hash object for this resource and changing it may require re-hashing.
        Throws:
        java.lang.IllegalArgumentException - DOCUMENT-ME
      • getType

        public ItemType getType()
        Returns the type of this resource.
      • setDate

        public void setDate​(int Round)
        Specifies the round, in which the information was "new"
        Throws:
        java.lang.IllegalArgumentException - DOCUMENT-ME
      • getDate

        public Date getDate()
        Returns the Date, the ressource info was last updated.
      • setAmount

        public void setAmount​(int amount)
        Sets the amount of the resource visible or available.
      • getAmount

        public int getAmount()
        Returns the amount of the resource visible or available.
      • setSkillLevel

        public void setSkillLevel​(int level)
        Sets the minimum skill level that is required to access this resource.
      • getSkillLevel

        public int getSkillLevel()
        Returns the minimum skill level that is required to access this resource.
      • toString

        public java.lang.String toString()
        Returns a string representation of this resource object.
        Overrides:
        toString in class java.lang.Object
      • getName

        public java.lang.String getName()
        This method is a shortcut for calling this.getType().getName()
      • equals

        public boolean equals​(java.lang.Object o)
        Indicates whether some other object is "equal to" this one based on the ID of this object
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Returns a hash code value for the object based on the ID of this object.
        Overrides:
        hashCode in class java.lang.Object