Package edu.wisc.game.rest
Class Files
- java.lang.Object
-
- edu.wisc.game.rest.Files
-
public class Files extends Object
Information about the data files the Rule Game web server reads and writes. The former are the experiment control files; the latter contain the record of the system's interactions with the players (transcripts, initial boards, players' responses to questionnaires, etc).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFiles.SavedNames of subdirectories under "saved"
-
Constructor Summary
Constructors Constructor Description Files()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidallowCachingAllRules(boolean x)This can be used (typically, in the captive server context) to allow caching all rules, for greater efficiencystatic FileboardsFile(String playerId)The file into which the initial boards of all episodes played by a given player are writtenstatic FileboardsFile(String playerId, boolean readOnly)static FilebotAssistFile(String playerId)static FilebotAssistFile(String playerId, boolean readOnly)static FilechatFile(String playerId)static FilecondFile(String condFileName)static FiledetailedTranscriptsFile(String playerId)static FiledetailedTranscriptsFile(String playerId, boolean readOnly)static FilegeminiDir()static FilegetImageFile(String shape)Looks for an image file with an appropriate name in the shapes directory.static FilegetLaunchFileA(LaunchRulesBase.Mode mode)The control file for the repeat-user launch pagestatic FilegetLaunchFileB(LaunchRulesBase.Mode mode)static FilegetSvgFile(Piece.Shape shape)static FilegetSvgFile(String shape)static FileguessesFile(String playerId)The file into which guesses by a given player are writtenstatic FileinitialBoardFile(String boardName)static FileinputBoardSubdir(String boardSubdirName)A subdirectory of the input boards directory, for use in a param set with initial boardsstatic String[]listAllRuleSetsInTree(String s)Lists all rule sets under rules/sstatic String[]listSAllExperimentPlans()List all existing experiment plans (based on the directory names in the appropriate tree).static String[]listSAllExperimentPlans(boolean validOnly)static StringlistSAllExperimentPlansHtml()Creates an HTML snippet (to be used inside a FORM, e.g.static StringlistSAllExperimentPlansHtml(boolean validOnly)static String[]listSAllExperimentPlansInTree(String subdir)static FilemlcUploadDir(String nickname, boolean readOnly)The upload directory for a particular MLC participant.static FilemodifierFile(String modifierName)static FilepregameDir(String pregame)The directory where the bundle pregame experience files is stored for a specific experience namestatic booleanrulesCanBeCached(String ruleSetName)Can the game server cache this rule set? The convention is, names not starting with a slash refer to files in the tomcat directory, whose content is supposed to be stable; therefore, they can be cached in the web app.static FilerulesFile(String ruleSetName)static FilesavedSubDir(String subdir)A specific subdirectory of the saved-files directorystatic voidsetInputDir(String path)Sets the path to the input directory, which is the root of the tree that contains the experiment control files.static FileshapesDir()static FiletranscriptsFile(String playerId)static FiletranscriptsFile(String playerId, boolean readOnly)
-
-
-
Method Detail
-
setInputDir
public static void setInputDir(String path)
Sets the path to the input directory, which is the root of the tree that contains the experiment control files. You only need to use this method if you want trial list files, rule set files, etc. to be read from directories in a directory tree other than the default ("/opt/w2020/game-data", or on older systems "/opt/tomcat/game-data"). So, for example, the Captive Game Server may use this method. If you use it, do so early in your application.- Parameters:
path- E.g. "/opt/w2020/game-data"
-
savedSubDir
public static File savedSubDir(String subdir)
A specific subdirectory of the saved-files directory
-
guessesFile
public static File guessesFile(String playerId) throws IOException
The file into which guesses by a given player are written- Throws:
IOException
-
chatFile
public static File chatFile(String playerId) throws IOException
- Throws:
IOException
-
boardsFile
public static File boardsFile(String playerId) throws IOException
The file into which the initial boards of all episodes played by a given player are written- Throws:
IOException
-
boardsFile
public static File boardsFile(String playerId, boolean readOnly) throws IOException
- Throws:
IOException
-
transcriptsFile
public static File transcriptsFile(String playerId) throws IOException
- Throws:
IOException
-
transcriptsFile
public static File transcriptsFile(String playerId, boolean readOnly) throws IOException
- Throws:
IOException
-
botAssistFile
public static File botAssistFile(String playerId) throws IOException
- Throws:
IOException
-
botAssistFile
public static File botAssistFile(String playerId, boolean readOnly) throws IOException
- Throws:
IOException
-
detailedTranscriptsFile
public static File detailedTranscriptsFile(String playerId) throws IOException
- Throws:
IOException
-
detailedTranscriptsFile
public static File detailedTranscriptsFile(String playerId, boolean readOnly) throws IOException
- Throws:
IOException
-
shapesDir
public static File shapesDir()
-
mlcUploadDir
public static File mlcUploadDir(String nickname, boolean readOnly) throws IOException
The upload directory for a particular MLC participant. It is created if it does not exist yet- Throws:
IOException
-
rulesFile
public static File rulesFile(String ruleSetName) throws IOException
- Parameters:
ruleSetName- Either a complete absolute path name ("/home/vmenkov/foo.txt") starting with a slash, or just a file name without the extension ("foo"). In the later case, the file is assumed to be in the standard rules directory.- Throws:
IOException
-
allowCachingAllRules
public static void allowCachingAllRules(boolean x)
This can be used (typically, in the captive server context) to allow caching all rules, for greater efficiency
-
rulesCanBeCached
public static boolean rulesCanBeCached(String ruleSetName)
Can the game server cache this rule set? The convention is, names not starting with a slash refer to files in the tomcat directory, whose content is supposed to be stable; therefore, they can be cached in the web app. Names starting with a slash are interpreted as absolute paths of files, presumably belonging to developers and thus possibly not stable; so the game server does not cache those.
-
initialBoardFile
public static File initialBoardFile(String boardName) throws IOException
- Throws:
IOException
-
inputBoardSubdir
public static File inputBoardSubdir(String boardSubdirName) throws IOException
A subdirectory of the input boards directory, for use in a param set with initial boards- Throws:
IOException
-
getSvgFile
public static File getSvgFile(Piece.Shape shape)
-
getSvgFile
public static File getSvgFile(String shape)
- Parameters:
shape- Case-insensitive shape name, e.g. "circle", or "arrows/up". To obtain the SVG file name, the shape name is converted to lower case, and ".svg" is added.
-
getImageFile
public static File getImageFile(String shape)
Looks for an image file with an appropriate name in the shapes directory.- Returns:
- A File object if a file has been found, or null otherwise
-
listSAllExperimentPlans
public static String[] listSAllExperimentPlans() throws IOException
List all existing experiment plans (based on the directory names in the appropriate tree). Excludes obviously "bad" plans (those without the rule set files, for example).- Throws:
IOException
-
listSAllExperimentPlans
public static String[] listSAllExperimentPlans(boolean validOnly) throws IOException
- Parameters:
validOnly- If true, excludes obviously "bad" plans (those without the rule set files, for example).- Throws:
IOException
-
listSAllExperimentPlansInTree
public static String[] listSAllExperimentPlansInTree(String subdir) throws IOException
- Throws:
IOException
-
listAllRuleSetsInTree
public static String[] listAllRuleSetsInTree(String s) throws IOException
Lists all rule sets under rules/s- Parameters:
s- The position of the root of the tree relative to the main rules directory- Returns:
- A list of proper rule set names (in the same format they would be likely to be encountered in trial list files, i.e. path names (relative to "rules") without extension.
- Throws:
IOException
-
listSAllExperimentPlansHtml
public static String listSAllExperimentPlansHtml() throws IOException
Creates an HTML snippet (to be used inside a FORM, e.g. at front-end-form.jsp) listing all currently existing experiment plans.- Throws:
IOException
-
listSAllExperimentPlansHtml
public static String listSAllExperimentPlansHtml(boolean validOnly) throws IOException
- Throws:
IOException
-
getLaunchFileA
public static File getLaunchFileA(LaunchRulesBase.Mode mode)
The control file for the repeat-user launch page- Parameters:
mode- APP, MLC, etc
-
getLaunchFileB
public static File getLaunchFileB(LaunchRulesBase.Mode mode)
-
modifierFile
public static File modifierFile(String modifierName) throws IOException
- Throws:
IOException
-
pregameDir
public static File pregameDir(String pregame) throws IOException
The directory where the bundle pregame experience files is stored for a specific experience name- Throws:
IOException
-
geminiDir
public static File geminiDir()
-
condFile
public static File condFile(String condFileName) throws IOException
- Parameters:
condFileName- Relative to /opt/w2020/game-data/cond- Throws:
IOException
-
-