source("WadleyHelp.bsh"); // load up the help stuff CustomParser() { customVerbs = new HashMap(); customVerbs{"CUSTOM"} ="CUSTOM"; customVerbs{"CUST"} ="CUSTOM"; customVerbs{"KNOCK"} ="KNOCK"; execute_CUSTOM(game, theCommand) { game.output.insertLineBreak(); game.output.insertStyledString ("Caught a custom command.", STYLE_RED_BOLD); game.output.insertLineBreak(); return true; } execute_KNOCK(game, theCommand) { // if we're on the front porch and the subject is the door // or the knocker or nothing, go ahead and knock if (game.currentLocation.roomId.equalsIgnoreCase("Front porch")) { if (isNull(theCommand.target) || theCommand.target.matches("DOOR|KNOCKER")) { game.output.insertString("[Using knocker]\n"); game.output.insertString("The sound of your knocking echos hollowly\n"); } else { game.output.insertStyledString("Knocking on that won't do anything\n", STYLE_ITALIC); } game.output.insertLineBreak(); } else { game.output.insertStyledString("Knocking won't do any good\n", STYLE_ITALIC); game.output.insertLineBreak(); } return true; // to let the game know that we've handled it } execute_LOOK(game, theCommand) { // return false to cause the default parser to execute return false; } execute_HELP(game, theCommand) { displayHelp(); // defined in WadleyHelp.bsh return true; } DOOR_CALLBACK(command, lastCommand) { debug("ENTER DOOR_CALLBACK(command, lastCommand)"); String[] strs = command.split(" "); lastCommand.subjectAdjective = strs[0].toUpperCase(); debug(lastCommand.toString()); obj = game.gameObjects.getObject(lastCommand.subject); try { obj.EXAMINE(lastCommand); game.output.insertLineBreak(); game.output.insertLineBreak(); } catch(ex) { debug(ex.getMessage()); ex.printStackTrace(); } debug("EXIT DOOR_CALLBACK(command, lastCommand)"); } return this; }