Class MarketplaceTile


  • public class MarketplaceTile
    extends Tile
    A Marketplace is a tile producing money. This tile can sell food an materials for money.
    • Field Detail

      • food

        public double food
        amount of food being sold
      • materials

        public double materials
        amount of materials being sold
      • economy

        public Metrics economy
        contains a economy tracker of this marketplace. money is the earned money. food and materials are the sold goods. (note they are negative)
    • Constructor Detail

      • MarketplaceTile

        public MarketplaceTile()
        Creates a coordinate less market place tile.
      • MarketplaceTile

        public MarketplaceTile​(CubeCoordinate coord)
        Creates a market place with coordinates.
        Parameters:
        coord - coordinate of the market place
      • MarketplaceTile

        public MarketplaceTile​(MarketplaceTile other)
        Creates a copy/clone of a market place.
        Parameters:
        other - marketplace to clone
      • MarketplaceTile

        public MarketplaceTile​(CubeCoordinate coord,
                               org.json.JSONObject data)
        Creates a market place with a coordinate and extra json meta data.
        Parameters:
        coord - coordinate of the tile
        data - extra data
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from class: Tile
        Name of Tile in Api interface.
        Specified by:
        getName in class Tile
        Returns:
        api name of the tile
      • serializeData

        public org.json.JSONObject serializeData()
        Description copied from class: Tile
        Serializes extra Data of an Tile, to be send.
        Overrides:
        serializeData in class Tile
        Returns:
        null or JSONObject with at least a valid "type" field.
      • clone

        public Tile clone()
        Description copied from class: Tile
        Creates a clone of the tile.
        Specified by:
        clone in class Tile
        Returns:
        the new tile
      • getEconomy

        public Metrics getEconomy()
        Marketplaces trade materials and food for money. Use this method to get the total amount sold and money collected. Note: materials and food are negative, because you sold them and money is positive, because you got it.
        Returns:
        Metrics object encoding Marketplace economy.
      • withFoodRatio

        public MarketplaceTile withFoodRatio​(double food)
        Sets ratio of food that should be sold in the area around this marketplace. Will only be applied when placing the tile. Use ConfigureMarketplaceTileAction to change an existing tile.
        Parameters:
        food - Materials sale ration [0,1]
        Returns:
        returns this
      • withMaterialsRatio

        public MarketplaceTile withMaterialsRatio​(double materials)
        Sets ratio of materials that should be sold in the area around this marketplace. Will only be applied when placing the tile. Use ConfigureMarketplaceTileAction to change an existing tile.
        Parameters:
        materials - Materials sale ration [0,1]
        Returns:
        returns this
      • dataToString

        public java.lang.String dataToString()
        Description copied from class: Tile
        Can be used by tile to add internal data to `toString`. Returned string should start with: ", "
        Overrides:
        dataToString in class Tile
        Returns:
        additional data stringified