Class PuzzleService

    • Field Detail

      • MAX_ENTRIES

        protected static final int MAX_ENTRIES
        The number of entries per board size in the high score list.
        See Also:
        Constant Field Values
      • agent

        protected IInternalAccess agent
        The agent to which the service belongs.
      • exta

        protected IExternalAccess exta
        The external access for decoupling settings service calls.
      • entries

        protected java.util.Map<java.lang.Integer,​java.util.SortedSet<HighscoreEntry>> entries
        The highscore entries (boardsize->sorted set).
    • Constructor Detail

      • PuzzleService

        public PuzzleService()
    • Method Detail

      • startService

        public IFuture<java.lang.Void> startService()
        Init method called on service startup.
      • shutdownService

        public IFuture<java.lang.Void> shutdownService()
        Termination method called on service shutdown.
      • hint

        public IFuture<Move> hint​(Board board,
                                  long timeout)
        Solve the game and give a hint on the next move.
        Specified by:
        hint in interface IPuzzleService
        Parameters:
        board - The current board state.
        timeout - A timeout to stop, when no solution is found in time (-1 for no timeout).
        Returns:
        The tile to move next.
        Throws:
        java.lang.Exception - in future, when puzzle can not be solved in time.
      • addHighscore

        public IFuture<java.lang.Void> addHighscore​(HighscoreEntry entry)
        Add a highscore entry and save the highscore list.
        Specified by:
        addHighscore in interface IPuzzleService
        Parameters:
        entry - The highscore entry.
      • getHighscore

        public IFuture<java.util.SortedSet<HighscoreEntry>> getHighscore​(int size)
        Get the highscore entries for a given board size.
        Specified by:
        getHighscore in interface IPuzzleService
        Parameters:
        size - The board size (e.g. 3, 5, ...).
        Returns:
        The sorted set of highscore entries (highest entry first).
      • save

        protected IFuture<java.lang.Void> save()
        Save highscore using settings service.