Class GameFactory


  • public class GameFactory
    extends java.lang.Object
    Factory class for game start up. This component is instantiated before the date is set.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2013 Created on Feb 2, 2013
    • Constructor Detail

      • GameFactory

        public GameFactory()
    • Method Detail

      • createPlayer

        public IHumanPlayer createPlayer​(java.lang.String name,
                                         java.lang.String lastName,
                                         ICity homeTown,
                                         boolean male,
                                         int cash,
                                         EPlayerColor color)
        Create a human player instance. Build their trading office in the home town as well.
        Parameters:
        name - first name of the player
        lastName - last name of the player
        homeTown - reference to the player's hometown
        male - flag indicating if the player is male
        cash - initial cash amount of the player
        color - player color
        Returns:
        Human player instance
      • createAIPlayer

        public IAIPlayer createAIPlayer​(ICity homeTown,
                                        long cash)
        Create an artifiacial player instance. Build their trading office in the home town as well.
        Parameters:
        homeTown - home town of the player
        cash - initial cash of the player
        Returns:
        AI player instance
      • initPlayerInCities

        private void initPlayerInCities​(IPlayer player)
        Init the player data in all cities
        Parameters:
        player - to register in all cities.
      • createMap

        public IMap createMap​(java.lang.String mapName)
        Create the map with all cities defined in its XML definition
        Returns:
        standard map of the game
      • getGame

        public IGame getGame()
      • computeRandomBirthDate

        private java.time.LocalDateTime computeRandomBirthDate​(int age)
      • getCityState

        public CityState getCityState​(ICity city)
        Retrieve the city state for the city. This method makes sure that repeated calls with the same city argument return the same instance.
        Parameters:
        city - for which to retrieve the city state
        Returns:
        CityState for the matching city
      • initCityPropertyState

        private CityState initCityPropertyState​(ICity city)
      • createCompany

        private Company createCompany​(ICity homeTown,
                                      long cash)