Project 2c

Due Date: Tue 29 Nov (firm!)

Group Project

Please see here.

Objectives

An understanding of
  • object-oriented modeling and design
  • SOLID and other design principles
  • basic design patterns and their implementation in C#
    • strategy
    • observer
    • decorator
    • singleton
    • iterator
    • command
  • graph representation and algorithms
  • human-computer interaction (HCI)

Description

This project builds on your design and implementation work from the previous project. The principal change is that we are now turning the project into a text-based interactive game.

Concretely, the game starts with the player at the designated starting location (the proverbial "square one"). The human user directs the player using the available commands detailed below. Initially, the player carries no items and has a configurable energy level. With each move the player makes, his or her energy level decreases by a configurable amount. When the player eats food, his or her energy level goes back up an amount that corresponds to the food item consumed. Certain locations contain items such as knives, keys, flashlights, food, and coins. The player can pick up items up to a configurable maximum. 

The object of the game is to reach an exit and pick up as many coins as possible in the process. The player has a configurable number of lives. If the player gets stuck in a dead end, such as a dungeon, or runs out of energy, he or she starves. 

Sample Session

This sample session is intended to give you an idea of the interaction with the game. You do not need to match it in detail, but your game must be similarly playable.
  • You are in the courtyard.
  • look here
  • You are in the shady courtyard with elm trees. You can go north or down. There is an energy bar and a flashlight.
  • take energy bar
  • take flashlight
  • info
  • You have 3 lives. Your energy level is 70%. You have an energy bar and a flashlight.
  • go down
  • You are in the banquet hall. It is pitch dark.
  • switch light
  • There is no light here.
  • switch flashlight
  • look here
  • You are in the long banquet hall. You can go east, west, or up. There is a coin.
  • take coin
  • ...

Commands

The following commands and associated behaviors are available:
  • info -> print number of lives left, energy level, and items being carried
  • look here -> print extended information of the current location, including
    • description
    • directions in which there are neighbors
    • items present
  • look <direction> -> print description of the neighbor in the given direction; precondition: there is a neighbor in that direction
  • go <direction> -> move to the neighbor in the given direction; precondition: there is a neighbor in that direction
  • take <item> -> pick up the item; precondition: the item available at the given location
  • drop <item> -> drop the item at the given location; precondition: the player is carrying the item
  • eat -> eat the food; precondition: the player is carrying at least one food item
  • enable/disable <feature> -> enable/disable the feature or item (e.g., flashlight, light source, draw bridge); precondition: the feature is available at the location
  • log <n> -> display the most recent n trip log events for this player
  • quit -> exit the game

Location Descriptions

Each location now has a name and a brief textual description. Example: "banquet hall" and "the long banquet hall". Whenever a player enters a location, the brief description is printed automatically.

Locations Enhancement

Locations can now be enhanced with the following features, some of which can be combined:
  • no daylight but with a installed switchable light source (operated by the switch command); the look commands will not work here unless the light is on
  • no daylight and without a switchable light source; the look commands will not work here unless the player carries a light source and turns it on
  • water with a player-operated draw bridge (operated by the switch command); the player will drown unless he/she operates the draw bridge before proceeding
  • booby trap that kills the player upon entry

Configuration

As mentioned above, the following settings are configurable in a central place:
  • player's initial number of lives
  • player's initial energy level
  • max items a player can carry
  • rate at which a player runs out of energy as he/she moves

Main Program and Specific Terrain

Enhance your terrain from the previous project to contain some of the enhancements mentioned above. Then enter the main command loop with the player on square one.

Error Handling

Your program must handle errors in the commands gracefully, for example:
  • It should automatically ignore leading or trailing spaces.
  • It should not crash on incorrect commands but re-prompt the user.

Written Portion

In about 600-900 words (two to three pages), succinctly describe your design, focusing on the changes you applied to your existing code from the previous subproject. Explain what design principles and patterns you used and discuss to what extent the pattern simplified or complicated matters.

Have fun!!!

Nonfunctional Requirements

  • Try to adhere to these C# coding guidelines.
  • More importantly, continue to follow test-driven development (TDD) by creating automated unit tests for your various program components.
  • Reuse suitable .NET library components whenever possible instead of building your own.
  • Use design principles and patterns where appropriate.
  • The player is responsible for providing the behavior that corresponds to the user commands listed above, as well as behaviors such as dying in certain situations; therefore, the player has methods corresponding to these behaviors. Accordingly, the player is responsible for maintaining his/her state, including:
    • lives left
    • current energy level
    • items currently carried

Extra Credit

Extra credit will be considered for the following additional features:
  • external description of terrain, including items found at different locations
  • external configuration
  • command undo/redo (Command Pattern)
  • graphical user interface

Grading

  • 5 commands (0.5 each)
  • 1 location Descriptions
  • 5 locations Enhancement (1 per enhancement plus 1 for ability to combine)
  • 2 configuration (0.5 per setting)
  • 1 error handling
  • 3 written portion
  • 2 documentation
  • 2 playability/user experience (subjective)
  • 2 nonfunctional requirements (overall architecture; player behavior)
  • 2 automated testing
Total 25

Submission

Please submit your code and written portion following the usual online submission procedure.
Comments