Class DefaultPlayerIdGenerator

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void freePlayerSlot​(int playerId)
      This method is called by the parent Room when a Player leaves the game and his player slot can be freed up.
      Room getParentRoom()
      Get a reference to the parent Room
      int getPlayerSlot()
      Return a new player slot/id
      void init()
      The init() method is invoked immediately after the successful creation of the Game Room.
      void onRoomResize()
      This method is invoked upon a Room size change.
      void setParentRoom​(Room room)  
      • Methods inherited from class java.lang.Object

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

      • DefaultPlayerIdGenerator

        public DefaultPlayerIdGenerator()
    • Method Detail

      • init

        public void init()
        Description copied from interface: IPlayerIdGenerator
        The init() method is invoked immediately after the successful creation of the Game Room. Here the developer can add any initialization code. It is recommended to use this method instead of the constructor to setup your data structures etc... This is because only in the init() method you will be able to access the parent Room.
        Specified by:
        init in interface IPlayerIdGenerator
        See Also:
        IPlayerIdGenerator.getParentRoom()
      • freePlayerSlot

        public void freePlayerSlot​(int playerId)
        Description copied from interface: IPlayerIdGenerator
        This method is called by the parent Room when a Player leaves the game and his player slot can be freed up.
        Specified by:
        freePlayerSlot in interface IPlayerIdGenerator
        Parameters:
        playerId - the id that should be freed up
      • onRoomResize

        public void onRoomResize()
        Description copied from interface: IPlayerIdGenerator
        This method is invoked upon a Room size change. Depending on the logic that generates Player id(s) it might be necessary to take rearrange player id data after a Room resize.
        Specified by:
        onRoomResize in interface IPlayerIdGenerator