Class Episode

  • Direct Known Subclasses:
    EpisodeInfo

    @Entity
    public class Episode
    extends Object
    An Episode is a single instance of a Game played by a person or machine with our game server. It describes the current state of the game, and has methods for processing player's actions. The episode object contains the top-level controls describing the current state of the rule set associated with this episode.
    • Field Detail

      • episodeId

        public String episodeId
        This is used to assign episode IDs, which are unique within a given server run. The IDs are not meant to be persistent.
      • NBU

        public static final int NBU
      • ruleLineNo

        protected int ruleLineNo
        Which row of rules do we look at now? (0-based)
    • Constructor Detail

      • Episode

        public Episode()
        Dummy constructor; only used for error code production, and maybe also by JPA when restoring a player's info (with all episodes) from the database.
      • Episode

        public Episode​(Game game,
                       Episode.OutputMode _outputMode,
                       Reader _in,
                       PrintWriter _out)
        Creates a new Episode for a given Game (which defines rules and the properties of the initial board).
        Parameters:
        _in - The input stream for commands; it will be null in the web app
        _out - Will be null in the web app.
    • Method Detail

      • getEpisodeId

        public String getEpisodeId()
      • setEpisodeId

        public void setEpisodeId​(String _episodeId)
      • getStartTime

        public Date getStartTime()
      • setStartTime

        public void setStartTime​(Date _startTime)
      • getNPiecesStart

        public int getNPiecesStart()
      • setNPiecesStart

        public void setNPiecesStart​(int _nPiecesStart)
      • graphicDisplay

        public String graphicDisplay()
        Graphic display of the board
      • graphicDisplay

        public String graphicDisplay​(boolean html)
      • graphicDisplayAscii

        public String graphicDisplayAscii​(boolean html)
        Retired from the web game server; still used in Captive Game Server.
      • getCurrentBoard

        public Board getCurrentBoard()
        Shows the current board (without removed [dropped] pieces)
      • mkDisplay

        public Episode.Display mkDisplay()
        Builds a Display objecy to be sent out over the web UI upon a /display call (rather than a /move or /pick)
      • playGame

        public boolean playGame​(int gameCnt)
                         throws IOException
        Lets this episode play out until either all pieces are cleared, or a stalemate is reached, or the player gives up (sends an EXIT or NEW command)
        Returns:
        true if another game is requested
        Throws:
        IOException
      • report

        public String report()
        Concise report, handy for debugging