Class Wish

    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • destination

        protected Location destination
        The requesting location of this wish.
      • transportable

        protected TransportableAIObject transportable
        The TransportableAIObject which will realize the wish, or null if none has been assigned.
      • TRANSPORTABLE_TAG

        private static final java.lang.String TRANSPORTABLE_TAG
        See Also:
        Constant Field Values
    • Constructor Detail

      • Wish

        public Wish​(AIMain aiMain,
                    java.lang.String id)
        Creates a new uninitialized Wish.
        Parameters:
        aiMain - The main AI-object.
        id - The object identifier.
      • Wish

        public Wish​(AIMain aiMain,
                    FreeColXMLReader xr)
             throws javax.xml.stream.XMLStreamException
        Creates a new Wish from the given XML-representation.
        Parameters:
        aiMain - The main AI-object.
        xr - The input stream containing the XML.
        Throws:
        javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
    • Method Detail

      • shouldBeStored

        public boolean shouldBeStored()
        Checks if this Wish needs to be stored in a savegame.
        Returns:
        True if it has been allocated a transportable.
      • getDestination

        public final Location getDestination()
        Gets the destination of this Wish.
        Returns:
        The Location in which the transportable assigned to this Wish will have to reach.
      • getDestinationAIColony

        public final AIColony getDestinationAIColony()
        Gets the destination AI colony, if any.
        Returns:
        The destination AIColony.
      • satisfiedBy

        public abstract boolean satisfiedBy​(Unit unit)
        Does a specified unit satisfy this wish?
        Parameters:
        unit - The Unit to test.
        Returns:
        True if the unit either matches exactly if expertRequired, or at least matches in a land/naval sense if not.
      • satisfiedBy

        public abstract <T extends AbstractGoods> boolean satisfiedBy​(T goods)
        Does some specified goods satisfy this wish?
        Type Parameters:
        T - The base type of the goods.
        Parameters:
        goods - The goods to test.
        Returns:
        True if the goods type matches and amount is not less than that requested.
      • dispose

        public void dispose()
        Disposes of this AIObject by removing any references to this object.
        Overrides:
        dispose in class AIObject
      • checkIntegrity

        public Constants.IntegrityType checkIntegrity​(boolean fix,
                                                      LogBuilder lb)
        AIObjects need integrity checking too.
        Overrides:
        checkIntegrity in class AIObject
        Parameters:
        fix - If true, fix problems if possible.
        lb - A LogBuilder to log to.
        Returns:
        -1 if there are problems remaining, zero if problems were fixed, +1 if no problems found at all.
      • writeAttributes

        protected void writeAttributes​(FreeColXMLWriter xw)
                                throws javax.xml.stream.XMLStreamException
        Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.
        Overrides:
        writeAttributes in class ValuedAIObject
        Parameters:
        xw - The FreeColXMLWriter to write to.
        Throws:
        javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.
      • readAttributes

        protected void readAttributes​(FreeColXMLReader xr)
                               throws javax.xml.stream.XMLStreamException
        Reads the attributes of this object from an XML stream.
        Overrides:
        readAttributes in class ValuedAIObject
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class ValuedAIObject