WebFund 2014W: Assignment 3

From Soma-notes
Jump to navigation Jump to search

The solutions for this assignment are available here.

In this assignment you are to examine, modify, and answer questions regarding the adventure-editor sample node application. The files of this application are also listed below. Note that to run this application you'll first need to run node storeRooms.js to setup the rooms collection in MongoDB.

Please submit your answers as a single zip file called "<username>-comp2406-assign3.zip" (where username is your MyCarletonOne username). This zip file should unpack into a directory of the same name (minus the .zip extension of course). This directory should contain:

  • your modified version of adventure-editor (one version with all code changes) and
  • a text file called "answers.txt" or "answers.pdf" at the top level (in text or PDF format, respectively) that contains the answers to the all of the questions, with the first four lines being "COMP 2406 Assignment 3", your name, student number, and the date. For questions requiring code changes (Part B), explain in your answers file which parts of the program were changed. You may wish to format answers.txt in Markdown to improve its appearance.

No other formats will be accepted. Submitting in another format will likely result in your assignment not being graded and you receiving no marks for this assignment. In particular do not submit an MS Word or OpenOffice file as your answers document!


Part A and B are mandatory and together contain 30 points. Part C is optional and contains an additional 10 points. Note that in cuLearn grades will be out of 40; full credit, however, is still 30 points.

Part A

  1. (2) How do you get the raw HTML of a page before any client-side JavaScript runs without modifying the configuration of any browser? Note you want to be sure to see exactly the HTML as it is received by the browser.
  2. (2) How can a player end up in the Void after starting a valid game session? Assume that the server is correctly configured and has a valid rooms collection. Also assume that the player has no access to the server other than accessing the adventure-editor web application.
  3. (2) What are the client-side AJAX calls in this application (before you have made any changes)?
  4. (4) When is the code in adventure.js called? If different functions are run at different times, explain.

Part B

  1. (2) In the editor, add a "quit" button to the bottom that takes you back to the initial screen.
  2. (4) In the editor, get the "Load" button to work. You should put the necessary client-side code in public/javascripts/editor.js. On the server this code should access /getContents; note, though, that you will have to make it so that the room can be selected when being requested from the editor.
  3. (4) In the editor, get the "Save" button to work by implementing the appropriate server-side code.
  4. (4) In the editor, add a room selector to the top that lists the names of all of the rooms in the rooms collection. This should be a drop-down menu or other control of equivalent functionality.
  5. (6) In the game, make it so that the game lists all of the players that are in the current room by saying in the last line of text (before the buttons), "Anil, Player7, Foo are here" (for example). You should omit the current player from this list. Keep track of the currently logged in players by adding and updating appropriately an "online" property to documents in the players collection. The query to the players collection should occur in getContents().

Part C (bonus)

  1. (bonus 5) In the game, add buttons above the exits that say "Actions:" followed by a set of actions.
    • These actions should change the activity description of the room.
    • Make a new actions property of rooms that is an array of objects, where each object has two properties: an action and a description. The action is used to label the action buttons. The description is the text that is used to replace the current activity when the button is pressed.
    • The activity string should not be changed directly on the client however. Instead it should send the action to the server, the server should update the room description, and then the client should retrieve the room description again after the button has been pressed (to get the current state of the room).
    • Note the room state will be the same for all of the current players of the game!
    • Using this new functionality, make it possible to ring the bell in engineering (and also stop the bell ringing).
  2. (bonus 5) Extend the editor to work with the "Actions". To get full marks make sure you provide a reasonable interface.