2018sp-cs117-stage5-SpecializingItems1.pdf

Name CS117 Project Stage 05: Special Items – Page 1

Project Stage 05: Special Items

In the previous two stages we added basic items and containers to our world. An interesting text adventure game will have many of both, but it will also have other kinds of specialized items that the player can use. In this stage, you will create all of the special types of items that exist in your game. Because every game has different types of special items, these instructions are much more open-ended than in the previous stages.

1 Design

As in the previous two stages, we will start by reviewing the items that you have specified in the previous stages. In this stage, we will focus on the play items since these are the ones that are going to be used to do things in your game. As you do this you will realize that there are many different special items in your game. Along with these items often come special commands. In this stage, you will be identifying what kinds of items you have and what kinds of commands are needed to make them useful.

Items that provide flavor to your world can be instances of the basic Item class that you have already written, because the player cannot do anything with these items but examine them, carry them, etc. Some other items can be instances of the Container class that you have already written, because the player can also pack and unpack other items from them.

But your game should contain other kinds of items that the player can interact with in other ways. For example:

• The player can eat food (and only food).

• The player can equip weapons (and only weapons).

• The player can switch switchable items (and only switchable items).

Items of these types will require their own classes, which should extend either Item or Container. Before we can start implementing them, we need to have a clear idea of what types of items exist in

your game. In the same file where we have been providing you with GWTs for each command, you need to add your own GWTs for special commands such as eat, equip, or switch in your game. You should have at least two such commands. You may NOT have the generic command use, but must instead have specific command words.

Notice the structure of the GWTs that have been provided to you. Each command has a sequence of them that describe what to do in every possible situation that can occur. Each GWT first lists a possible condition the game could be in when the user types a command (as GIVEN), then the command typed by the user (as WHEN), and finally the results of the command when those conditions hold (as THEN).

2 Implementation

We are going to use interfaces to implement special item commands. Generally, each command will require its own interface, but some commands might be grouped into a single interface, like in these examples:

• Interface Edible would include a method named eat.

• Interface Equippable would include methods named equip and unequip.

• Interface Switchable would include methods named switchOn and switchOff.

Name CS117 Project Stage 05: Special Items – Page 2

Each of these methods (when implemented in a class) will be responsible for modifying the world in whatever way is necessary when that command is chosen and for generating a message that can be printed to the user. Thus, all of them will return a String (the message to be printed), and most of them will require parameters. For example, some commands might need access to the Player, others to a Room, and others perhaps to a second Item.

After you have created these interfaces, you can start creating classes for the special items in your game, like in these examples:

• A banana and a sandwich might both be instances of a class Food, which extends Item and implements Edible.

• A knife might be an instance of a class Weapon, which extends Item and implements Equippable.

• A flashlight might be an instance of a class LightSource, which extends Item and implements Switchable .

• A light saber with a compartment for storing your personal effects might be an instance of a class LightSaber, which extends Container (because it can store things) and implements both Equippable (because you can equip it) and Switchable (because you can turn it on and off).

I must emphasize that all of these are only examples of types of special items you might create. I am not saying that every game will have bananas, knives, and flashlights, or even that every game will include commands for eating, equipping, or switching on/off. You might have these kinds of special items or something very different – whatever fits into your game design.

After you have created the classes for your special items, you can add some to the world / convert some of the basic items in your world to special items.

Then you can implement the commands themselves. These will look a little bit different from our earlier commands. Like those, the method in the Game class will need to check for parameters, make sure that items exist and are the correct type, get additional input if necessary, etc. But to actually do the work of eating, equipping, switching, etc. they will call the methods from your interfaces on the items.

3 Looking Forward

In this stage you customized your game by creating classes and interfaces that are unique to the story that you would like to tell. In the next and final stage you will continue to make your game special by adding features, which are extra things that allow you to show off what you have learned in CS117 and to give the player interesting things to do.

Over the years, we have identified a list of common types of features that people like to put in their game, which you will find below. When I was reading your design document at the beginning of the semester, I made a list of those features that I saw in your descriptions and added it to the bottom of my game summary. Because some features are more challenging to complete than others, we assign each feature a point value. You need to include a combination of features in your game that are worth at least 20 points together.

Here is a list of common features, with their value. If you would like to do something that sounds like it would be a feature but is not listed here, please come explain it to me so that I can assign it a point value and help you figure out how to make it work.

Non-Player Characters are people (or sometimes animals or machines) with whom the player can talk. To count for the full point value, these need to be deep conversations with multiple paths for the player to choose. (10 points)

Name CS117 Project Stage 05: Special Items – Page 3

Shops are NPCs that sell items to the player. (5 points in addition to the NPC ones)

Elevators are rooms that exit to different locations based on what floor they are on. (5 points)

Mazes are groups of confusing rooms that all look the same. (5 points)

Vehicles are rooms that can move around. (5 points)

Appearing Exits are exits from rooms that can be made accessible and inaccessible by player actions. (5 points)

Changing Descriptions are rooms (or items, or NPCs) whose descriptions change as a result of player actions. (5 points)

Battles are combat encounters between the player and enemies. (10 points)

Buildable Items are items that cannot be found but must be constructed out of other items. (5 points)

Countable Items are items that appear in stacks. (5 points)

Minigames are things the player must do that take them out of the usual interface. (5 points)

Random Events are things that have a probability of occurring each turn. (5 points)

Add a new section to your design document that will list the features that you plan to use. For any feature described above that you would like to use, list the name of the feature and explain how it will be used and where it will appear in your game. If you would like to do any other interesting thing in your game that does not fit into any of those categories, list it as well with a similar explanation, and talk to me about how many points it should be worth.

If / when I accept your submission for this stage, I will add documents explaining how to implement each of your features in the next stage.

4 Finishing

In order to continue you must:

• Write GWTs for at least two commands that can be applied to special items in your game.

• Define interfaces for those commands.

• Write subclasses of Item that implement those interfaces for different types of special items.

• Add special items to your world.

• Implement the commands that allow the player to interact with special items.

• Have at least 20 points worth of features explained in your design document.

When you are ready double check that you have been using good style (HINT: use Checkstyle to help you) and that all the code you have implemented is properly documented. Be sure that all of your changes are committed and pushed to Github.

Instead of uploading an archive of your project, you will be uploading a commit marker called an secure hash algorithm (SHA). Every commit in GitHub has a SHA marker attached to it. When you are happy with your submission, commit and push your changes to GitHub. Go to the GitHub website and check to make sure your last commit has made it to the server. Now copy the commit link by right-clicking on the “Latest commit” and selecting “Copy Link Location” (see figure):

Name CS117 Project Stage 05: Special Items – Page 4

Once you have copied the link, go to the submission page on Moodle and paste it into the sub- mission text area. The link that you get will read something like: https://github.com/kings-cs/ CS117-S16-JumpMaria/commit/2076ab47397891666d11a2474208f24e73fe576d.