Class ColonyTradeItem

    • Field Detail

      • colonyId

        private java.lang.String colonyId
        The identifier of the colony to change hands.
      • colonyName

        private java.lang.String colonyName
        The colony name, which is useful when the colony is unknown to the offer recipient.
    • Constructor Detail

      • ColonyTradeItem

        public ColonyTradeItem​(Game game,
                               Player source,
                               Player destination,
                               Colony colony)
        Creates a new ColonyTradeItem instance.
        Parameters:
        game - The enclosing Game.
        source - The source Player.
        destination - The destination Player.
        colony - The Colony to trade.
      • ColonyTradeItem

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

      • getColonyId

        protected java.lang.String getColonyId()
      • getColonyName

        protected java.lang.String getColonyName()
      • 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.
      • getColony

        public Colony getColony​(Game game)
        Get the colony to trade.
        Overrides:
        getColony in class TradeItem
        Parameters:
        game - A Game to look for the colony in.
        Returns:
        The Colony 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