Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Improve information provided by First Room, some refinements to /help
Browse files Browse the repository at this point in the history
Signed-off-by: Erin Schnabel <[email protected]>
  • Loading branch information
Erin Schnabel committed Oct 19, 2016
1 parent aea9b8c commit 5d3d474
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ public interface Constants {
* List of common/always present commands
*/
JsonObject COMMON_COMMANDS = Json.createObjectBuilder()
.add("/look", "Look at the room")
.add("/examine", "Examine an item, e.g. `/examine` or `/examine item`")
.add("/inventory", "List your inventory (will vary by room)")
.add("/exits", "List room exits")
.add("/examine", "Examine an item. Implementations will vary: this may be similar to look, or may not work at all")
.add("/go", "Exit the room using the specified door, e.g. `/go N`")
.add("/look", "Describe a room or an item. Implementations will vary")
.add("/sos", "Emergency rescue: will return you to First Room")
.add("/help", "List available commands")
.add("/help", "List available commands. Result will vary room to room")
.build();

String MEDIATOR_UUID = UUID.randomUUID().toString(); // there is a liberty server one?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.gameontext.mediator.Log;
import org.gameontext.mediator.MapClient;
import org.gameontext.mediator.MediatorNexus;
import org.gameontext.mediator.RoutedMessage;
import org.gameontext.mediator.MediatorNexus.UserView;
import org.gameontext.mediator.RoutedMessage;
import org.gameontext.mediator.RoutedMessage.FlowTarget;
import org.gameontext.mediator.models.Exit;
import org.gameontext.mediator.models.Exits;
Expand Down Expand Up @@ -259,9 +259,14 @@ protected void buildLocationResponse(JsonObjectBuilder responseBuilder) {
responseBuilder.add(Constants.KEY_ROOM_FULLNAME, getFullName());
responseBuilder.add(Constants.KEY_ROOM_EXITS, exits.toSimpleJsonList());
responseBuilder.add(RoomUtils.DESCRIPTION, getDescription());
addRoomItems(responseBuilder);
addCommands(responseBuilder);
}


protected void addRoomItems(JsonObjectBuilder responseBuilder) {
// no-op.
}

protected void addCommands(JsonObjectBuilder responseBuilder) {
// no-op.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.logging.Level;

import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;

Expand All @@ -22,16 +23,16 @@ public class FirstRoom extends AbstractRoomMediator {
public static final String TELEPORT = "teleport";

public static final String FIRST_ROOM_FULL = "The First Room";
static final String FIRST_ROOM_DESC = "You've entered a vaguely squarish room, with walls of an indeterminate color.";
static final String FIRST_ROOM_EXTENDED = "\n\nTL;DR README (The extended edition is [here](https://gameontext.gitbooks.io/gameon-gitbook/content/)): \n\n"
static final String FIRST_ROOM_DESC = "You've entered a vaguely squarish room, with walls of an indeterminate color. A note is pinned to the wall.";
static final String FIRST_ROOM_EXTENDED = "\n\nTL;DR README (The extended edition is [here](https://book.game-on.org/)): \n\n"
+ "* Commands start with '/'.\n"
+ "* Use `/help` to list all available commands. The list will change from room to room.\n"
+ "* Use `/exits` to list all available exits.\n"
+ "* Use `/sos` to return to First Room if you're stuck.\n"
+ "* Rooms might try to fool you, but these three commands will always work.";

static final String FIRST_ROOM_INV = "Sadly, there is nothing here.";

static final String FIRST_ROOM_POCKETS = "You do not appear to be carrying anything.";
static final String FIRST_ROOM_POCKETS_EXTENDED = "\n\n Individual rooms "
+ " may or may not support the notion of items. So whether or not you have things in your pockets"
Expand Down Expand Up @@ -96,14 +97,29 @@ public Type getType() {
protected String parseCommand(String userId, String userName, JsonObject sourceMessage, JsonObjectBuilder responseBuilder) {
String content = sourceMessage.getString(RoomUtils.CONTENT);
String contentToLower = content.toLowerCase();

if (contentToLower.startsWith("/inventory")) {

if ( contentToLower.startsWith("/look ") || (contentToLower.startsWith("/examine"))) {
JsonObject contentResponse;
if ( contentToLower.contains(" note") ) {
contentResponse = RoomUtils.buildContentResponse(userId,
"Welcome to Game On!\n\n"
+ "Please take some time to explore the game and wander from room to room (`/go N`). "
+ "Each room is a separate microservice provided by developers like you. "
+ "We hope you feel encouraged to explore microservices by building your own room.\n\n"
+ "* Command behavior will vary from room to room, as different people write different things\n"
+ "* The Mediator (the service providing First Room) connects to rooms on your behalf using pre-defined websocket endpoints.\n"
+ "* Status updates on the right side show the Mediator's progress as it coordinates switching rooms.");

responseBuilder.add(RoomUtils.TYPE, RoomUtils.EVENT).add(RoomUtils.CONTENT, contentResponse);
} else if ( contentToLower.contains(" room") ) {
buildLocationResponse(responseBuilder);
} else {
contentResponse = RoomUtils.buildContentResponse(userId, "Not sure what you're trying to examine.");
responseBuilder.add(RoomUtils.TYPE, RoomUtils.EVENT).add(RoomUtils.CONTENT, contentResponse);
}
} else if (contentToLower.startsWith("/inventory")) {
responseBuilder.add(RoomUtils.TYPE, RoomUtils.EVENT).add(RoomUtils.CONTENT, buildInventoryResponse());

} else if (contentToLower.startsWith("/examine")) {
responseBuilder.add(RoomUtils.TYPE, RoomUtils.EVENT).add(RoomUtils.CONTENT,
RoomUtils.buildContentResponse("You don't see anything of interest."));

} else if (contentToLower.startsWith("/listmyrooms")) {
processListMyRoomsCommand(userId, responseBuilder);

Expand Down Expand Up @@ -139,13 +155,21 @@ protected void buildLocationResponse(JsonObjectBuilder responseBuilder) {
@Override
protected void addCommands(JsonObjectBuilder responseBuilder) {
JsonObjectBuilder content = Json.createObjectBuilder();
content.add("/inventory", "Check your pockets");
content.add("/listmyrooms", "List all of your rooms");
content.add("/teleport", "Teleport to the specified room, e.g. `/teleport room-id`");
content.add("/deleteroom", "Deregisters a room you have registered. e.g. `/deleteroom room-id`");

responseBuilder.add(Constants.KEY_COMMANDS, content.build());
}

@Override
protected void addRoomItems(JsonObjectBuilder responseBuilder) {
JsonArrayBuilder content = Json.createArrayBuilder();
content.add("Note");
responseBuilder.add(Constants.KEY_ROOM_INVENTORY, content.build());
}

protected JsonObject buildInventoryResponse() {
if (inventory)
return RoomUtils.buildContentResponse(FIRST_ROOM_POCKETS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class SickRoom extends AbstractRoomMediator {

// %s will be replaced by the room's full name
static final List<String> SICK_DESCRIPTIONS = Collections.unmodifiableList(Arrays.asList(
"A hasty message has been taped to the wall, `Not feeling well, I've gone to lie down -- %s`"
"A hasty message has been taped to the wall: \n\n> Not feeling well, I've gone to lie down\n> \n> -- %s\n\nThis room is not healthy."
));

static final List<String> SICK_COMPLAINTS = Collections.unmodifiableList(Arrays.asList(
Expand Down Expand Up @@ -173,7 +173,7 @@ protected String parseCommand(String userId, String userName, JsonObject sourceM
String content = sourceMessage.getString(RoomUtils.CONTENT);
String contentToLower = content.trim().toLowerCase();

if (contentToLower.startsWith("/examine") ) {
if (contentToLower.startsWith("/examine") || contentToLower.startsWith("/look") ) {
JsonObject contentResponse;

if ( contentToLower.contains(" monitor") ) {
Expand Down
2 changes: 1 addition & 1 deletion mediator-wlpcfg/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ dockerrc
/servers/.pid
/build/
/servers/.classCache
/servers/gameon-mediator/configDropins/overrides
/servers/gameon-mediator/configDropins
/servers/gameon-mediator/defaultServer
4 changes: 4 additions & 0 deletions mediator-wlpcfg/servers/gameon-mediator/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@

<webApplication contextRoot="/mediator" id="mediator-app" location="mediator-app.war" name="mediator-app"/>

<include location="${env.GAMEON_MODE}-local.xml" optional="true" />
<include location="${env.GAMEON_MODE}-logCollector.xml" optional="true" />
<include location="${env.GAMEON_MODE}-messageHub.xml" optional="true" />

</server>
Empty file removed mediator-wlpcfg/shared/.gitkeep
Empty file.
6 changes: 3 additions & 3 deletions mediator-wlpcfg/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ if [ "$ETCDCTL_ENDPOINT" != "" ]; then
export LOGMET_PWD=$(etcdctl get /logmet/pwd)
export SYSTEM_ID=$(etcdctl get /global/system_id)

GAMEON_MODE=$(etcdctl get /global/mode)
export GAMEON_MODE=${GAMEON_MODE:-production}

#to run with message hub, we need a jaas jar we can only obtain
#from github, and have to use an extra config snippet to enable it.
mv ${SERVER_PATH}/configDropins/messageHub.xml ${SERVER_PATH}/configDropins/overrides
wget https://github.com/ibm-messaging/message-hub-samples/raw/master/java/message-hub-liberty-sample/lib-message-hub/messagehub.login-1.0.0.jar

exec /opt/ibm/wlp/bin/server run defaultServer
else
cp ${SERVER_PATH}/configDropins/localDev.xml ${SERVER_PATH}/configDropins/overrides

exec a8sidecar --log --proxy --register --supervise /opt/ibm/wlp/bin/server run defaultServer
fi

0 comments on commit 5d3d474

Please sign in to comment.