Package edu.wisc.game.rest

## Class GameService2

- java.lang.Object
- - edu.wisc.game.rest.GameService2

- Direct Known Subclasses:
    `AutomaticRuleGeneratorService`, `CheckPlanService`, `GameService2Html`

      @Path("/GameService2")
      public class GameService2
      extends Object

  The "Second Batch" of API calls, primarily for use with players constrained by an experiment plan, and playing a sequence of games as outlined in the trial list to which the player is assigned. This API is set up in accordance with Kevin Mui's request, 2020-08-17.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `GameService2()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `String` | `abandon​(String playerId)` |
    `ActivateBonusWrapper` | `activateBonus​(String playerId)` |
    `ColorMap` | `colorMap()` | Returns a hash map that maps each color name (in upper case) to a vector of 3 integers, representing RGB values.
    `EpisodeInfo.ExtendedDisplay` | `display​(String playerId, String episodeId)` |
    `LaunchRulesBase.AndroidRuleInfoReport` | `findPlans​(int uid)` |
    `String` | `getVersion()` | Reports the current version of the server
    `GiveUpWrapper` | `giveUp​(String playerId, int seriesNo)` |
    `FileWriteReport` | `guess​(String playerId, String episodeId, String text, int confidence)` | Records a player's guess about the rules.
    `ListShapesWrapper` | `listShapes()` | Lists the names of all shapes.
    `NewEpisodeWrapper2` | `mostRecentEpisode​(String playerId)` | Changed to existing=false on 2022-11-04, due to an error reported by Paul.
    `EpisodeInfo.ExtendedDisplay` | `move​(String playerId, String episodeId, int x, int y, int pieceId, int cnt)` |
    `EpisodeInfo.ExtendedDisplay` | `move​(String playerId, String episodeId, int x, int y, int bx, int by, int pieceId, int bucketId, int cnt)` |
    `NewEpisodeWrapper2` | `newEpisode​(String playerId, boolean activateBonus, boolean giveUp)` |
    `PlayerResponse` | `player​(String playerId, String exp, int uid)` |
    `UserResponse` | `registerUser​(String email, String nickname, boolean anon)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GameService2

          public GameService2()

  - ### Method Detail

    - #### registerUser

          @POST
          @Path("/registerUser")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public UserResponse registerUser​(@DefaultValue("null") @FormParam("email")
                                           String email,
                                           @DefaultValue("null") @FormParam("nickname")
                                           String nickname,
                                           @DefaultValue("false") @FormParam("anon")
                                           boolean anon)

    - #### player

          @POST
          @Path("/player")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public PlayerResponse player​(@DefaultValue("null") @FormParam("playerId")
                                       String playerId,
                                       @DefaultValue("null") @FormParam("exp")
                                       String exp,
                                       @DefaultValue("-1") @FormParam("uid")
                                       int uid)

    - #### mostRecentEpisode

          @POST
          @Path("/mostRecentEpisode")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public NewEpisodeWrapper2 mostRecentEpisode​(@FormParam("playerId")
                                                      String playerId)

      Changed to existing=false on 2022-11-04, due to an error reported by Paul.

    - #### newEpisode

          @POST
          @Path("/newEpisode")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public NewEpisodeWrapper2 newEpisode​(@FormParam("playerId")
                                               String playerId,
                                               @DefaultValue("false") @FormParam("activateBonus")
                                               boolean activateBonus,
                                               @DefaultValue("false") @FormParam("giveUp")
                                               boolean giveUp)

    - #### display

          @GET
          @Path("/display")
          @Produces("application/json")
          public EpisodeInfo.ExtendedDisplay display​(@DefaultValue("null") @QueryParam("playerId")
                                                     String playerId,
                                                     @QueryParam("episode")
                                                     String episodeId)

    - #### move

          @POST
          @Path("/move")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public EpisodeInfo.ExtendedDisplay move​(@DefaultValue("null") @FormParam("playerId")
                                                  String playerId,
                                                  @FormParam("episode")
                                                  String episodeId,
                                                  @DefaultValue("-1") @FormParam("x")
                                                  int x,
                                                  @DefaultValue("-1") @FormParam("y")
                                                  int y,
                                                  @DefaultValue("-1") @FormParam("bx")
                                                  int bx,
                                                  @DefaultValue("-1") @FormParam("by")
                                                  int by,
                                                  @DefaultValue("-1") @FormParam("id")
                                                  int pieceId,
                                                  @DefaultValue("-1") @FormParam("bid")
                                                  int bucketId,
                                                  @FormParam("cnt")
                                                  int cnt)

    - #### move

          @POST
          @Path("/pick")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public EpisodeInfo.ExtendedDisplay move​(@DefaultValue("null") @FormParam("playerId")
                                                  String playerId,
                                                  @FormParam("episode")
                                                  String episodeId,
                                                  @DefaultValue("-1") @FormParam("x")
                                                  int x,
                                                  @DefaultValue("-1") @FormParam("y")
                                                  int y,
                                                  @DefaultValue("-1") @FormParam("id")
                                                  int pieceId,
                                                  @FormParam("cnt")
                                                  int cnt)

    - #### activateBonus

          @POST
          @Path("/activateBonus")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public ActivateBonusWrapper activateBonus​(@FormParam("playerId")
                                                    String playerId)

    - #### giveUp

          @POST
          @Path("/giveUp")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public GiveUpWrapper giveUp​(@FormParam("playerId")
                                      String playerId,
                                      @FormParam("seriesNo")
                                      int seriesNo)

    - #### guess

          @POST
          @Path("/guess")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public FileWriteReport guess​(@DefaultValue("null") @FormParam("playerId")
                                       String playerId,
                                       @FormParam("episode")
                                       String episodeId,
                                       @FormParam("data")
                                       String text,
                                       @DefaultValue("-1") @FormParam("confidence")
                                       int confidence)

      Records a player's guess about the rules. This is typically used at the end of an episode.

    - #### colorMap

          @GET
          @Path("/colorMap")
          @Produces("application/json")
          public ColorMap colorMap()

      Returns a hash map that maps each color name (in upper case) to a vector of 3 integers, representing RGB values. The data come from the file in game-data/colors. Note that calling this method causes the system to re-read the file; so the client may want to cache the data.

    - #### listShapes

          @GET
          @Path("/listShapes")
          @Produces("application/json")
          public ListShapesWrapper listShapes()

      Lists the names of all shapes. This can be used e.g. in a board editor.

    - #### getVersion

          @GET
          @Path("/getVersion")
          @Produces("application/json")
          public String getVersion()

      Reports the current version of the server

    - #### findPlans

          @GET
          @Path("/findPlans")
          @Produces("application/json")
          public LaunchRulesBase.AndroidRuleInfoReport findPlans​(@DefaultValue("-1") @QueryParam("uid")
                                                                 int uid)

    - #### abandon

          @POST
          @Path("/abandon")
          @Consumes("application/x-www-form-urlencoded")
          @Produces("application/json")
          public String abandon​(@FormParam("playerId")
                                String playerId)