Montana Tech of The University of Montana
Computer Science Department

CSCI 135
Fundamentals of Computer Science I
Fall 2019



ASSIGNMENT 10 - Dungeon 2

NEWS FLASH!!! THIS ASSIGNMENT IS OPTIONAL!!
SHOULD YOU CHOOSE TO DO IT, IT WILL REPLACE YOUR LOWEST SCORE LAB

In this assignment, you will be extending the game you made for the last assignment.
  • You will extend an existing class hierarchy to add additional functionality.
  • You will refactor code to make the program simpler.

Dungeon 2. This is the exciting sequel to your previous assignment. Dungeon 2 adds these new features: Getting started. Download the file dungeon2.zip. This contains the assets as well as some provided classes and some stubbed out classes. NOTE: You may use your own Cell.py, CellPassage.py, CellDoor.py, Hero.py and Dungeon.py classes from the last assignment as a starting point, or you may use the ones provided. Whichever you choose, copy these files into your new Dungeon 2 project directory.

Dungeon definition. The dungeon definition is similar to the previous assignment, but there are now breakable rocks in the dungeon denoted by an 'R'. Also the second line now contains the number of gems, keys, and pickaxes to randomly place in the dungeon. As such, the files from your last dungeon assignment won't work with the new DungeonGame main program. Here is what d4.txt looks like:
13 10
10 4 2
1 1
W W W W W W W W W W W W W
W - W - - - - - - D - - W
W - R - W W W - W W - - W
W - W - S - S - W W - - W
W - R - W W W - W W W O W
W - W - W W W D W W - - W
W - W - W - - - - D - - W
W W W - W - W - - W - - W
W - - - W - W - - W - - W
W W W W W W W W W W W W W


Updated Config. The provided Config class has been changed in the following ways:
Part 0: Dungeon creation using file input. We have provided a partially completed DungeonFactory class. This class provides a method that handles all the work associated with instantiating a Dungeon object. The code that used to live in the main game program to read in a file should now be all tucked away in this factory class. You are to implement the createFromFile method. This method should construct a Dungeon using file input. HINT: You may re-use much of the code provided in DungeonGame.py from the last lab assignment.

Once complete, you can test it by running DungeonGame running it with a single command line argument:
% python DungeonGame.py d3.txt

Part 1: Changes to APIs. At this point, your program should compile. You should be able to run it on a dungeon without rocks by reading from standard input:
% python DungeonGame.py d3.txt
If you implemented containsItem and getCount correctly, you should be able to win the game by collecting all the gems. If last time you implemented collectItem in Hero in a general manner, you should notice that collecting a pickaxe results in a new sound effect. If not, you'll need to add logic to the Hero class in the next part to handle pickaxes.
Part 2: Breakable rocks and hero status. To support the new breakable rock feature, we have added a new PICKAXE value to the Item enumeration. We have also added rockImages to Config that returns a list of image filenames. The first image in the list is the starting point for a rock. Each time a rock is pickaxed, it goes to the next image and the use item sound effect is played. Every time the pickaxe is used, there is a 5% chance that the axe breaks. If the axe breaks, the item consumed sound effect is played. Once it reaches the final image, the passage way is clear and the hero is thereafter allowed to walk through that cell.



We have given you only a basic stub for CellRock. A variety of changes need to happen to realize your rock-breaking dream: You can test out your progress by running on a dungeon that includes rocks:
% python DungeonGame.py d4.txt
You should also add a status line at the top of the screen that shows the number of collected gems, keys, and pickaxes. The exact position, color, font size, and justification is up to you, just be sure that it is readable and doesn't obstruct a player's view. You can assume the top row of the dungeon will be a wall as in d4.txt. For example:
Gems: 5 Keys: 2 Pickaxes: 0

Grading
Grade ItemPoints PossiblePoints Earned
Header: Name and Description on ALL FILES
3
Program Compiles and Runs
3
Part 0: DungeonFactory
6
Part 1: API Changes
6
Part 2: Breakable Rocks
6
Hero Status Line, Allows Quit, Ends Game on Win
6
Total
30

Where did you get the graphics? For this assignment, Keith started with this 128 x 128 tile set from the Slash'EM game.


Extra credit. Make the game better. You might want to use some of the extra images provided in dungeon2-extra-assets.zip. Or you could also cut them out of the extremely large (20MB) image linked above. Please see the note below on how to submit your extra-credit creation. Be sure to submit your regular submission first and ensure it works per the assignment specifications.
Submission. Submit all the classes you changed: Cell.py, CellPassage.py, CellRock.py, Dungeon.py, Hero.py, and DungeonFactory.py. Be sure each submitted source file has the required header with your name and a description of the program and all your classes and methods are commented. For extra-credit, please submit a single zip file containing all your programs/graphics/sounds/configuration files via the special extra-credit drop box.

Page last updated: December 04, 2019