Class InciteTradeItem

  • All Implemented Interfaces:
    java.lang.Comparable<FreeColObject>, ObjectWithId

    public class InciteTradeItem
    extends TradeItem
    A trade item consisting of a player to incite war against.
    • Constructor Detail

      • InciteTradeItem

        public InciteTradeItem​(Game game,
                               Player source,
                               Player destination,
                               Player victim)
        Creates a new InciteTradeItem inincite.
        Parameters:
        game - The enclosing Game.
        source - The source Player.
        destination - The destination Player.
        victim - The Player to incite against.
      • InciteTradeItem

        public InciteTradeItem​(Game game,
                               FreeColXMLReader xr)
                        throws javax.xml.stream.XMLStreamException
        Creates a new InciteTradeItem inincite.
        Parameters:
        game - The enclosing Game.
        xr - A FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is an error reading the stream.
    • Method Detail

      • isValid

        public boolean isValid()
        Is this trade item valid? That is, is the request well formed.
        Specified by:
        isValid in class TradeItem
        Returns:
        True if the item is valid.
      • isUnique

        public boolean isUnique()
        Is this trade item unique? This is true for the StanceTradeItem and the GoldTradeItem, and false for all others.
        Specified by:
        isUnique in class TradeItem
        Returns:
        True if the item is unique.
      • getLabel

        public StringTemplate getLabel()
        Get a label for this item.
        Specified by:
        getLabel in class TradeItem
        Returns:
        A StringTemplate describing this item.
      • getVictim

        public Player getVictim()
        Get the victim player to incite war against.
        Overrides:
        getVictim in class TradeItem
        Returns:
        The Player to trade.
      • evaluateFor

        public int evaluateFor​(Player player)
        Evaluate this trade item for a given player.
        Specified by:
        evaluateFor in class TradeItem
        Parameters:
        player - The Player to evaluate for.
        Returns:
        A value for the player, INVALID_TRADE_ITEM for invalid.
      • copyIn

        public <T extends FreeColObject> boolean copyIn​(T other)
        Copy another FreeColObject into this one if it is compatible.
        Overrides:
        copyIn in class TradeItem
        Type Parameters:
        T - The FreeColObject subclass of the object to copy in.
        Parameters:
        other - The other object.
        Returns:
        True if the copy in is succesful.
      • 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 TradeItem
        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 TradeItem
        Parameters:
        xr - The FreeColXMLReader to read from.
        Throws:
        javax.xml.stream.XMLStreamException - if there is a problem reading the stream.
      • getXMLTagName

        public java.lang.String getXMLTagName()
        Get the serialization tag for this object.
        Specified by:
        getXMLTagName in class FreeColObject
        Returns:
        The tag.
      • equals

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