org.starhope.appius.game
Class Commands

java.lang.Object
  extended by org.starhope.appius.game.Commands

public class Commands
extends Object

Command processor for Appius Game Server (JSON Commands)

This is the command interpreter library for JSON command received from the game client. The server will search for commands in the general library (using Java reflection to examine this class), as well as a configuration-specified local “library” class for extensions specific to a given game.

This command processor is scanned for a method name matching the command name specified in the RPC call (JSON call) from the client. These commands can be invoked by any client.

Command names must start with do_, followed by the (typically javaCamelCased) command verb. The method signature must be exactly public static void do_ verb (Zone, JSONObject, User, Integer) .

Security is generally voluntary and must be enforced by individual methods.

Author:
brpocock@star-hope.org

Field Summary
(package private) static org.json.JSONObject baseColors
          cache for base colours palette
(package private) static org.json.JSONObject extraColors
          cache for extra colours palette
 
Constructor Summary
Commands()
           
 
Method Summary
static void do_addFurniture(org.json.JSONObject jso, AbstractUser u, Room room)
          Synonym for setFurniture
static void do_addToList(org.json.JSONObject jso, AbstractUser u, Room room)
          add a user to a buddy list or ignore list using the traditional (online-only, no notification engine) mechanism (using out of band methods).
static void do_click(org.json.JSONObject jso, AbstractUser u, Room r)
           Used by the client to report a mouse click.
static void do_createUserHouse(org.json.JSONObject jso, AbstractUser u, Room room)
           Response from the first run screen for the user's house
static void do_dofff(org.json.JSONObject jso, AbstractUser u, Room room)
           Response with total avatar info from "wardrobe"
static void do_don(org.json.JSONObject jso, AbstractUser u, Room room)
           JSON object has the item slot number to be worn (clothes, patterns, pivitz) and optionally set the color (for patterns)
 void do_eavesdrop(org.json.JSONObject jso, AbstractUser u, Room room)
          WRITEME: Document this method brpocock@star-hope.org
static void do_echo(org.json.JSONObject jso, AbstractUser u, Room room)
           Echoes back the supplied JSON (or ActionScript) object to the client.
static void do_endEvent(org.json.JSONObject jso, AbstractUser u, Room room)
           This method terminates an event (probably a minigame, but possibly a fountain) which was initiated by startEvent.
static void do_finger(org.json.JSONObject jso, AbstractUser u, Room room)
           Get public info for a list of (other) users.
static void do_gameAction(org.json.JSONObject jso, AbstractUser u, Room room)
           WRITEME — basically similar to an do_sendOutOfBandMessage(JSONObject, AbstractUser, Room) but specifically something to do with a game
static void do_getAvatars(org.json.JSONObject jso, AbstractUser u, Room room)
          Get avatar data for a list of (other) users.
static void do_getColorPalettes(org.json.JSONObject jso, AbstractUser u, Room room)
          Deprecated. This routine appears to be unused by anyone. If this is not true, please comment to BRPocock@Star-Hope.org or it will be removed without replacement before Appius 1.2
 void do_getConfig(org.json.JSONObject jso, AbstractUser u, Room room)
          Get a configuration key from the server's config.properties file, based upon a key name beginning with "client." — note that clients cannot read arbitrary server config file values for security purposes; e.g.
static void do_getInventory(org.json.JSONObject jso, AbstractUser u, Room room)
           get all inventory for an user — both active and inactive
static void do_getInventoryByType(org.json.JSONObject jso, AbstractUser u, Room room)
           Get a subset of items from your own inventory
static void do_getOnlineUsers(org.json.JSONObject jso, AbstractUser u, Room room)
          Get a list of users in a Zone, or in a Room.
static void do_getRoomList(org.json.JSONObject jso, AbstractUser u, Room room)
          Get a list of all “well known” Rooms currently active/visible.
static void do_getServerTime(org.json.JSONObject jso, AbstractUser u, Room room)
           Send the server time to the client requesting it (for synchronization purposes)
static org.json.JSONObject do_getSessionApple(org.json.JSONObject jso, AbstractUser who, Room where)
          Initialise a session key for batch mode operations
static org.json.JSONObject do_getStoreItemInfo(org.json.JSONObject jso, AbstractUser u, Room r)
          WRITEME: Document this method brpocock@star-hope.org
 void do_getText(org.json.JSONObject jso, AbstractUser u, Room room)
          Get a text string from the server's message catalogue
static void do_getUserLists(org.json.JSONObject jso, AbstractUser u, Room room)
          Get the user's buddy list and ignore list.
static void do_getWallet(org.json.JSONObject jso, AbstractUser u, Room room)
          WRITEME: Document this method brpocock@star-hope.org
static void do_getZoneList(org.json.JSONObject jso, AbstractUser u, Room room)
          Get a list of all Zones currently active/visible.
static void do_give(org.json.JSONObject jso, AbstractUser u, Room room)
          Give an item to another user
static void do_go(org.json.JSONObject jso, AbstractUser u, Room room)
          go to a place and/or perform a gesture
static void do_initUserRoom(org.json.JSONObject jso, AbstractUser u, Room userCurrentRoomInZone)
           Creates room named user/user's name/room — room is the room index number given in the JSON data as “room,” it will always be zero right now as all users have single-room houses.
static void do_join(org.json.JSONObject jso, AbstractUser u, Room room)
          Join a room.
static void do_logout(org.json.JSONObject jso, AbstractUser u, Room room)
           Log out of this game session (or zone)
static void do_mailCustomerService(org.json.JSONObject jso, AbstractUser u, Room room)
          send an eMail to customer service (feedback)
static void do_peekAtInventory(org.json.JSONObject jso, AbstractUser u, Room room)
          Handle looking at other user's inventories
static void do_ping(org.json.JSONObject jso, AbstractUser u, Room room)
          Send a “ping” to the server to get back a “pong.” This also updates the user's last-active timestamp, to prevent them from being idled offline.
static void do_promptReply(org.json.JSONObject jso, AbstractUser u, Room room)
           Server initiates prompt with:
static void do_removeFromList(org.json.JSONObject jso, AbstractUser u, Room room)
          Remove someone from a buddy list or ignore list.
static void do_reportBug(org.json.JSONObject jso, AbstractUser u, Room room)
          This method allows the client to “phone home” to report a bug.
static void do_reportUser(org.json.JSONObject jso, AbstractUser u, Room room)
          Report an user to the moderator(s) on duty for breaking a rule
static void do_requestBuddy(org.json.JSONObject jso, AbstractUser u, Room room)
          Request adding a user to your buddy list (mutual-add) using the new notification-based system
 void do_savePrefs(org.json.JSONObject jso, AbstractUser u, Room room)
           Set persistent user preferences on the server, to be maintained between sessions.
static void do_sendOutOfBandMessage(org.json.JSONObject jso, AbstractUser u, Room room)
           Send an arbitrary JSON packet to another user, or all of the users in a room, out of the band of communications.
static void do_serverTime(org.json.JSONObject jso, AbstractUser u, Room room)
          Accept the client's notification of a server-time adjustment.
static void do_setAvatarColor(org.json.JSONObject jso, AbstractUser u, Room room)
           Set the avatar base and extra colours for the given user.
static void do_setFurniture(org.json.JSONObject jso, AbstractUser u, Room room)
           Set or change a furniture item.
static void do_setRoomVar(org.json.JSONObject jso, AbstractUser u, Room room)
          Set a room variable or set of room variables.
static void do_setUserVar(org.json.JSONObject jso, AbstractUser u, Room room)
           Set user variable(s)
static void do_spawnZone(org.json.JSONObject jso, AbstractUser u, Room room)
          Spawn an additional zone.
static void do_speak(org.json.JSONObject jso, AbstractUser u, Room room)
           Handle speech by the user.
static void do_startEvent(org.json.JSONObject jso, AbstractUser u, Room room)
           Attempt to begin an event.
static void do_useEquipment(org.json.JSONObject jso, AbstractUser u, Room r)
          WRITEME: Document this method brpocock@star-hope.org
private static String getBuddySignature(AbstractUser u, AbstractUser u2)
          Create a fancy signature thing to validate buddy list requests
private static void getInventoryByType(org.json.JSONObject jso, AbstractUser caller, AbstractUser owner, Room room)
           JSON object has the type of item from the strings in the config file.
static String getRev()
          Get the current Subversion level of this file
private static Collection<InventoryItemType> getTypeSetFromString(String typeString)
          WRITEME: Document this method brpocock@star-hope.org
(package private) static String handleDice(String inSpeech)
          Handle die rolls, coin tosses, and magic Rock-Paper-Scissors picker
private static String nonObnoxious(String speech)
          remove some of the more obnoxious punctuation abuses from a string
private static void speak_atMessage(AbstractUser u, Room room, String speech)
          WRITEME: document this method (brpocock@star-hope.org, Mar 11, 2010)
private static String speak_filterResultToString(AbstractUser u, FilterResult carlSays)
          WRITEME: document this method (brpocock@star-hope.org, Mar 11, 2010)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseColors

static final org.json.JSONObject baseColors
cache for base colours palette


extraColors

static final org.json.JSONObject extraColors
cache for extra colours palette

Constructor Detail

Commands

public Commands()
Method Detail

do_addFurniture

public static void do_addFurniture(org.json.JSONObject jso,
                                   AbstractUser u,
                                   Room room)
                            throws org.json.JSONException,
                                   NotFoundException
Synonym for setFurniture

Parameters:
jso - See do_setFurniture(JSONObject, AbstractUser, Room)
u - The user calling this method
room - The room in which this user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form
NotFoundException - if the furniture doesn't exist
See Also:
do_setFurniture(JSONObject, AbstractUser, Room)

do_addToList

public static void do_addToList(org.json.JSONObject jso,
                                AbstractUser u,
                                Room room)
                         throws org.json.JSONException
add a user to a buddy list or ignore list using the traditional (online-only, no notification engine) mechanism (using out of band methods). Compare vs. #do_requestBuddy

Parameters:
jso - { buddy: (name) } or { ignore: (name) } or { buddy: (name), confirm: (boolean), sign: (signature) }
u - The user calling this method
room - The room in which this user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_click

public static void do_click(org.json.JSONObject jso,
                            AbstractUser u,
                            Room r)
                     throws org.json.JSONException

Used by the client to report a mouse click. There are a couple of different cases that this would be called.

First: if the user clicks on a placed-item in a room, this method should be called with the following syntax:

{"c":"click", "d":{ "on": itemID, "x": x, "y": y, "with": mods } }

Note that the (x,y) values passed are relative to the origin point of the item; thus, if an item is placed at (200,200) and is clicked at (210,210), the coördinates reported should be (10,10).

Alternatively, if the user clicks anywhere on the screen , and has one of the modifier keys held down (e.g. Shift, Meta, Control/Command) (but not Control on MacOS, as that represents a button-3-click), then send a click event like this:

{ "c":"click", "d":{ "x": x, "y":y, "with":mods } }

Note the absence of the "on" attribute in the second form.


The mods string can contain any of the following symbols in any order, representing modifier keys that were held down when the user clicked on the item:

^
Caret represents the CONTROL key on Linux/Unix/Windows systems, or the COMMAND key on MacOS.
S
Ess represents the SHIFT key on any platform
C
Ci represents the CAPS LOCK state being enabled.
N
En represents the NUM LOCK state being enabled
M
Em represents the META key on Linux/Unix, ALT on Linux/Unix/Windows, or OPTION on MacOS
L
Ell represents the SCROLL LOCK state being enabled.
A
Ay represents the ALT-GR key on any platform (if supported)
*
Asterisk represents the SUPER key on Linux or WINDOWS-LOGO key on Windows.
1, 2, 3
Numbers represent mouse buttons: 1 for left, 2 for middle, 3 for right.
+, -
Plus represents rolling a scroll wheel down; Minus to scroll up
<, >
Less-than represents rolling a scroll knob left; greater-than, right.

Flash details

In the Flash MouseEvent object, you can create the "mods" with the following:

var mods:String = ""; if (ev.altKey) mods += "M"; if (ev.commandKey || ev.ctrlKey) mods += "^"; if (ev.shiftKey) mods += "S"; if (ev.type == ev.CLICK) mods += "1"; if (ev.type == ev.MIDDLE_CLICK) mods += "2"; if (ev.type == ev.RIGHT_CLICK) mods += "3"; if (ev.type == ev.MOUSE_WHEEL) { if (ev.delta < 0) mods += "-"; if (ev.delta > 0) mods += "+"; } if (Keyboard.numLock) mods += "N"; if (Keyboard.capsLock) mods += "C";

Parameters:
jso - See above. Must contain x, y, and mods. "mods" may be a null string. May contain "on" with an ItemID (e.g. "item99"), in which case, x,y are relative to the item's origin.
u - The user clicking
r - The room in which the click happened
Throws:
org.json.JSONException - JSON data malformed

do_createUserHouse

public static void do_createUserHouse(org.json.JSONObject jso,
                                      AbstractUser u,
                                      Room room)
                               throws org.json.JSONException

Response from the first run screen for the user's house

Either create the user's house and lot, or add a room to their house.

Parameters:
jso - Data describing the user's lot { lot: lot-ID, house: house-ID }, or adding a room, { index: roomIndex }
u - The user buying the lot
room - The room in which the user is found — for communications purposes, at least.
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_dofff

public static void do_dofff(org.json.JSONObject jso,
                            AbstractUser u,
                            Room room)
                     throws org.json.JSONException

Response with total avatar info from "wardrobe"

Parameters:
jso - ignored
u - The user calling this method
room - The room in which this user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_don

public static void do_don(org.json.JSONObject jso,
                          AbstractUser u,
                          Room room)
                   throws org.json.JSONException,
                          NumberFormatException,
                          DataException

JSON object has the item slot number to be worn (clothes, patterns, pivitz) and optionally set the color (for patterns)

Response with total avatar info from "wardrobe"

Parameters:
jso - { slot : ### } or { slot: ###, color: CCC } — valid formats defined in Colour.Colour(String)
u - The user calling this method
room - The room in which this user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form
DataException - for bad colour
NumberFormatException - for bad colour numeric parts

do_echo

public static void do_echo(org.json.JSONObject jso,
                           AbstractUser u,
                           Room room)

Echoes back the supplied JSON (or ActionScript) object to the client. This method exists solely for testing purposes.

Sends response containing:

Note that the field name is literally “You said:”

Parameters:
jso - Any JSON object, the contents of which will be returned to the caller.
u - The user calling (to whom the response is sent)
room - The room in which the user calls us (ignored)

do_endEvent

public static void do_endEvent(org.json.JSONObject jso,
                               AbstractUser u,
                               Room room)
                        throws org.json.JSONException

This method terminates an event (probably a minigame, but possibly a fountain) which was initiated by startEvent.

For fountains, the score is ignored, and a random number from 1..100 is used as the effective score. Since fountains (should) have a 1:1 points:peanuts ratio, this will earn the player 1..100 peanuts randomly per fountain visit.

Response: JSON sent to user: { ended: event ID; peanuts: number of peanuts earned; highScores: array of scores, indexed by position on the high score list (1..24), each of which contains: { points: number of points scored by the high-scoring user; userName: the name of the user }, totalPeanuts: user's new total peanut balance }

Additionally, if this user earned a high score on this event, s/he will get the attribute in the top level of the response as "gotHighScore": with the value being the position number which was earned. For example, earning no high score omits the "gotHighScore" attribute altogether; earning the third highest score will return instead "gotHighScore" == 3.

Parameters:
jso - JSON parameters. { moniker = the event's moniker; eventID = the event ID to be ended; score = the earned score, in points (not peanuts); status = one of "cxl" to cancel an event (in which case, score should be 0), or "cmp" to complete an event (score may be zero or more). }
u - The calling user
room - The room in which the user is found (for replies)
Throws:
org.json.JSONException - if something nasty happens

do_finger

public static void do_finger(org.json.JSONObject jso,
                             AbstractUser u,
                             Room room)
                      throws org.json.JSONException

Get public info for a list of (other) users.

Reply format:

  { from: avatars, status: true, avatars: { 0: { USER-INFO … }, … }
 

User public information is in the format of AbstractUser.getPublicInfo()

Parameters:
jso - JSON object, with (ignored) keys tied to values which must be the names of users.
u - The calling user. The calling user's avatar data will not be returned.
room - the (ignored) room in which the method is being called
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_gameAction

public static void do_gameAction(org.json.JSONObject jso,
                                 AbstractUser u,
                                 Room room)
                          throws org.json.JSONException

WRITEME — basically similar to an do_sendOutOfBandMessage(JSONObject, AbstractUser, Room) but specifically something to do with a game

Parameters:
jso - { "action": (verb), (other params...) }
u - The user calling this method
room - The room in which this user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_getAvatars

public static void do_getAvatars(org.json.JSONObject jso,
                                 AbstractUser u,
                                 Room room)
                          throws org.json.JSONException
Get avatar data for a list of (other) users.

Parameters:
jso - JSON object, with (ignored) keys tied to values which must be the names of users. e.g. { 0: "someUser", 1: "otherUser" }
u - The calling user. The calling user's avatar data will not be returned.
room - the (ignored) room in which the method is being called
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_getColorPalettes

@Deprecated
public static void do_getColorPalettes(org.json.JSONObject jso,
                                                  AbstractUser u,
                                                  Room room)
                                throws SQLException,
                                       org.json.JSONException
Deprecated. This routine appears to be unused by anyone. If this is not true, please comment to BRPocock@Star-Hope.org or it will be removed without replacement before Appius 1.2

returns palettes in "extraColors", "baseColors", "patternColors" in the JSON result object (from: "getColorPalettes")

XXX contains SQL

Note: Not used in Tootsville™ any more. The analogous palettes in Li'l Vampies and Empires of the Air are being replaced with algorithmic checks, so this routine may be removed before Appius 1.2.0 unless there is a reason to maintain it.

Parameters:
jso - JSON parameters: ignored
u - calling user
room - calling user's room
Throws:
SQLException - if something squirrelly happens
org.json.JSONException - if something squirrelly happens

do_getInventory

public static void do_getInventory(org.json.JSONObject jso,
                                   AbstractUser u,
                                   Room room)
                            throws org.json.JSONException

get all inventory for an user — both active and inactive

Returns a set of items as inv: { 0: { id: 123, isActive: boolean }, ... } — furniture with placement data will also have x, y, and facing vars. Other attributes are "from":"inventory", "type": matching the type of the question

Parameters:
jso - { }
u - The user whose inventory to be searched
room - The room in which the user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_getInventoryByType

public static void do_getInventoryByType(org.json.JSONObject jso,
                                         AbstractUser u,
                                         Room room)
                                  throws org.json.JSONException

Get a subset of items from your own inventory

Parameters:
jso - { type: TYPE-STRING } — see getInventoryByType(JSONObject, AbstractUser, AbstractUser, Room) for discussion of TYPE-STRING; or { type: TYPE-STRING, withActive: BOOLEAN } to mask out active items; optional { who: LOGIN-NAME } to look at someone else's inventory
u - The user whose inventory to be searched, who is the caller of this routine
room - The room in which the user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_getOnlineUsers

public static void do_getOnlineUsers(org.json.JSONObject jso,
                                     AbstractUser u,
                                     Room room)
                              throws org.json.JSONException,
                                     PrivilegeRequiredException,
                                     NotFoundException
Get a list of users in a Zone, or in a Room. This is an administrative function, only available to staff members.

Parameters:
jso - The JSON data provided by the caller. If this contains an attribute of "inRoom" with a room moniker, we'll only return the users in that room. Otherwise, all users in the Zone will be returned.
u - The caller's ID. Must have staff privileges.
room - The room from which the caller is making the extension call: ignored.
Throws:
org.json.JSONException - if the JSON data can't be processed, in or out.
PrivilegeRequiredException - if the user doesn't have STAFF_LEVEL_STAFF_MEMBER
NotFoundException - if the room requested doesn't exist

do_getRoomList

public static void do_getRoomList(org.json.JSONObject jso,
                                  AbstractUser u,
                                  Room room)
                           throws org.json.JSONException
Get a list of all “well known” Rooms currently active/visible.

Parameters:
jso - Ignored
u - The user requesting the data.
room - Ignored
Throws:
org.json.JSONException - If something untoward happens

do_getServerTime

public static void do_getServerTime(org.json.JSONObject jso,
                                    AbstractUser u,
                                    Room room)
                             throws org.json.JSONException

Send the server time to the client requesting it (for synchronization purposes)

Sends a JSON object with a single property, serverTime, with the current time in milliseconds (give or take transit time)

Parameters:
jso - ignored
u - The user requesting the time
room - The room in which the user is standing
Throws:
org.json.JSONException - If the JSON data can't be written out

do_getSessionApple

public static org.json.JSONObject do_getSessionApple(org.json.JSONObject jso,
                                                     AbstractUser who,
                                                     Room where)
                                              throws org.json.JSONException
Initialise a session key for batch mode operations

Parameters:
jso - ignored
who - unused
where - unused
Returns:
Replies with { from: initSession, key: (OPAQUE-STRING) }
Throws:
org.json.JSONException - if the reply can't be encoded in JSON form for some reason...

do_getStoreItemInfo

public static org.json.JSONObject do_getStoreItemInfo(org.json.JSONObject jso,
                                                      AbstractUser u,
                                                      Room r)
                                               throws org.json.JSONException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
jso - JavaScript array-style object where the key names are ignored, but the values are item ID's
u - WRITEME
r - WRITEME
Returns:
WRITEME
Throws:
org.json.JSONException - if things go very wrongly.

do_getUserLists

public static void do_getUserLists(org.json.JSONObject jso,
                                   AbstractUser u,
                                   Room room)
                            throws org.json.JSONException
Get the user's buddy list and ignore list.

{ buddyList: { … } , ignoreList: { … } }

Parameters:
jso - no parameters needed
u - The user whose buddy and ignore lists will be fetched
room - The user's current room (ignored)
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_getWallet

public static void do_getWallet(org.json.JSONObject jso,
                                AbstractUser u,
                                Room room)
                         throws org.json.JSONException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
jso - WRITEME
u - WRITEME
room - WRITEME
Throws:
org.json.JSONException - WRITEME

do_getZoneList

public static void do_getZoneList(org.json.JSONObject jso,
                                  AbstractUser u,
                                  Room room)
                           throws org.json.JSONException
Get a list of all Zones currently active/visible. (Empty and retired Zones are culled. See AbstractZone.getZoneList_JSON(org.starhope.appius.user.AbstractUser) )

Parameters:
jso - Ignored
u - The user requesting the data.
room - Ignored
Throws:
org.json.JSONException - If something untoward happens

do_give

public static void do_give(org.json.JSONObject jso,
                           AbstractUser u,
                           Room room)
                    throws org.json.JSONException,
                           AlreadyExistsException
Give an item to another user

XXX: notify the recipient using notifications (currently using a Message Box popup message)

Parameters:
jso - { slot: SLOT-NUMBER, to: USER-LOGIN }
u - giver
room - room of gift being given
Throws:
org.json.JSONException - if the JSON data is malformed
AlreadyExistsException - if the event can't be started for some reason

do_go

public static void do_go(org.json.JSONObject jso,
                         AbstractUser u,
                         Room room)
                  throws org.json.JSONException
go to a place and/or perform a gesture

Parameters:
jso - { do: VERB (required)
x: DEST, y: DEST, z: DEST (each optional, but if x or y is given, both must be; z can be omitted)
facing: FACING (optional)
}
u - the user doing something
room - the room in which the user is standing
Throws:
org.json.JSONException - if the packet can't be decoded somehow

do_initUserRoom

public static void do_initUserRoom(org.json.JSONObject jso,
                                   AbstractUser u,
                                   Room userCurrentRoomInZone)
                            throws org.json.JSONException

Creates room named user/user's name/room — room is the room index number given in the JSON data as “room,” it will always be zero right now as all users have single-room houses. This will populate all furniture-type items for that room onto a set of room variables owned by the user. The user calling this method must be the owner of the room. If the user has not visited his/her house before, this will return an asynchronous "make a new house" notification to do the "first run" screen, by sending a message of type { "from": "initUserRoom", "status": false, "err": "showFirstRun" }.

Success: responds with true, and "moniker": the room's moniker (user/WHOEVER/123)

If unneccessary, returns an error of "exists" meaning that the room is already existing

Parameters:
jso - { room: (room-number), autoJoin: (boolean) }
u - The user whose house-room needs to be initialized
userCurrentRoomInZone - The room in which the user is actually standing right now
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_join

public static void do_join(org.json.JSONObject jso,
                           AbstractUser u,
                           Room room)
                    throws org.json.JSONException
Join a room. On success, sends back the set of room join events; but on failure, replies with { from: roomJoin, status: false, err: ...}

NOTE the inconsistency: the command is join, but the reply comes from roomJoin

zone.notFound
The user is not in a Zone
room.noMoniker
No room moniker was given to be joined
room.notFound
The room moniker does not refer to an actual room in this Zone
room.full
The room is too full (too many users)

Parameters:
jso - { room: MONIKER } or { room: MONIKER, from: MONIKER }
u - the user joining the room
room - the user's prior room
Throws:
org.json.JSONException - if the packet can't be produced

do_logout

public static void do_logout(org.json.JSONObject jso,
                             AbstractUser u,
                             Room room)

Log out of this game session (or zone)

There's a bug in the Persephone client that causes it to explode if we log it out before it receives & processes the logout message. So, we wait for the expected lag time to expire and then throw 2 full seconds of wasted wait time after it, which had ought to be enough time

Note: in the future, this will be configured to be off by default. Tootsville™ servers will need to incorporate the configuration key value if Persephone 2 hasn't been fixed by that time.

Parameters:
jso - no data
u - The user logging out
room - The room in which the user was standing

do_mailCustomerService

public static void do_mailCustomerService(org.json.JSONObject jso,
                                          AbstractUser u,
                                          Room room)
send an eMail to customer service (feedback)

Parameters:
jso - { subject: STRING, body: STRING }
u - the user sending the feedback
room - the room in which the user is standing

do_peekAtInventory

public static void do_peekAtInventory(org.json.JSONObject jso,
                                      AbstractUser u,
                                      Room room)
                               throws org.json.JSONException,
                                      NotFoundException
Handle looking at other user's inventories

Parameters:
jso - {"who": the login name of the user of whom to get the inventory }; optional "type": to filter by type. (see getInventoryByType(JSONObject, AbstractUser, AbstractUser, Room) for details)
u - The user requesting the inventory
room - The room in which the request occurs
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form
NotFoundException - Could not find a user with that name

do_ping

public static void do_ping(org.json.JSONObject jso,
                           AbstractUser u,
                           Room room)
                    throws org.json.JSONException
Send a “ping” to the server to get back a “pong.” This also updates the user's last-active timestamp, to prevent them from being idled offline.

Parameters:
jso - No parameters
u - The user sending the “ping”
room - The room in which the user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_promptReply

public static void do_promptReply(org.json.JSONObject jso,
                                  AbstractUser u,
                                  Room room)
                           throws org.json.JSONException

Server initiates prompt with:



 { "from" : "prompt",
   "id" : $ID,
   "label" : $LABEL,
   "label_en_US" : $LABEL,
   "title" : $TITLE,
   [ "attachUser" : $AVATAR_LABEL || "attachItem" : $ITEM_ID ] ,
   "msg" : $TEXT,
   "replies" :
    {  $TOKEN :
        { "label" : $BUTTON_LABEL,
          "label_en_US" : $BUTTON_LABEL,
          "type" : $BUTTON_TYPE },
      [ … ]
    }
 }
 

Where:

The "replies" assoc-array is of arbitrary length ≥ 2, where the key to each item is a $TOKEN, again an arbitrary string without \0 to represent this response uniquely. This is not an user-visible string.

$BUTTON_LABEL = the text to display. In future, the client may want to special-case specific text to use icons or something: e.g. "OK" will always be sent as precisely "OK" in English locale.

$BUTTON_TYPE = the type of the button for theming purposes only. This is from the enumerated set [ "aff" | "neg" | "neu" ];

To simplify future i18n/l10n efforts, the $LABEL and $BUTTON_LABEL will always be sent twice. The user's current language version will be in the "label" properties. The versions of those strings in the "en_US" locale will always be in the "label_en_US" properties. For purposes of theming and such, the label_en_US properties should be considered; the "label" properties, however, should always be used in presentation to the end-user.

Example:

 { "from": "prompt", "status": "true",
    "id": "fountain/tootSquare/þ=?/x'deadbeef'",
   "label": "Fountain", "label_en_US": "Fountain",
   "title": "Make a Wish?", "msg": "Do you want to make a wish on the Toot Square fountain?",
   "replies":
    { "yes": { "label": "Make a Wish!", "label_en_US": "Make a Wish!", "type": "aff" },
      "no": { "label": "Not now", "label_en_US": "Not now", "type": "neg" }
    }
 }
 

The client's response is a bit simpler:

 { "c": "promptReply", "d": { "id": $ID, "reply": $TOKEN } }
 

e.g.

 { "c":"promptReply", "d": { "id":  "fountain/tootSquare/þ=?/x'deadbeef'", "reply": "yes" } }
 

As a special-case, for the reply only, the special $TOKEN of "close" should be sent if the user dismissed the dialog box with the close button.

I'd suggest that the GUI attach anonymous functions with the reply packets already constructed to the various dialog box controls at creation time, rather than trying to manage some queue of pending prompts.

To handle user expectations, it would be best to display the button in a "down" state until receiving the server's acknowledgement of the "promptReply" and disallow multiple-clicking in the window.

The server will respond with

 { "from": "promptReply", "status": "true", "id": $ID }
 

For debugging purposes, the server may reply with

 { "from": "promptReply", "status": "false", "err": $ERR }
 

Where $ERR will be a brief description of the problem. e.g. $ERR = "reply.notFound" might represent a reply button that was not a valid $TOKEN from the "prompt" command nor the special case "close". $ERR = "id.notFound" might represent a reply to a prompt that was not (recently) asked.

A prompt ID is not valid across sessions; pending prompts should be auto-closed on logout. Prompts can, however, remain active indefinitely, even across room joins.

Optional implementation: the server may cancel an outstanding prompt request by sending a packet with the following properties:

Client applications may choose to dismiss the prompt automatically upon receiving such a packet. Failure to do so is not an error, however, later attempting to reply to a canceled prompt will return status: false, err: id.notFound. Clients must accept a cancelation packet silently if they do not process it.

Parameters:
jso - in the form { id: $ID, reply: $TOKEN }, as detailed above
u - the user replying to a prompt
room - the room in which the user is standing (unimportant)
Throws:
org.json.JSONException - for really bad syntax errors

do_removeFromList

public static void do_removeFromList(org.json.JSONObject jso,
                                     AbstractUser u,
                                     Room room)
                              throws org.json.JSONException
Remove someone from a buddy list or ignore list.

Parameters:
jso - To remove a buddy: { buddy: (name) }; or to attend to someone who had previously been ignored: { ignore: (name) }
u - The user whose buddy list or ignore list will be updated
room - The room in which the user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_reportBug

public static void do_reportBug(org.json.JSONObject jso,
                                AbstractUser u,
                                Room room)
                         throws org.json.JSONException
This method allows the client to “phone home” to report a bug. The bug report itself is just a giant string embedded in the “bug” element, but a “cause” element will be treated as the subject. Note that the bug report — like all JSON input — will be cut off at a certain limit (typically 4KiB), so it's most helpful to keep it short & sweet: Typically, this should be something like a single stack backtrace (with as much detail as possible), rather than a complete log trace or something.

The suggested usage is to include the exception itself as “cause,” the backtrace up to a maximum of 1KiB, a log backtrace up to its last 1KiB as “bug,” and as much machine-formatted system information as possible in the “info” object.

Fields of “info”

As many fields as possible, limit the contents to a reasonable length though…

Note that the keys listed are strings, so e.g.:

 info ["navigator.language"] = navigator.language;
 info ["navigator.product"] = navigator.product;
 

ActionScript example:

 var info:Object = {
    "flash.sys.ime": flash.system.System.ime,
    "flash.sys.totalMemory": flash.system.System.totalMemory,
    "flash.sys.useCodePage": flash.system.System.useCodePage
 };
    // imperfect but close
 for ( var key in flash.system.Capabilities ) {
        info["flash.sysCap." + key] = flash.system.Capabilities[key];
 }
 
navigator.language
JavaScript: navigator.language
navigator.product
JavaScript: navigator.product
navigator.appVersion
JavaScript: navigator.appVersion
navigator.platform
JavaScript: navigator.platform
navigator.vendor
JavaScript: navigator.vendor
navigator.appCodeName
JavaScript: navigator.appCodeName
navigator.cookieEnabled
JavaScript: navigator.cookieEnabled
navigator.appName
JavaScript: navigator.appName
navigator.productSub
JavaScript: navigator.productSub
navigator.userAgent
JavaScript: navigator.userAgent
navigator.vendorSub
JavaScript: navigator.vendorSub
screen.height
JavaScript: screen.height; ActionScript: flash.system.Capabilities.screenResolutionX
screen.width
JavaScript: screen.width; ActionScript: flash.system.Capabilities.screenResolutionY
screen.availHeight
JavaScript: screen.availHeight; ActionScript: flash.display.Stage.fullScreenHeight
screen.availWidth
JavaScript: screen.availWidth; ActionScript: flash.display.Stage.fullScreenWidth
window.outerHeight
JavaScript: window.outerheight note case
window.outerWidth
JavaScript: window.outerwidth note case
window.innerHeight
JavaScript: window.innerheight note case
window.innerWidth
JavaScript: window.innerwidth note case
window.windowName
JavaScript: the window.name property of the highest parent of this window (frame); e.g.
 var topWindow = window.parent;
 for (; topWindow.parent != topWindow; topWindow = topWindow.parent)
        ;
 info ["window.windowName"] = topWindow.name;
 
flash.sys.totalMemory
ActionScript: flash.system.System.totalMemory
flash.sys.ime
ActionScript: flash.system.System.ime
flash.sys.useCodePage
ActionScript: flash.system.System.useCodePage
flash.sysCap.avHardwareDisable
ActionScript: flash.system.Capabilities.avHardwareDisable
flash.sysCap.hasAccessibility
ActionScript: flash.system.Capabilities.hasAccessibility
flash.sysCap.hasAudio
ActionScript: flash.system.Capabilities.hasAudio
flash.sysCap.hasAudioEncoder
ActionScript: flash.system.Capabilities.hasAudioEncoder
flash.sysCap.hasEmbeddedVideo
ActionScript: flash.system.Capabilities.hasEmbeddedVideo
flash.sysCap.hasIME
ActionScript: flash.system.Capabilities.hasIME
flash.sysCap.hasMP3
ActionScript: flash.system.Capabilities.hasMP3
flash.sysCap.hasPrinting
ActionScript: flash.system.Capabilities.hasPrinting
flash.sysCap.hasScreenBroadcast
ActionScript: flash.system.Capabilities.hasScreenBroadcast
flash.sysCap.hasScreenPlayback
ActionScript: flash.system.Capabilities.hasScreenPlayback
flash.sysCap.hasStreamingAudio
ActionScript: flash.system.Capabilities.hasStreamingAudio
flash.sysCap.hasStreamingVideo
ActionScript: flash.system.Capabilities.hasStreamingVideo
flash.sysCap.hasTLS
ActionScript: flash.system.Capabilities.hasTLS
flash.sysCap.hasVideoEncoder
ActionScript: flash.system.Capabilities.hasVideoEncoder
flash.sysCap.isDebugger
ActionScript: flash.system.Capabilities.isDebugger
flash.sysCap.isEmbeddedInAcrobat
ActionScript: flash.system.Capabilities.isEmbeddedInAcrobat
flash.sysCap.language
ActionScript: flash.system.Capabilities.language
flash.sysCap.localFileReadDisable
ActionScript: flash.system.Capabilities.localFileReadDisable
flash.sysCap.manufacturer
ActionScript: flash.system.Capabilities.manufacturer
flash.sysCap.os
ActionScript: flash.system.Capabilities.os
flash.sysCap.pixelAspectRatio
ActionScript: flash.system.Capabilities.pixelAspectRatio
flash.sysCap.playerType
ActionScript: flash.system.Capabilities.playerType
flash.sysCap.screenColor
ActionScript: flash.system.Capabilities.screenColor
flash.sysCap.screenDPI
ActionScript: flash.system.Capabilities.screenDPI
flash.sysCap.version
ActionScript: flash.system.Capabilities.version
flash.displayState
ActionScript: if flash.display.Stage.displayState == FULL_SCREEN_INTERACTIVE, then "fullScreen"; for NORMAL, return "window".
flash.frameRate
ActionScript: flash.display.Stage.frameRate
flash.quality
ActionScript: flash.display.Stage.quality
flash.scaleMode
ActionScript: flash.display.Stage.scaleMode
 // ActionScript example
 function systemReport:Object () {
  return {
   "screen": {
    "height": flash.system.Capabilities.screenResolutionX,
    "width": flash.system.Capabilities.screenResolutionY,
    "availHeight": flash.display.Stage.fullScreenHeight,
    "availWidth": flash.display.Stage.fullScreenWidth,
   },
   "flash": {
    "sys": {
     "totalMemory": flash.system.System.totalMemory,
     "ime": flash.system.System.ime,
     "useCodePage": flash.system.System.useCodePage,
    },
    "sysCap": {
     "avHardwareDisable": flash.system.Capabilities.avHardwareDisable,
     "hasAccessibility": flash.system.Capabilities.hasAccessibility,
     "hasAudio": flash.system.Capabilities.hasAudio,
     "hasAudioEncoder": flash.system.Capabilities.hasAudioEncoder,
     "hasEmbeddedVideo": flash.system.Capabilities.hasEmbeddedVideo,
     "hasIME": flash.system.Capabilities.hasIME,
     "hasMP3": flash.system.Capabilities.hasMP3,
     "hasPrinting": flash.system.Capabilities.hasPrinting,
     "hasScreenBroadcast": flash.system.Capabilities.hasScreenBroadcast,
     "hasScreenPlayback": flash.system.Capabilities.hasScreenPlayback,
     "hasStreamingAudio": flash.system.Capabilities.hasStreamingAudio,
     "hasStreamingVideo": flash.system.Capabilities.hasStreamingVideo,
     "hasTLS": flash.system.Capabilities.hasTLS,
     "hasVideoEncoder": flash.system.Capabilities.hasVideoEncoder,
     "isDebugger": flash.system.Capabilities.isDebugger,
     "isEmbeddedInAcrobat": flash.system.Capabilities.isEmbeddedInAcrobat,
     "language": flash.system.Capabilities.language,
     "localFileReadDisable": flash.system.Capabilities.localFileReadDisable,
     "manufacturer": flash.system.Capabilities.manufacturer,
     "os": flash.system.Capabilities.os,
     "pixelAspectRatio": flash.system.Capabilities.pixelAspectRatio,
     "playerType": flash.system.Capabilities.playerType,
     "screenColor": flash.system.Capabilities.screenColor,
     "screenDPI": flash.system.Capabilities.screenDPI,
     "version": flash.system.Capabilities.version
    },
    "displayState": ( flash.display.Stage.displayState == FULL_SCREEN_INTERACTIVE ? "fullScreen" : "window" ),
    "frameRate": flash.display.Stage.frameRate,
    "quality": flash.display.Stage.quality,
    "scaleMode": flash.display.Stage.scaleMode
   }
  };
 }

 

Parameters:
jso - Must contain a single string attribute named “bug.” Should contain an attribute named “info” with system information key-value pairs (see above). May also have a subject of “cause” as a string.
u - The user reporting the bug.
room - The user's current room.
Throws:
org.json.JSONException - JSON encoding error

do_reportUser

public static void do_reportUser(org.json.JSONObject jso,
                                 AbstractUser u,
                                 Room room)
                          throws org.json.JSONException
Report an user to the moderator(s) on duty for breaking a rule

Parameters:
jso - { userName = user to be reported }
u - The user who is reporting the other user
room - The room in which the reporting user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_requestBuddy

public static void do_requestBuddy(org.json.JSONObject jso,
                                   AbstractUser u,
                                   Room room)
                            throws org.json.JSONException
Request adding a user to your buddy list (mutual-add) using the new notification-based system

Parameters:
jso - { buddy: LOGIN }
u - user who is requesting the addition
room - unused
Throws:
org.json.JSONException - if the data can't be interpreted

do_sendOutOfBandMessage

public static void do_sendOutOfBandMessage(org.json.JSONObject jso,
                                           AbstractUser u,
                                           Room room)
                                    throws org.json.JSONException

Send an arbitrary JSON packet to another user, or all of the users in a room, out of the band of communications. This is neither a public nor a private message in the chat context: just some additional data that is being provided.

{ sender: sender, from: outOfBand, status: true, body: {JSON} }

Adds "roomTitle" to body if body contains "room" and title can be determined

Add “"sendRoomList": "true"” to give the user an updated room list as well. (Necessary for invitations to new rooms.)

Inviting to houses …

  1. initUserRoom { room: 0, autoJoin: false }
    • { from: initUserRoom, status: true, moniker: ROOM-MONIKER } ** OK
    • => { from: initUserRoom, status: false, err: exists, moniker: ROOM-MONIKER } ** OK
    • => { from: initUserRoom, status: false, err: showFirstRun } ** ERR (player does not have that room)
  2. sendOutOfBandMessage { to: USER-LOGIN, body: { locType: "house", type: "invite", room: MONIKER } }
    { from: outOfBand, sender: YOUR-LOGIN, status: true, body: { locType: "house", type: "invite", room: MONIKER, roomTitle: USER-VISIBLE-NAME } }

for user houses, roomTitle will be like "BlackDaddyNerd's House"

Parameters:
jso - To send to one user: { to: userName, body: {JSON} }, or to broadcast to the entire room: { toRoom: true, body: {JSON} }
u - The sender of the out-of-band-message
room - The room in which the sender is standing. Necessary for the toRoom version of this method.
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form

do_serverTime

public static void do_serverTime(org.json.JSONObject jso,
                                 AbstractUser u,
                                 Room room)
                          throws org.json.JSONException
Accept the client's notification of a server-time adjustment. This is used to compute the client's round-trip lag time.

Parameters:
jso - { serverTime: LONG milliseconds since epoch }
u - The user responding
room - The room in which the user is standing
Throws:
org.json.JSONException - if the packet is malformed

do_setAvatarColor

public static void do_setAvatarColor(org.json.JSONObject jso,
                                     AbstractUser u,
                                     Room room)
                              throws org.json.JSONException,
                                     SQLException

Set the avatar base and extra colours for the given user.

Colour numbers are given in X'RRGGBB' form as an integer — to compute one from byte (0..255) RGB values, do ( red << 16 & green << 8 & blue )

Parameters:
jso - { "base": (colour number), "extra": (colour number) }
u - The user whose avatar colours are being set
room - The room in which the user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form
SQLException - if the palettes can't be loaded

do_setFurniture

public static void do_setFurniture(org.json.JSONObject jso,
                                   AbstractUser u,
                                   Room room)
                            throws org.json.JSONException,
                                   NotFoundException

Set or change a furniture item. To add a structural item to the room, put item: 123 without anything else. To place furniture on the floor, also add attributes x, y, and facing.

To change furniture, replace item: with slot: (to avoid ambiguities about “which chair”)

To remove an item from the room, send { slot: 123, remove: true }

Parameters:
jso - { slot: #, x: #, y: #, facing: $ } or { item: #, x: #, y: #, facing: $ } or { slot: #, remove: true }
u - The user calling this method
room - The room in which this user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form
NotFoundException - if the furniture doesn't exist

do_setRoomVar

public static void do_setRoomVar(org.json.JSONObject jso,
                                 AbstractUser u,
                                 Room room)
                          throws org.json.JSONException,
                                 PrivilegeRequiredException
Set a room variable or set of room variables.

Parameters:
jso - key-value pair(s) for room variable(s) to be set
u - the user requesting the change
room - the room to which the variable(s) are associated
Throws:
org.json.JSONException - if the packet is malformed
PrivilegeRequiredException - if a non-privileged user attempts to set a room variable.

do_setUserVar

public static void do_setUserVar(org.json.JSONObject jso,
                                 AbstractUser u,
                                 Room room)
                          throws org.json.JSONException

Set user variable(s)

Input: { key : value } (one or more)

Parameters:
jso - user variable(s) to set
u - the user setting them
room - the room in which the user is standing
Throws:
org.json.JSONException - if the JSO can't be decoded

do_spawnZone

public static void do_spawnZone(org.json.JSONObject jso,
                                AbstractUser u,
                                Room room)
                         throws org.json.JSONException,
                                PrivilegeRequiredException
Spawn an additional zone.

Parameters:
jso - JSON object, containing an associative array whose values are zones to be spawned
u - The caller responsible
room - Where is the caller?
Throws:
org.json.JSONException - if something goes awry
PrivilegeRequiredException - if the user isn't a Developer

do_speak

public static void do_speak(org.json.JSONObject jso,
                            AbstractUser u,
                            Room room)
                     throws org.json.JSONException,
                            NotFoundException

Handle speech by the user. XXX This should be calling User.speak(Room, String) to do the dirty work: but, in fact, the reverse is currently true.

Speech is public to all users in a room.

Emotes are simply speech beginning with "/". A few are special-cased. WRITEME: which

Commands are speech beginning with "#"

Parameters:
jso - { "speech": TEXT-TO-BE-SPOKEN }
u - The user speaking
room - The room in which the speech occurs.
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON form
NotFoundException - WRITEME

do_startEvent

public static void do_startEvent(org.json.JSONObject jso,
                                 AbstractUser u,
                                 Room room)
                          throws org.json.JSONException,
                                 SQLException

Attempt to begin an event. Might return an error. Uses Quaestor for the heavy lifting.

Note that for all fountains, use the magic moniker “fountain”

Calls back the user with either of:

alreadyDone: true; status: false; err: "event.alreadyDone"
This returns for fountains that have already given peanuts today (where today started at midnight, database local time)
eventID: (NUM), filename: "blah.swf", asVersion: { 2, 3, or not }, status: true
For successfully registered events. Must be completed or canceled using do_endEvent(JSONObject ,AbstractUser , Room )

Parameters:
jso - JSON payload from the caller. Data: moniker = event moniker.
u - The caller = the user performing the event
room - The caller's room. For fountains, we'll use this room's moniker to figure out which fountain is which
Throws:
org.json.JSONException - if JSON data can't be put into a response, or gotten out of a command.
SQLException - probably means that the moniker is bad, but I'm not really doing much to validate it here

do_useEquipment

public static void do_useEquipment(org.json.JSONObject jso,
                                   AbstractUser u,
                                   Room r)
                            throws org.json.JSONException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
jso - { t: slot-type-char, x: target-x, y: target-y, z: target-z, [ on: target-name ] }
u - WRITEME
r - WRITEME
Throws:
org.json.JSONException - WRITEME

getBuddySignature

private static String getBuddySignature(AbstractUser u,
                                        AbstractUser u2)
Create a fancy signature thing to validate buddy list requests

Parameters:
u - The user calling this method
u2 - The user with whom they want to be buddies
Returns:
a fancy signature thing to validate buddy list requests

getInventoryByType

private static void getInventoryByType(org.json.JSONObject jso,
                                       AbstractUser caller,
                                       AbstractUser owner,
                                       Room room)
                                throws org.json.JSONException

JSON object has the type of item from the strings in the config file.

OR, you can specify an item type by passing # plus its ID, or a string of them; e.g. for items of type 1, pass "#1," for items of types 2 or 3, pass "#2:3"

OR, you can specify a list of item type strings using '$' plus the string identifiers divided by ':', e.g. "$Pants:Shirts"

Returns a set of items as inv: { 0: { id: 123, isActive: boolean }, ... } — furniture with placement data will also have x, y, and facing vars. Other attributes are "from":"inventory", "type": matching the type of the question

You can also supply withActive: false to screen out active items.

Return data

  { from: inventory, for: USER-LOGIN, type: TYPE-STRING,
    inv: {
     #: { ITEM-INFO },
      #: { ITEM-INFO } …
    }
  }
 

Parameters:
jso - { type: TYPE-STRING } — see above for discussion of TYPE-STRING; { withActive: false } to mask out active items
caller - The caller of the routine, who is inquiring about someone else's inventory
owner - the user owning the inventory
room - The room in which the user is standing
Throws:
org.json.JSONException - Thrown if the data cannot be interpreted from the JSON objects passed in, or conversely, if we can't encode a response into a JSON for,

getRev

public static String getRev()
Get the current Subversion level of this file

Returns:
the current Subversion revision level of this file

getTypeSetFromString

private static Collection<InventoryItemType> getTypeSetFromString(String typeString)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
typeString - WRITEME
Returns:
WRITEME

handleDice

static String handleDice(String inSpeech)
Handle die rolls, coin tosses, and magic Rock-Paper-Scissors picker

Parameters:
inSpeech - Speech before filtering
Returns:
Speech after filtering

nonObnoxious

private static String nonObnoxious(String speech)
remove some of the more obnoxious punctuation abuses from a string

Parameters:
speech - a string to be edited
Returns:
the same string with some obnoxious punctuation faux pas removed

speak_atMessage

private static void speak_atMessage(AbstractUser u,
                                    Room room,
                                    String speech)
WRITEME: document this method (brpocock@star-hope.org, Mar 11, 2010)

Parameters:
u - WRITEME
room - WRITEME
speech - WRITEME

speak_filterResultToString

private static String speak_filterResultToString(AbstractUser u,
                                                 FilterResult carlSays)
WRITEME: document this method (brpocock@star-hope.org, Mar 11, 2010)

Parameters:
u - WRITEME
carlSays - WRITEME
Returns:
WRITEME

do_eavesdrop

public void do_eavesdrop(org.json.JSONObject jso,
                         AbstractUser u,
                         Room room)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
jso - WRITEME
u - WRITEME
room - WRITEME

do_getConfig

public void do_getConfig(org.json.JSONObject jso,
                         AbstractUser u,
                         Room room)
                  throws org.json.JSONException
Get a configuration key from the server's config.properties file, based upon a key name beginning with "client." — note that clients cannot read arbitrary server config file values for security purposes; e.g. the config file probably has a database password or similar in it.

Parameters:
jso - WRITEME
u - WRITEME
room - WRITEME
Throws:
org.json.JSONException - WRITEME

do_getText

public void do_getText(org.json.JSONObject jso,
                       AbstractUser u,
                       Room room)
                throws org.json.JSONException
Get a text string from the server's message catalogue

Parameters:
jso - { for : KEY } or { for: KEY, default: FALLBACK-STRING }
u - the user (whose language will be considered)
room - the room in which the user is standing (unimportant)
Throws:
org.json.JSONException - if the input or output won't JSON encode/decode cleanly

do_savePrefs

public void do_savePrefs(org.json.JSONObject jso,
                         AbstractUser u,
                         Room room)

Set persistent user preferences on the server, to be maintained between sessions. Changes to preferences are reflected to the user at login, and any time they're changed.

Preferences are stored in hierarchical form as string values. However, the full “dotted notation” of any preference key must not extend beyond 100 characters in length.

At present, all preferences are echoed to all clients using an user account. There is no filter.

Preference keys cannot be deleted; the closest equivalent is to set their values to "". Each savePrefs call will only overwrite prior calls with identical keys; keys not replaced will be left alone.

Parameters:
jso - The preference keys to be saved.
u - The user whose preferences are being saved
room - The user's current room