public class CityUtilities extends Object
| Modifier and Type | Field and Description |
|---|---|
private Date |
date |
private IMap |
map |
private PeopleFactory |
peopleFactory |
private com.google.common.collect.Range<Double> |
range |
private Random |
rnd |
| Constructor and Description |
|---|
CityUtilities() |
| Modifier and Type | Method and Description |
|---|---|
private double |
calculateDistance(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2) |
private boolean |
checkCities(ICity startCity,
List<ICity> exclude)
Check if there is a city that can be choosen
|
javafx.collections.ObservableList<ICityHallNotice> |
createNotices(ICity targetCity) |
Optional<ICity> |
findNearbyCity(ICity startCity,
double radiusFactor,
int max,
List<ICity> exclude)
Find a city nearby.
|
ICity |
findNearbyCityRepeated(ICity startCity,
double radiusFactor,
int max,
List<ICity> exclude)
Find a nearby city.
|
ICity |
findNearestCity(javafx.geometry.Point2D p)
Find the nearest city to a point
|
List<ICity> |
findRandomCities(ICity exclude,
int numberOfCities)
Find up to
numberOfCities random cities that are not the excluded one. |
ICity |
findRandomCity(ICity excludedCity)
Find a random city that is not the excluded city.
|
private ICity |
findRandomCity(List<ICity> excludedCity)
Find a random city that is not the excluded city.
|
SortedMapRandomizedSameElements<Integer,ICitizen> |
getCandidateMap(List<ICitizen> candidates,
ICity city)
Create a sorted map of the candidates according to their reputation.
|
int |
getFine(ECityViolationPunishment punishment,
ITreasury otherTreasury) |
int |
getMaxNumberOfGuards(int population)
Calculate the maximum of possible city guards base on the size of the population
|
@Autowired private IMap map
@Autowired private Random rnd
@Autowired private Date date
@Autowired private PeopleFactory peopleFactory
private final com.google.common.collect.Range<Double> range
public Optional<ICity> findNearbyCity(ICity startCity, double radiusFactor, int max, List<ICity> exclude)
max dimension of the map the radius is calculated with this
factor.
Repeated calls with the same arguments are not guaranteed to deliver the same resultstartCity - city where to startradiusFactor - factor for the radius calculationmax - maximal dimension of the mapexclude - potentially empty list of cities, that should be excluded from the searchpublic ICity findNearbyCityRepeated(ICity startCity, double radiusFactor, int max, List<ICity> exclude)
startCity - city where to startradiusFactor - factor for the radius calculationmax - maximal dimension of the mapexclude - potentially empty list of cities, that should be excluded from the searchfindNearbyCity(ICity, double, int, List)private boolean checkCities(ICity startCity, List<ICity> exclude)
startCity - exclude - public ICity findNearestCity(javafx.geometry.Point2D p)
p - public ICity findRandomCity(ICity excludedCity)
excludedCity - city that cannot be chosen.private ICity findRandomCity(List<ICity> excludedCity)
excludedCity - city that cannot be chosen.private double calculateDistance(javafx.geometry.Point2D p1,
javafx.geometry.Point2D p2)
public List<ICity> findRandomCities(ICity exclude, int numberOfCities)
numberOfCities random cities that are not the excluded one.exclude - city that should be ignorednumberOfCities - number of cities in the list. If the number is bigger than the max amount of cities on the
map, only that amount minus one will be used.public int getMaxNumberOfGuards(int population)
population - of the citypublic javafx.collections.ObservableList<ICityHallNotice> createNotices(ICity targetCity)
public int getFine(ECityViolationPunishment punishment, ITreasury otherTreasury)
public SortedMapRandomizedSameElements<Integer,ICitizen> getCandidateMap(List<ICitizen> candidates, ICity city)
IPlayer
have a reputation any all ICitizen have the same reputation of 0.candidates - Copyright © 2011-2015 Sahits GmbH. All Rights Reserved.