public class CityState extends Object
| Modifier and Type | Field and Description |
|---|---|
private ICity |
city
Reference to the city model that is driven by this engine
|
private PopulationConsume |
consume
Provider for the consume numbers
|
private Map<IWare,Double> |
consumed
Map of consumed wares, since only whole units can be consumed we need to store the fractions
|
private Map<IWare,Double> |
produced
Map of produced wares, since only whole units can be consumed we need to store the fractions
|
private CityProduction |
production
Mock up to simulate the city production
|
private Random |
rnd |
private IShipyard |
shipyardState
Ship yard state fos the city
|
private StateFactory |
stateFactory |
private double |
surplusThreshold |
private TavernState |
tavernState
Tavern state for this city
|
| Modifier and Type | Method and Description |
|---|---|
void |
consumeWares()
compute the wares consumed in the last 12 hours and remove them from the city
This method is package private for testing purposes
|
com.google.common.base.Optional<IWare> |
findMostNeededWare()
Find the ware which is consumed the most and which is missing for the longest time.
|
com.google.common.base.Optional<IWare> |
findWareWithMostSurplus()
Find the ware that the city sells near the minimal price
|
private void |
initCity() |
void |
produceWares()
Compute the wares produced in the last 12 hours and add the whole quatities to the city.
|
@Autowired private Random rnd
@Value(value="${ware.surplus.treshold}")
private double surplusThreshold
private ICity city
private Map<IWare,Double> consumed
private Map<IWare,Double> produced
@Autowired private CityProduction production
private TavernState tavernState
private IShipyard shipyardState
@Autowired private PopulationConsume consume
@Autowired private StateFactory stateFactory
public CityState(ICity city)
@PostConstruct private void initCity()
public void consumeWares()
public void produceWares()
public com.google.common.base.Optional<IWare> findMostNeededWare()
public com.google.common.base.Optional<IWare> findWareWithMostSurplus()
Copyright © 2011-2015 Sahits GmbH. All Rights Reserved.