Class AIPlayerEngine

  • All Implemented Interfaces:
    IAIEventHandler

    public class AIPlayerEngine
    extends AbstractEngine
    implements IAIEventHandler
    This implements the engine for an AI Player
    Author:
    Andi Hotz, (c) Sahits GmbH, 2014 Created on Jan 23, 2014
    • Constructor Summary

      Constructors 
      Constructor Description
      AIPlayerEngine()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean executeCurrentTrade​(ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel)
      Check weather the current vessel is engaged in executing trade steps.
      java.util.List<AbstractEngine> getChildren()
      Any engine may hold various child engines.
      void handelLoadedNewGame​(ch.sahits.game.openpatrician.event.GameStateChange event)
      Initialize the visible ships.
      void handleBlockadeStart​(ch.sahits.game.openpatrician.event.data.ai.BlockadeShipRequestEvent event)  
      void handleBuildingAuctionFinished​(ch.sahits.game.openpatrician.event.data.BuildingAuctionFinished event)  
      void handleBuildingNotAuction​(ch.sahits.game.openpatrician.event.data.BuildingNotAuctioned event)  
      void handleConvoyDissolve​(ch.sahits.game.openpatrician.clientserverinterface.model.event.ConvoyDisolveEvent event)  
      void handleDonationRequest​(ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.clientserverinterface.model.event.DonationRequestState state)
      Handle a donation request.
      void handleGameLoad​(ch.sahits.game.openpatrician.event.GameStateChange gameStateChange)
      Listen to the start of the game loading to continue with the handling of ship arrival events.
      void handleMarriageEvent​(ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.clientserverinterface.model.event.MarriageBrokerAnnouncementState state)
      Handle the offer of a marriage broker.
      void handleMarriageWareDelivery​(ch.sahits.game.openpatrician.model.IAIPlayer player, ch.sahits.game.openpatrician.clientserverinterface.model.event.MarriageFeastRequestState state)
      Handle the request to deliver marriage wares.
      void handleShipArrivesInCity​(ch.sahits.game.openpatrician.event.data.ShipEntersPortEvent event)  
      void handleShipAuctionFinished​(ch.sahits.game.openpatrician.event.data.ShipAuctionFinished event)  
      void handleShipConstructionFinished​(ch.sahits.game.openpatrician.model.ship.IShip ship, ch.sahits.game.openpatrician.model.IAIPlayer player)
      Method to handle the finishing of a ship construction.
      void handleShipFittedForOrleg​(ch.sahits.game.openpatrician.clientserverinterface.model.event.OrlegShipOutfittedEvent event)
      When a ship has finally been fitted for orlead duties, create the convoy.
      void handleShipNotAuction​(ch.sahits.game.openpatrician.event.data.ShipNotAuctioned event)  
      void handleSpecialMissionFinished​(ch.sahits.game.openpatrician.event.data.ai.SpecialMissionFinishedEvent event)
      Handle the reinitialisation after finishing a special mission.
      void handleTradeStrategyStart​(ch.sahits.game.openpatrician.event.data.GraphInitialisationComplete event)  
      void handleWeeklyTasks​(ch.sahits.game.event.data.PeriodicalTimeWeekEndUpdate event)  
      void initializeNewShip​(ch.sahits.game.openpatrician.model.ship.IShip ship, ch.sahits.game.openpatrician.model.IAIPlayer player)
      Method to handle the initializing of a trade strategy for a new ship.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AIPlayerEngine

        public AIPlayerEngine()
    • Method Detail

      • 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.
      • handleBlockadeStart

        public void handleBlockadeStart​(ch.sahits.game.openpatrician.event.data.ai.BlockadeShipRequestEvent event)
      • handleShipArrivesInCity

        public void handleShipArrivesInCity​(ch.sahits.game.openpatrician.event.data.ShipEntersPortEvent event)
      • handleGameLoad

        public void handleGameLoad​(ch.sahits.game.openpatrician.event.GameStateChange gameStateChange)
        Listen to the start of the game loading to continue with the handling of ship arrival events.
        Parameters:
        gameStateChange - event for game state change
      • handleTradeStrategyStart

        public void handleTradeStrategyStart​(ch.sahits.game.openpatrician.event.data.GraphInitialisationComplete event)
      • executeCurrentTrade

        public boolean executeCurrentTrade​(ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel)
        Check weather the current vessel is engaged in executing trade steps.
        Parameters:
        vessel - for which to check if it is active
        Returns:
        true if the vessel is active for trading
      • handleWeeklyTasks

        public void handleWeeklyTasks​(ch.sahits.game.event.data.PeriodicalTimeWeekEndUpdate event)
      • handleSpecialMissionFinished

        public void handleSpecialMissionFinished​(ch.sahits.game.openpatrician.event.data.ai.SpecialMissionFinishedEvent event)
        Handle the reinitialisation after finishing a special mission.
        Parameters:
        event - special mission is finished
      • handleShipAuctionFinished

        public void handleShipAuctionFinished​(ch.sahits.game.openpatrician.event.data.ShipAuctionFinished event)
      • handleShipNotAuction

        public void handleShipNotAuction​(ch.sahits.game.openpatrician.event.data.ShipNotAuctioned event)
      • handleBuildingAuctionFinished

        public void handleBuildingAuctionFinished​(ch.sahits.game.openpatrician.event.data.BuildingAuctionFinished event)
      • handleBuildingNotAuction

        public void handleBuildingNotAuction​(ch.sahits.game.openpatrician.event.data.BuildingNotAuctioned event)
      • handleMarriageEvent

        public void handleMarriageEvent​(ch.sahits.game.openpatrician.model.IAIPlayer player,
                                        ch.sahits.game.openpatrician.clientserverinterface.model.event.MarriageBrokerAnnouncementState state)
        Description copied from interface: IAIEventHandler
        Handle the offer of a marriage broker.
        Specified by:
        handleMarriageEvent in interface IAIEventHandler
        state - of the marriage broker
      • handleMarriageWareDelivery

        public void handleMarriageWareDelivery​(ch.sahits.game.openpatrician.model.IAIPlayer player,
                                               ch.sahits.game.openpatrician.clientserverinterface.model.event.MarriageFeastRequestState state)
        Description copied from interface: IAIEventHandler
        Handle the request to deliver marriage wares.
        Specified by:
        handleMarriageWareDelivery in interface IAIEventHandler
        Parameters:
        player - that is requested to deliver the wares
        state - request details
      • handleDonationRequest

        public void handleDonationRequest​(ch.sahits.game.openpatrician.model.IAIPlayer player,
                                          ch.sahits.game.openpatrician.clientserverinterface.model.event.DonationRequestState state)
        Description copied from interface: IAIEventHandler
        Handle a donation request.
        Specified by:
        handleDonationRequest in interface IAIEventHandler
        Parameters:
        player - that is requested to deliver the wares
        state - request details
      • handleShipConstructionFinished

        public void handleShipConstructionFinished​(ch.sahits.game.openpatrician.model.ship.IShip ship,
                                                   ch.sahits.game.openpatrician.model.IAIPlayer player)
        Method to handle the finishing of a ship construction.
        Parameters:
        ship - that is newly constructed
        player - owner of the ship
      • initializeNewShip

        public void initializeNewShip​(ch.sahits.game.openpatrician.model.ship.IShip ship,
                                      ch.sahits.game.openpatrician.model.IAIPlayer player)
        Method to handle the initializing of a trade strategy for a new ship.
        Specified by:
        initializeNewShip in interface IAIEventHandler
        Parameters:
        ship - to be initialized
        player - owner of the ship
      • handelLoadedNewGame

        public void handelLoadedNewGame​(ch.sahits.game.openpatrician.event.GameStateChange event)
        Initialize the visible ships.
        Parameters:
        event - game state change event
      • handleConvoyDissolve

        public void handleConvoyDissolve​(ch.sahits.game.openpatrician.clientserverinterface.model.event.ConvoyDisolveEvent event)
      • handleShipFittedForOrleg

        public void handleShipFittedForOrleg​(ch.sahits.game.openpatrician.clientserverinterface.model.event.OrlegShipOutfittedEvent event)
        When a ship has finally been fitted for orlead duties, create the convoy.
        Parameters:
        event -