Class CityHallEngine
- java.lang.Object
-
- ch.sahits.game.openpatrician.engine.AbstractEngine
-
- ch.sahits.game.openpatrician.engine.land.city.CityHallEngine
-
public class CityHallEngine extends AbstractEngine
Engine for controlling the aspects of the city government. This engine handles all cities.- Author:
- Andi Hotz, (c) Sahits GmbH, 2015 Created on Mar 14, 2015
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CityHallEngine.CityInitialisation
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CityHallEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkPetitions(ICityHall cityHall)
void
checkPirateKilledAldermanTask(ShipAttackEvent event)
Check if the destroyed ship was a pirate ship that belongs to an alderman task.private void
checkTasksFinished(IAldermanOffice office)
private void
checkViolations(IAldermanOffice office, ICitizen alderman, ICityHall cityHall)
private int
countMilitia(java.util.List<ICityGuard> cityGuard, java.lang.Class<? extends ICityGuard> clazz)
private void
electNewAlderman(ICityHall cityHall)
private void
electNewMayor(ICityHall cityHall)
void
establishCityHall(ICity city)
private IAldermanOffice
getAldermanOffice()
java.util.List<AbstractEngine>
getChildren()
Any engine may hold various child engines.private int
getLimit(ICityHall cityHall, ICityPetition petition)
Calculate the limit for a petition.private int
getLimit(ICity city, ICityViolation violation)
Calculate the limit for a violation.private void
handleAcceptedCityPetition(ICityHall cityHall, ICityPetition petition)
The city council accepted a petition, execute it.private void
handleAldermansTask(IAldermanOffice office)
private void
handleCityViolationPunishment(ICityViolation violation)
The Hanseatic council agreed on a punishment for a city violation, execute it.void
handleDailyUpdate(ClockTickDayChange event)
private void
handleDeniedCityPetition(ICityHall cityHall, ICityPetition petition)
The city council decided against a petition, inform.private void
handleDeniedCityViolation(ICityViolation violation)
The Hanseatic council decided not to punish a city for its violation, notify.void
handleEndOfYearUpdate(PeriodicalTimeYearEndUpdate event)
void
handleGameStartEvent(NewGameClient newGameClient)
private void
handleMayoralTasks(ICityHall cityHall)
void
handleMonthlyUpdate(PeriodicalTimeMonthEndUpdate event)
void
handleShipNearingPort(ShipNearingPortEvent event)
void
handleWeeklyUpdate(PeriodicalTimeWeekEndUpdate event)
private void
init()
private ICityHall
initializeCity(ICity city)
(package private) boolean
isHumanPlayer(ICitizen mayor)
private DisplayMessage
leveySpecialTax(ICityHall cityHall, ISpecialTaxPetition petition)
private void
notificationElectionWinner(ICityHall cityHall)
Publish a message with the winner of the election.private void
postMayoralElectionMessage(DisplayMessage msg)
private void
unregister()
private void
updateAldermanTasks(IAldermanOffice office)
(package private) void
updateTreasuryWeekly(ICityHall cityHall)
Update the treasury.private void
voteOnPetition(ICityHall cityHall)
private void
voteOnViolation(ICityHall cityHall)
-
-
-
Field Detail
-
clientServerEventBus
@Autowired @Qualifier("serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
-
timerEventBus
@Autowired @Qualifier("timerEventBus") private com.google.common.eventbus.AsyncEventBus timerEventBus
-
stateFactory
@Autowired private StateFactory stateFactory
-
rnd
@Autowired private java.util.Random rnd
-
date
@Autowired private Date date
-
citiesInteractionService
@Autowired private MapService citiesInteractionService
-
map
@Autowired private IMap map
-
pirateState
@Autowired private SeaPiratesState pirateState
-
engineFactory
@Autowired private EngineFactory engineFactory
-
peopleFactory
@Autowired private PeopleFactory peopleFactory
-
timedTaskListener
@Autowired private TimedUpdatableTaskList timedTaskListener
-
aldermanCandidates
@Autowired private AldermanCandidateList aldermanCandidates
-
cityHalls
@Autowired private CityHallList cityHalls
-
initialisation
private CityHallEngine.CityInitialisation initialisation
-
aldermanOffice
@Autowired private AldermanOffice aldermanOffice
-
context
@Autowired private DependentAnnotationConfigApplicationContext context
-
dateService
@Autowired private DateService dateService
-
loanerService
@Autowired private LoanerService loanerService
-
cityHallAccessor
@Autowired private ModelStateAccessor cityHallAccessor
-
blockadeEngine
@Autowired private BlockadeEngine blockadeEngine
-
seaFightService
@Autowired private SeaFightService seaFightService
-
translations
@Autowired private ModelTranslations translations
-
armories
@Autowired private ArmoryRegistry armories
-
cityProperties
@Autowired private CityProperties cityProperties
-
-
Method Detail
-
init
@PostConstruct private void init()
-
unregister
@PreDestroy private void unregister()
-
handleWeeklyUpdate
public void handleWeeklyUpdate(PeriodicalTimeWeekEndUpdate event)
-
checkPetitions
private void checkPetitions(ICityHall cityHall)
-
checkViolations
private void checkViolations(IAldermanOffice office, ICitizen alderman, ICityHall cityHall)
-
checkTasksFinished
private void checkTasksFinished(IAldermanOffice office)
-
handleDailyUpdate
public void handleDailyUpdate(ClockTickDayChange event)
-
voteOnViolation
private void voteOnViolation(ICityHall cityHall)
-
voteOnPetition
private void voteOnPetition(ICityHall cityHall)
-
getLimit
private int getLimit(ICityHall cityHall, ICityPetition petition)
Calculate the limit for a petition.- Parameters:
cityHall
- in which to place hte petitionpetition
- to be placed- Returns:
- limit required for the petition to pass.
-
getLimit
private int getLimit(ICity city, ICityViolation violation)
Calculate the limit for a violation.- Parameters:
city
- for which to calculate the limitviolation
- that is to be checked- Returns:
- limit of the violation.
-
electNewAlderman
private void electNewAlderman(ICityHall cityHall)
-
electNewMayor
private void electNewMayor(ICityHall cityHall)
-
notificationElectionWinner
private void notificationElectionWinner(ICityHall cityHall)
Publish a message with the winner of the election.- Parameters:
cityHall
- in which the winner is anounced.
-
handleCityViolationPunishment
private void handleCityViolationPunishment(ICityViolation violation)
The Hanseatic council agreed on a punishment for a city violation, execute it.- Parameters:
violation
- that is to be handled.
-
handleDeniedCityViolation
private void handleDeniedCityViolation(ICityViolation violation)
The Hanseatic council decided not to punish a city for its violation, notify.- Parameters:
violation
- that is to be handled.
-
postMayoralElectionMessage
private void postMayoralElectionMessage(DisplayMessage msg)
-
handleAcceptedCityPetition
private void handleAcceptedCityPetition(ICityHall cityHall, ICityPetition petition)
The city council accepted a petition, execute it.- Parameters:
cityHall
- in which the petition is to be handledpetition
- that is to be handled
-
leveySpecialTax
private DisplayMessage leveySpecialTax(ICityHall cityHall, ISpecialTaxPetition petition)
-
handleDeniedCityPetition
private void handleDeniedCityPetition(ICityHall cityHall, ICityPetition petition)
The city council decided against a petition, inform.- Parameters:
cityHall
- in which the petition is to be deniedpetition
- that is denied
-
handleMonthlyUpdate
public void handleMonthlyUpdate(PeriodicalTimeMonthEndUpdate event)
-
handleAldermansTask
private void handleAldermansTask(IAldermanOffice office)
-
updateAldermanTasks
private void updateAldermanTasks(IAldermanOffice office)
-
handleMayoralTasks
private void handleMayoralTasks(ICityHall cityHall)
-
countMilitia
private int countMilitia(java.util.List<ICityGuard> cityGuard, java.lang.Class<? extends ICityGuard> clazz)
-
isHumanPlayer
boolean isHumanPlayer(ICitizen mayor)
-
handleEndOfYearUpdate
public void handleEndOfYearUpdate(PeriodicalTimeYearEndUpdate event)
-
getChildren
public java.util.List<AbstractEngine> getChildren()
Description copied from class:AbstractEngine
Any engine may hold various child engines. This is the way to retrieve them. If there are no child engines, return an empty list. Subclasses have to implement this in the proper way.- Specified by:
getChildren
in classAbstractEngine
- Returns:
- list of child engines.
-
establishCityHall
public void establishCityHall(ICity city)
-
handleGameStartEvent
public void handleGameStartEvent(NewGameClient newGameClient)
-
handleShipNearingPort
public void handleShipNearingPort(ShipNearingPortEvent event)
-
updateTreasuryWeekly
void updateTreasuryWeekly(ICityHall cityHall)
Update the treasury. Payed taxes and recurring costs (militia, outrigger). This update is done on a weekly basis.
-
checkPirateKilledAldermanTask
public void checkPirateKilledAldermanTask(ShipAttackEvent event)
Check if the destroyed ship was a pirate ship that belongs to an alderman task.- Parameters:
event
- ship attack
-
getAldermanOffice
private IAldermanOffice getAldermanOffice()
-
-