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 classPairing.StateA 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 booleanensurePairingNow(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 voidnewPlayerRegistration(PlayerInfo p)Called on /newPlayer (from PlayerResponse()), to check if the new (or restored) player needs to be paired.static intwhoWillStartEpisode(PlayerInfo p, int seriesNo, int epiNo)static intwhoWillStartSeries(PlayerInfo p, int seriesNo)Which player starts the specified series?
-
-
-
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)
-
-