|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.game.Commands
public class 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.
Constructor Summary | |
---|---|
Commands()
|
Method Summary | |
---|---|
static void |
do_addFurniture(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
|
static void |
do_addToList(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
WRITEME: document this method (brpocock, Aug 31, 2009) |
static void |
do_createUserHouse(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Response from the first run screen for the user's house |
static void |
do_doff(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
JSON object contains "type" = either "clothes" or "pivitz". |
static void |
do_don(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
JSON object has the item ID to be worn (clothes, patterns, pivitz) and optionally set the color (for patterns) |
static void |
do_echo(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Echoes back the supplied ActionScript object to the client. |
static void |
do_gameAction(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
TODO: document this method (brpocock, Nov 13, 2009) |
static void |
do_getAvatars(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Get avatar data for a list of (other) users. |
static void |
do_getColorPalettes(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
returns palettes in "extraColors", "baseColors", "patternColors" in the JSON result object (from: "getColorPalettes") |
static void |
do_getInventoryByType(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
JSON object has the type of item from the following list of strings: "clothes" "patterns" "pivitz" "furniture" "structure" "music" |
static void |
do_getOnlineUsers(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Get a list of users in a Zone, or in a Room. |
static void |
do_getServerTime(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Send the server time to the client requesting it (for synchronization purposes) |
static void |
do_getStoreItems(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
WRITEME: document this method (brpocock, Aug 26, 2009) |
static void |
do_getUserLists(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
WRITEME: document this method (brpocock, Aug 31, 2009) |
static void |
do_getZoneList(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Get a list of all Zones currently active/visible. |
static void |
do_initUserRoom(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom 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_ping(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
WRITEME: document this method (brpocock, Sep 8, 2009) |
static void |
do_removeFromList(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
WRITEME: document this method (brpocock, Aug 31, 2009) |
static void |
do_reportBug(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
This method allows the client to “phone home” |
static void |
do_reportUser(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
WRITEME: document this method (brpocock, Aug 31, 2009) |
static void |
do_sendOutOfBandMessage(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
WRITEME: document this method (brpocock, Sep 2, 2009) { sender: sender, from: outOfBand, status: true, body: {JSON} } Adds "roomTitle" to body if body contains "room" and title can be determined |
static void |
do_setAvatarColor(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Params: "base" and "extra" are color numbers |
static void |
do_setFurniture(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Set or change a furniture item. |
static void |
do_spawnZone(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
Spawn an additional zone. |
static void |
do_speak(org.json.JSONObject jso,
AbstractUser u,
AbstractRoom room)
|
private static String |
getBuddySignature(AbstractUser u,
AbstractUser u2)
Create a fancy signature thing to validate buddy list requests |
static String |
getRev()
TODO: document this method (brpocock, Dec 10, 2009) |
(package private) static String |
handleDice(String inSpeech)
Handle die rolls, coin tosses, and magic Rock-Paper-Scissors picker |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Commands()
Method Detail |
---|
public static void do_addFurniture(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException, NotFoundException
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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
- WRITEMEdo_setFurniture(JSONObject, AbstractUser, AbstractRoom)
public static void do_addToList(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
jso
- { buddy: (name) } or { ignore: (name) } or { buddy:
(name), confirm: (boolean), sign: (signature) } oru
- WRITEMEroom
- WRITEME
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 formpublic static void do_createUserHouse(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
Response from the first run screen for the user's house
jso
- Data describing the user's lot { lot: lot-ID, house:
house-ID }u
- The user buying the lotroom
- The room in which the user is found — for
communications purposes, at least.
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 formpublic static void do_doff(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
JSON object contains "type" = either "clothes" or "pivitz". Does not affect patterns.
Response with total avatar info from "wardrobe"
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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 formpublic static void do_don(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException, NumberFormatException, DataException
JSON object has the item ID to be worn (clothes, patterns, pivitz) and optionally set the color (for patterns)
Response with total avatar info from "wardrobe"
jso
- { item = (itemID) }u
- WRITEMEroom
- WRITEME
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 partspublic static void do_echo(org.json.JSONObject jso, AbstractUser u, AbstractRoom room)
Echoes back the supplied ActionScript object to the client. This method exists solely for testing purposes.
Sends response containing:
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)public static void do_gameAction(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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 formpublic static void do_getAvatars(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
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
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 formpublic static void do_getColorPalettes(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws SQLException, org.json.JSONException
jso
- JSON parameters: ignoredu
- calling userroom
- calling user's room
SQLException
- if something squirrelly happens
org.json.JSONException
- if something squirrelly happenspublic static void do_getInventoryByType(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
JSON object has the type of item from the following list of strings: "clothes" "patterns" "pivitz" "furniture" "structure" "music"
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
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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 formpublic static void do_getOnlineUsers(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException, PrivilegeRequiredException
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.
org.json.JSONException
- if the JSON data can't be processed, in or
out.
PrivilegeRequiredException
- if the user doesn't have
STAFF_LEVEL_STAFF_MEMBERpublic static void do_getServerTime(org.json.JSONObject jso, AbstractUser u, AbstractRoom 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)
jso
- ignoredu
- The user requesting the timeroom
- The room in which the user is standing
org.json.JSONException
- If the JSON data can't be written outpublic static void do_getStoreItems(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws NumberFormatException, org.json.JSONException
Results: totalPeanuts, stores...
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
NumberFormatException
- WRITEME
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 formpublic static void do_getUserLists(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
{ buddyList: { 0: { buddy-notice... } , 1: { buddy-notice... } , ... } , ignoreList: { 0: ignoredUserName, 1: ignoredUserName, ... } }
jso
- no parameters neededu
- WRITEMEroom
- WRITEME
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 formpublic static void do_getZoneList(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
AbstractZone.getZoneList_JSON(org.starhope.appius.user.AbstractUser)
)
jso
- Ignoredu
- The user requesting the data.room
- Ignored
org.json.JSONException
- If something untoward happenspublic static void do_initUserRoom(org.json.JSONObject jso, AbstractUser u, AbstractRoom 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)
jso
- { room: (room-number), autoJoin: (boolean) }u
- WRITEMEuserCurrentRoomInZone
- WRITEME
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 formpublic static void do_ping(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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 formpublic static void do_removeFromList(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
jso
- { buddy: (name) } or { ignore: (name) }u
- WRITEMEroom
- WRITEME
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 formpublic static void do_reportBug(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
jso
- Must contain a single string attribute named "bug."
Other attributes will be ignored.u
- The user reporting the bug.room
- The user's current room.
org.json.JSONException
- JSON encoding errorpublic static void do_reportUser(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
jso
- { userName = user to be reported }u
- WRITEMEroom
- WRITEME
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 formpublic static void do_sendOutOfBandMessage(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
jso
- { to: userName, body: {JSON} } { toRoom: true, body:
{JSON} }u
- WRITEMEroom
- WRITEME
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 formpublic static void do_setAvatarColor(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException
Params: "base" and "extra" are color numbers
WRITEME: document this method (brpocock, Aug 27, 2009)
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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 formpublic static void do_setFurniture(org.json.JSONObject jso, AbstractUser u, AbstractRoom 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 }
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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
- WRITEMEpublic static void do_spawnZone(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException, PrivilegeRequiredException
jso
- JSON object, containing an associative array whose
values are zones to be spawnedu
- The caller responsibleroom
- Where is the caller?
org.json.JSONException
- if something goes awry
PrivilegeRequiredException
- if the user isn't a Developerpublic static void do_speak(org.json.JSONObject jso, AbstractUser u, AbstractRoom room) throws org.json.JSONException, NotFoundException
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
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
- WRITEMEprivate static String getBuddySignature(AbstractUser u, AbstractUser u2)
u
- WRITEMEu2
- WRITEME
public static String getRev()
static String handleDice(String inSpeech)
inSpeech
- Speech before filtering
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |