Package edu.wisc.game.rest
Class PlayerResponse
- java.lang.Object
-
- edu.wisc.game.rest.ResponseBase
-
- edu.wisc.game.rest.PlayerResponse
-
public class PlayerResponse extends ResponseBase
The object returned by the /player call. This is the call that's used at the beginning (or resumption) of a series, to create a new player entry in the database or find an existing one.
-
-
Constructor Summary
Constructors Constructor Description PlayerResponse(String pid, String exp, int uid)
PlayerResponse(String pid, String exp, int uid, boolean debug)
Registers a new player, or finds an existing player record.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PlayerInfo
findPlayerInfo(javax.persistence.EntityManager em, String pid)
Find the matching record for a player, in the cache of the database.static HashMap<String,PlayerInfo>
getAllCachedPlayers()
boolean
getAlreadyFinished()
True if this player has finished all episodes he could play.String
getCompletionCode()
int
getCompletionMode()
String
getExperimentPlan()
boolean
getIsAdveGame()
Are we playing an adversarial 2PG?boolean
getIsCoopGame()
Are we playing a cooperative two-player game (2PG)?boolean
getIsTwoPlayerGame()
Are we playing a 2PG? (A 2PG may be adversarial or cooperative)boolean
getNeedChat()
Do we need a between-player chat element in the GUI? (In 2PG only, based on para.chatboolean
getNewlyRegistered()
String
getPlayerId()
PlayerInfo
getPlayerInfo()
TrialList
getTrialList()
String
getTrialListId()
static void
main(String[] argv)
Handy testingvoid
setPlayerId(String _playerId)
-
-
-
Constructor Detail
-
PlayerResponse
public PlayerResponse(String pid, String exp, int uid, boolean debug)
Registers a new player, or finds an existing player record. In the former case, the player will be assigned to the specified experiment plan; in the latter case, we verify that the existing player has already been assigned to that plan.- Parameters:
exp
- The experiment plan that the player must play.pid
- The player ID. If it is not supplied, the uid must be supplied, and this method will create a semi-random player ID.uid
- The numeric ID of the repeat user who creates this playerId for himself. If negative, this parameter is ignored, as this is an M-Turker etc, and not a repeat user.debug
- If true, set this.playerInfo. (This is useful in Pseudo-Learning bot)
-
-
Method Detail
-
getNewlyRegistered
public boolean getNewlyRegistered()
-
getTrialListId
public String getTrialListId()
-
getTrialList
public TrialList getTrialList()
-
getPlayerId
public String getPlayerId()
-
setPlayerId
public void setPlayerId(String _playerId)
-
getPlayerInfo
public PlayerInfo getPlayerInfo()
-
getAlreadyFinished
public boolean getAlreadyFinished()
True if this player has finished all episodes he could play. This means that the most recent episode has been completed, and no more new episodes can be created.
-
getCompletionCode
public String getCompletionCode()
-
getCompletionMode
public int getCompletionMode()
-
getExperimentPlan
public String getExperimentPlan()
-
getIsCoopGame
public boolean getIsCoopGame()
Are we playing a cooperative two-player game (2PG)?
-
getIsAdveGame
public boolean getIsAdveGame()
Are we playing an adversarial 2PG?
-
getIsTwoPlayerGame
public boolean getIsTwoPlayerGame()
Are we playing a 2PG? (A 2PG may be adversarial or cooperative)
-
getNeedChat
public boolean getNeedChat()
Do we need a between-player chat element in the GUI? (In 2PG only, based on para.chat
-
getAllCachedPlayers
public static HashMap<String,PlayerInfo> getAllCachedPlayers()
-
findPlayerInfo
public static PlayerInfo findPlayerInfo(javax.persistence.EntityManager em, String pid) throws IOException, IllegalInputException, ReflectiveOperationException, RuleParseException
Find the matching record for a player, in the cache of the database. First looks it up in the local cache; then, if not found, in the SQL database. The main block is synchronized, to ensure that we don't put duplicate copies of a database entry into the cache.- Parameters:
em
- The EntityManager to use, if needed. If null is given, the EM will be created when needed, and then closed, so that the returned object will be detached.- Returns:
- The PlayerInfo object with the matching name, or null if none is found
- Throws:
IOException
IllegalInputException
ReflectiveOperationException
RuleParseException
-
-