diff --git a/mediator-app/src/main/java/org/gameontext/mediator/Constants.java b/mediator-app/src/main/java/org/gameontext/mediator/Constants.java index bbde26b..ce625ce 100644 --- a/mediator-app/src/main/java/org/gameontext/mediator/Constants.java +++ b/mediator-app/src/main/java/org/gameontext/mediator/Constants.java @@ -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? diff --git a/mediator-app/src/main/java/org/gameontext/mediator/room/AbstractRoomMediator.java b/mediator-app/src/main/java/org/gameontext/mediator/room/AbstractRoomMediator.java index 1f331d6..d05533a 100644 --- a/mediator-app/src/main/java/org/gameontext/mediator/room/AbstractRoomMediator.java +++ b/mediator-app/src/main/java/org/gameontext/mediator/room/AbstractRoomMediator.java @@ -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; @@ -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. } diff --git a/mediator-app/src/main/java/org/gameontext/mediator/room/FirstRoom.java b/mediator-app/src/main/java/org/gameontext/mediator/room/FirstRoom.java index bd02aa3..691c611 100644 --- a/mediator-app/src/main/java/org/gameontext/mediator/room/FirstRoom.java +++ b/mediator-app/src/main/java/org/gameontext/mediator/room/FirstRoom.java @@ -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; @@ -22,8 +23,8 @@ 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" @@ -31,7 +32,7 @@ public class FirstRoom extends AbstractRoomMediator { + "* 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" @@ -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); @@ -139,6 +155,7 @@ 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`"); @@ -146,6 +163,13 @@ protected void addCommands(JsonObjectBuilder responseBuilder) { 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); diff --git a/mediator-app/src/main/java/org/gameontext/mediator/room/SickRoom.java b/mediator-app/src/main/java/org/gameontext/mediator/room/SickRoom.java index 7875288..69843af 100644 --- a/mediator-app/src/main/java/org/gameontext/mediator/room/SickRoom.java +++ b/mediator-app/src/main/java/org/gameontext/mediator/room/SickRoom.java @@ -40,7 +40,7 @@ public class SickRoom extends AbstractRoomMediator { // %s will be replaced by the room's full name static final List 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 SICK_COMPLAINTS = Collections.unmodifiableList(Arrays.asList( @@ -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") ) { diff --git a/mediator-wlpcfg/.gitignore b/mediator-wlpcfg/.gitignore index 1362b08..bd94ec2 100644 --- a/mediator-wlpcfg/.gitignore +++ b/mediator-wlpcfg/.gitignore @@ -12,5 +12,5 @@ dockerrc /servers/.pid /build/ /servers/.classCache -/servers/gameon-mediator/configDropins/overrides +/servers/gameon-mediator/configDropins /servers/gameon-mediator/defaultServer diff --git a/mediator-wlpcfg/servers/gameon-mediator/configDropins/localDev.xml b/mediator-wlpcfg/servers/gameon-mediator/development-local.xml similarity index 100% rename from mediator-wlpcfg/servers/gameon-mediator/configDropins/localDev.xml rename to mediator-wlpcfg/servers/gameon-mediator/development-local.xml diff --git a/mediator-wlpcfg/servers/gameon-mediator/configDropins/logCollector.xml b/mediator-wlpcfg/servers/gameon-mediator/production-logCollector.xml similarity index 100% rename from mediator-wlpcfg/servers/gameon-mediator/configDropins/logCollector.xml rename to mediator-wlpcfg/servers/gameon-mediator/production-logCollector.xml diff --git a/mediator-wlpcfg/servers/gameon-mediator/configDropins/messageHub.xml b/mediator-wlpcfg/servers/gameon-mediator/production-messageHub.xml similarity index 100% rename from mediator-wlpcfg/servers/gameon-mediator/configDropins/messageHub.xml rename to mediator-wlpcfg/servers/gameon-mediator/production-messageHub.xml diff --git a/mediator-wlpcfg/servers/gameon-mediator/server.xml b/mediator-wlpcfg/servers/gameon-mediator/server.xml index 11c279d..838265b 100644 --- a/mediator-wlpcfg/servers/gameon-mediator/server.xml +++ b/mediator-wlpcfg/servers/gameon-mediator/server.xml @@ -49,4 +49,8 @@ + + + + diff --git a/mediator-wlpcfg/shared/.gitkeep b/mediator-wlpcfg/shared/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/mediator-wlpcfg/startup.sh b/mediator-wlpcfg/startup.sh index 5164ea5..48ad9f7 100755 --- a/mediator-wlpcfg/startup.sh +++ b/mediator-wlpcfg/startup.sh @@ -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