Class SeaPiratesState


  • public class SeaPiratesState
    extends java.lang.Object
    State of all the sea pirates.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2013 Created on Feb 1, 2013
    • Field Detail

      • rnd

        @Autowired
        private java.util.Random rnd
      • map

        @Autowired
        private IMap map
      • clientServerEventBus

        @Autowired
        @Qualifier("serverClientEventBus")
        private com.google.common.eventbus.AsyncEventBus clientServerEventBus
      • date

        @Autowired
        private Date date
      • pirates

        private java.util.Set<ISeaPirate> pirates
    • Constructor Detail

      • SeaPiratesState

        public SeaPiratesState()
    • Method Detail

      • add

        public void add​(ISeaPirate pirate)
        Add a pirate. The pirate may be a private pirate belonging only to one player. Post an update event to notify listiners of a new pirate.
        Parameters:
        pirate - to be added
      • remove

        public void remove​(ISeaPirate pirate)
        Remove a pirate from the list.
        Parameters:
        pirate - to be removed
      • replace

        public void replace​(INonFreeSeaPirate pirate,
                            ISeaPirate replaceWith)
        A non free priate becomes a free pirate.
        Parameters:
        pirate - non free pirate who disapears
        replaceWith - free pirate who appears
      • getNonFreePirates

        public java.util.List<ISeaPirate> getNonFreePirates​(IPlayer player)
        Retrieve immutable list of non free pirates for the player
        Parameters:
        player - who has contracted non free pirates
        Returns:
        List of non free pirates contracted by player
      • getAllPirates

        public java.util.Set<ISeaPirate> getAllPirates()
        Retrieve all pirates.
        Returns:
        set of all pirates
      • getFreePirates

        public java.util.Set<ISeaPirate> getFreePirates()
        Retrieve immutable list of free pirates.
        Returns:
        set of free sea pirates.
      • findSuccessfulPirate

        public ISeaPirate findSuccessfulPirate()
        Find a successful free pirate
        Returns:
        sea pirate that is the most successful.