Class 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
    • Constructor Detail

      • CityHallEngine

        public CityHallEngine()
    • Method Detail

      • init

        @PostConstruct
        private void init()
      • unregister

        @PreDestroy
        private void unregister()
      • checkPetitions

        private void checkPetitions​(ICityHall cityHall)
      • checkTasksFinished

        private void checkTasksFinished​(IAldermanOffice office)
      • 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 petition
        petition - 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 limit
        violation - 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 handled
        petition - that is to be handled
      • 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 denied
        petition - that is denied
      • 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)
      • 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 class AbstractEngine
        Returns:
        list of child engines.
      • establishCityHall

        public void establishCityHall​(ICity city)
      • handleGameStartEvent

        public void handleGameStartEvent​(NewGameClient newGameClient)
      • 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