Package edu.wisc.game.sql

## Class Pairing

- java.lang.Object
- - edu.wisc.game.sql.Pairing

-     public class Pairing
      extends Object

  Auxiliary methods for two-player games, introduced in GS 7.*. In a two-player game, a player may be in one of the following states: Must wait for the first display to appear Can retrieve a ready display Can make a move Must wait for the partner to make a move

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `Pairing.State` | A player's current state in the pairing system.

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `ensurePairingNow​(PlayerInfo p)` | This is called at the beginning of each episode (on a /newEpisode API call), to ensure that if this is a two-player game, the player is paired, if at all possible.
    `static void` | `newPlayerRegistration​(PlayerInfo p)` | Called on /newPlayer (from PlayerResponse()), to check if the new (or restored) player needs to be paired.
    `static int` | `whoWillStartEpisode​(PlayerInfo p, int seriesNo, int epiNo)` |
    `static int` | `whoWillStartSeries​(PlayerInfo p, int seriesNo)` | Which player starts the specified series?

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

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

- - ### Constructor Detail

    - #### Pairing

          public Pairing()

  - ### Method Detail

    - #### newPlayerRegistration

          public static void newPlayerRegistration​(PlayerInfo p)

      Called on /newPlayer (from PlayerResponse()), to check if the new (or restored) player needs to be paired.

    - #### ensurePairingNow

          public static boolean ensurePairingNow​(PlayerInfo p)

      This is called at the beginning of each episode (on a /newEpisode API call), to ensure that if this is a two-player game, the player is paired, if at all possible.
      Returns:
        true if pairing is needed, but is not possible right now, and therefore p has to wait to start playing

    - #### whoWillStartSeries

          public static int whoWillStartSeries​(PlayerInfo p,
                                               int seriesNo)

      Which player starts the specified series?

    - #### whoWillStartEpisode

          public static int whoWillStartEpisode​(PlayerInfo p,
                                                int seriesNo,
                                                int epiNo)

      Parameters:
        `epiNo` - episode number within the series (0-based)