SpookyMansion and other Interactive Fiction to explore using and understanding Graphs.
The learning objectives of this assignment are:
- To practice using Maps/Sets with Java.
- To gain a some understanding of Graphs.
- To reinforce inheritance / overriding methods as a way of solving problems.
... --- ...
You are in the grand entrance hall of a large building.
The front door is locked. How did you get here?
0. There are stairs leading down.
1. There are stairs leading up.
2. There is a red door.
3. There is a brown door.
? 2
... --- ...
You've found the kitchen. You smell old food and some kind of animal.
0. There is a red door.
1. There is a dumbwaiter.
?
- Import the starter code. (Don't forget the Maven step).
- Play SpookyMansion, and sketch out the "game" on paper.
- Finish the game by finding the "Crypt" place.
- Add an Exit from the
secretRoom
to thebasement
(but not in the other direction). - Make the very long hallway even longer.
- Modify the very long hallway messages to include a number scratched on the wall, so that players can tell how far they've come.
- Add another room connected to the Attic.
- Add another room connected to the Basement.
- Change the solution to the labyrinth as well as the hint.
- Note on your "map" the changes you've made to the game's "Graph".
- Find the code in
InteractiveFiction
that handles quitting the game.
- (3) Allow users to quit with the word "escape" or just the letter "q". (They will still need to press enter).
- (3) Add a "help" command that explains to type in the number of the room as well as how to quit.
- You will need
continue
ORbreak
statements!
When you visit a place for the second time, print out a message indicating to the player that they have been to that place before. This will not carry over between games.
- (3) Add a
Set<String> visited
onto thePlayer
class. - (3) Print a message when the player has returned to a place they have already
visited
from the InteractiveFiction loop. - (3) Update this behavior from
false
totrue
within an appropriate method.
Remember that SpookyMansion will be due Due Date: February 27, 2020.
Remember that we will have a new assignment opening on the next day, so don't save it until the last minute!
You must complete a Google Form as usual to indicate the challenges you attempted and completed.
In addition, you will write 10 statements of either:
- Accomplishments: things that you understand much better now.
- Challenges: things that you are still working on understanding.
I will provide direct feedback to your writing.
This includes that your code should be professional.
- Try to proofread your work like an essay!
- Find all your
println("stuff")
statements and remove them, etc. - Your code looks intentional: don't just fiddle with it until it works. Reason about it! Sketch out the python by hand and then try translating to Java.
- Delete commented out code or experiments that don't work out. Make your submission as small as it needs to be.
- Your code is your own. Respect the honor code.
- Working with others or helping them debug is acceptable - use your best judgment! Make sure that you know what you're working on.
- Any methods or class-level variables left without a Javadoc comment (
/** */
) will result in the loss of a point. - Have comments explaining tricky code!
Consider building a spooky version of FordHall.
- (4) Must have at least 8 Places.
- (4) Must have at least 8 functional Exits.
- (4) Must have a terminal place (a way to win the game).
- Be creative?
What does this look like? Consider this example: SecretExit.md
- (4) Create a class SecretExit that extends Exit.
- (4) Override the method called
boolean isSecret()
. Exits are never secret, but SecretExits are until yousearch
for them. - (4) SecretExit should have a private boolean hidden, that starts off as true.
- (4) When a user types
search
, if there is a SecretExit in the room they are currently in, it should be made visible to them. Make avoid search()
method onPlace
that callssearch()
on all of its exits. - (4) Override
void search()
onSecretExit
so that it becomes no-longer-secret when called. - (4) Put a SecretExit from the
basement
to thesecretRoom
in SpookyMansion OR put a SecretExit in your custom game.
What does this look like? Consider part of this example: LockedExit.md
- (4) The player can no longer be represented by just a location. They need to know what key(s) if any they have.
- (4) Make a
stuff
command that prints out the users items or "You have nothing." - (4) Place must have a method that returns a list of items in a location (maybe just
List<String>
; don't need an item class) - (4) There must be an action to
take
any items associated with the location (just take all of them, no menu needed!). - (4) Items are part of the description until they are taken from a
Place
. See thegetDescription
method. It might be easier to create a newvoid printDescription()
What does this look like? Consider this example: LockedExit.md
- (4) Implement a
LockedExit
class that extendsExit
. - (4)
LockedExit
objects can only be chosen with the appropriate key (take aString required
) in the constructor. ... hint:canOpen
is nearly complete for you. - (4) Add a
LockedExit
to your game.
- (8) Create a class
GameTime
, that has anint hour
as state, ranging from 0 to 23 (inclusive). Implementint getHour()
andvoid increaseHour()
and print out the hour like a 12 or 24-hour watch. Do not change yourhour
field in your getter method. - (4) Extend the game's concept of a player with a current time. Increment the hour every time the player moves. Print out the current time after a room description.
- (4) Tell the player how many hours they spent in your game upon Game-Over. (Not the current time, so you'll need a new
int
on yourGameTime
class).
- (4) Make an action
rest
that advances the game 2 hours so that you can test your descriptions. - (4) Implement a boolean method called
isNightTime()
- (4) Add GameTime as a parameter to the
getDescription
method onPlace
(maybeprintDescription
now). - (8) Create some places with descriptions based whether GameTime
isNightTime()
-- maybe specific Places need to be subclasses with their own customprintDescription
!
- (12) Challenge: I'm not breaking this down, shares some work with
SecretExit
.
- Check with me to make sure it's not too hard :)