Class GameMap

  • All Implemented Interfaces:
    IMap

    @Component
    @Lazy
    @DependentInitialisation(StartNewGameBean.class)
    public class GameMap
    extends java.lang.Object
    implements IMap
    Implementation of the game map. This singleton is instaniated by the Game Factory.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2011 Created on Sep 16, 2011
    • Field Detail

      • cities

        private final java.util.LinkedList<ICity> cities
      • dimension

        private javafx.geometry.Dimension2D dimension
      • mapImagePath

        private java.lang.String mapImagePath
      • mapBWImagePath

        private java.lang.String mapBWImagePath
      • numberOfPixelPerKilometer

        private double numberOfPixelPerKilometer
      • futureTowns

        private final java.util.List<IFutureTowns> futureTowns
      • landbridges

        private final java.util.List<ILandBridge> landbridges
      • pirateNests

        private final java.util.List<PirateNest> pirateNests
      • townsInFounding

        private final com.google.common.collect.Multimap<IPlayer,​ICity> townsInFounding
      • cityCoordinates

        private java.util.List<javafx.geometry.Point2D> cityCoordinates
      • tradeRoutes

        private java.util.Set<ITradeRoute> tradeRoutes
      • clientServerEventBus

        @Autowired
        @Qualifier("serverClientEventBus")
        private com.google.common.eventbus.AsyncEventBus clientServerEventBus
    • Constructor Detail

      • GameMap

        public GameMap()
    • Method Detail

      • setup

        public void setup​(java.util.Collection<ICity> cities,
                          javafx.geometry.Dimension2D dim,
                          java.lang.String mapName,
                          java.lang.String bwImageName,
                          double numberOfPixelPerKilometer)
        Initialize the map by means of a list of its cities.
        Parameters:
        cities - List of cities for which to set up the map
        dim - dimensions of the map
        bwImageName - black and white image filename distinguishing land and sea
        mapName - image filename
        numberOfPixelPerKilometer - ratio of pixels that make up one km on the map
      • getNumberCities

        public int getNumberCities()
        Description copied from interface: IMap
        Retrieve the number of cities that are on the map.
        Specified by:
        getNumberCities in interface IMap
        Returns:
        number of cities on the map.
      • getCities

        public java.util.List<ICity> getCities()
        Description copied from interface: IMap
        Retrieve an unmodifiable list of all the cities in the map
        Specified by:
        getCities in interface IMap
        Returns:
        list of cities on the map, visible by all players.
      • findCity

        public ICity findCity​(java.lang.String cityName)
        Description copied from interface: IMap
        Find a city by its name.
        Specified by:
        findCity in interface IMap
        Parameters:
        cityName - name of the city
        Returns:
        city reference.
      • add

        public void add​(ICity city)
        Description copied from interface: IMap
        Add a new city.
        Specified by:
        add in interface IMap
        Parameters:
        city - to be added
      • getCities

        public java.util.List<ICity> getCities​(IPlayer player)
        Description copied from interface: IMap
        Retrieve an unmodifiable list of all the cities in the map also including the once only visible to the player.
        Specified by:
        getCities in interface IMap
        Parameters:
        player - for whom the cities are visible.
        Returns:
        list of cities on the map, inculding the ones only visible to player
      • findCity

        public java.util.Optional<ICity> findCity​(javafx.geometry.Point2D location)
        Description copied from interface: IMap
        Find the city at the given coordinates.
        Specified by:
        findCity in interface IMap
        Parameters:
        location - of the supposed city.
        Returns:
        instance of the city or null if at the coordinates there is no city.
      • addTradeRoute

        public void addTradeRoute​(ITradeRoute tradeRoute)