Class GameFactory
- java.lang.Object
-
- ch.sahits.game.openpatrician.clientserverinterface.model.factory.GameFactory
-
public class GameFactory extends java.lang.ObjectFactory 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
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description GameFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.time.LocalDateTimecomputeRandomBirthDate(int age)IAIPlayercreateAIPlayer(ICity homeTown, long cash)Create an artifiacial player instance.private CompanycreateCompany(ICity homeTown, long cash)IGamecreateGame(EObjective objective, Difficulty difficulty, EGameSpeed speed, boolean singleplayer)IMapcreateMap(java.lang.String mapName)Create the map with all cities defined in its XML definitionIHumanPlayercreatePlayer(java.lang.String name, java.lang.String lastName, ICity homeTown, boolean male, int cash, EPlayerColor color)Create a human player instance.CityStategetCityState(ICity city)Retrieve the city state for the city.IGamegetGame()private CityStateinitCityPropertyState(ICity city)private voidinitPlayerInCities(IPlayer player)Init the player data in all cities
-
-
-
Field Detail
-
rnd
@Autowired private java.util.Random rnd
-
cityFactory
@Autowired private CityFactory cityFactory
-
date
@Autowired private Date date
-
buildingFactory
@Autowired private BuildingFactory buildingFactory
-
game
private IGame game
-
context
@Autowired private org.springframework.context.ApplicationContext context
-
cityRegistry
@Autowired private CityRegistry cityRegistry
-
players
@Autowired private PlayerList players
-
aiPlayers
@Autowired private AIPlayerList aiPlayers
-
shipNameLoader
@Autowired @Qualifier("shipNameLoader") private RandomNameLoader shipNameLoader
-
shipFactory
@Autowired private ShipFactory shipFactory
-
mapLoader
@Autowired private IMapSegmentImageCreator mapLoader
-
pointInterner
@Autowired protected com.google.common.collect.Interner<javafx.geometry.Point2D> pointInterner
-
interactionFactory
@Autowired private PlayerInteractionFactory interactionFactory
-
offices
@Autowired private TradingOfficeList offices
-
strategyLoader
@Autowired private AIStrategyLoader strategyLoader
-
strategyHolderService
@Autowired private StrategyHolderService strategyHolderService
-
repairTypes
private java.util.List<IAIShipRepairStrategyType> repairTypes
-
takeLoanStrategies
private java.util.List<IAITakeLoanStrategyType> takeLoanStrategies
-
constructionStrategies
private java.util.List<IAIConstructionSelectionStrategyType> constructionStrategies
-
hireCaptainStrategies
private java.util.List<IAICaptainHireStrategyType> hireCaptainStrategies
-
guildJoinStrategies
private java.util.List<IAIGuildJoinStrategyType> guildJoinStrategies
-
eventDecisionStrategies
private java.util.List<IAIEventDecisionStrategyType> eventDecisionStrategies
-
hireTradeManagerStrategies
private static java.util.List<IAIHireTradeManagerStrategyType> hireTradeManagerStrategies
-
weaponBuyStrategies
private static java.util.List<IAIBuyWeaponStrategyType> weaponBuyStrategies
-
hireSailorStrategies
private static java.util.List<IAIHireSailorsStrategyType> hireSailorStrategies
-
shipUpgradeStrategies
private static java.util.List<IAIShipUpgradeStrategyType> shipUpgradeStrategies
-
stateFactory
private StateFactory stateFactory
-
locationTracker
private ILocationTracker locationTracker
-
-
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 playerlastName- last name of the playerhomeTown- reference to the player's hometownmale- flag indicating if the player is malecash- initial cash amount of the playercolor- 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 playercash- 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
-
createGame
public IGame createGame(EObjective objective, Difficulty difficulty, EGameSpeed speed, boolean singleplayer)
-
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
-
-