· Web viewThe Dungeon constructor function should allocate an array of count Monster objects, and...

6
DASC 1204 - Programming Project 8 Due Date – 04/29/2021/2021 1. Problem Statement: Before computers and network speeds were fast enough for online multiplayer games to have high-quality graphics, text-based multi-user dungeons (MUDs) were common. In these games, players can explore the map, fight enemies, and perform other actions, given only textual descriptions of the world around them. While rudimentary, they are relatively simple to program, and the creative possibilities are endless. In fact, some MUDs have been active for decades and are still thriving. (from Crowler’s 1975 “Colossal Cave Adventure” game) The goal of this programming project is to create a small text-based dungeons and dragons inspired game. We will start by designing and implementing a “Monster” class with a simple combat system. Then we will create a “Dungeon” class that contains an array of Monsters and a simple game engine that will let the user simulate a battle between two Monsters. Detailed project requirements are given below. Task 1: Creating the Monster class Your Monster class needs to have the following attributes: Access Type Attribute Name Value Private string name tba Private int strength tba Private int health tba Private int defense tba Private int speed tba Public final int MAX_HEALTH 100 Public final int MAX_STRENGTH 50 Public final int MAX_DEFENSE 100

Transcript of  · Web viewThe Dungeon constructor function should allocate an array of count Monster objects, and...

Page 1:  · Web viewThe Dungeon constructor function should allocate an array of count Monster objects, and initialize all of the Monster attributes using a random number generator. The Math.Random()

DASC 1204 - Programming Project 8Due Date – 04/29/2021/2021

1. Problem Statement:

Before computers and network speeds were fast enough for online multiplayer games to have high-quality graphics, text-based multi-user dungeons (MUDs) were common. In these games, players can explore the map, fight enemies, and perform other actions, given only textual descriptions of the world around them. While rudimentary, they are relatively simple to program, and the creative possibilities are endless. In fact, some MUDs have been active for decades and are still thriving.

(from Crowler’s 1975 “Colossal Cave Adventure” game)

The goal of this programming project is to create a small text-based dungeons and dragons inspired game. We will start by designing and implementing a “Monster” class with a simple combat system. Then we will create a “Dungeon” class that contains an array of Monsters and a simple game engine that will let the user simulate a battle between two Monsters. Detailed project requirements are given below.

Task 1: Creating the Monster class

Your Monster class needs to have the following attributes:

Access Type Attribute Name ValuePrivate string name tbaPrivate int strength tbaPrivate int health tbaPrivate int defense tbaPrivate int speed tbaPublic final int MAX_HEALTH 100Public final int MAX_STRENGTH 50Public final int MAX_DEFENSE 100Public final int MAX_SPEED 20

Your Monster class needs to have the following methods:

Access Return

Method Name Inputs Purpose

Public none Monster none Default constructor

Public none Monster Five Monster attributes

Non-default constructor

Public none Monster One monster Copy constructor

Page 2:  · Web viewThe Dungeon constructor function should allocate an array of count Monster objects, and initialize all of the Monster attributes using a random number generator. The Math.Random()

Public string getName none Accessor

Public int getStrength none Accessor

Public int getHealth none Accessor

Public int getDefense none Accessor

Public int getSpeed none Accessor

Public void setName string Mutator

Public void setStrength int Mutator with error checking

Public void setHealth int Mutator with error checking

Public void setDefense int Mutator with error checking

Public void setSpeed int Mutator with error checking

Public void attack One monster Simulate one Monster attacking another Monster

Public void print none Print all five Monster attributes

Most of the Monster method descriptions are straightforward, but special rules apply when monster1 attacks monster2. To make the battle interesting, we will use randomness to determine if monster2 can dodge monster1 attack, and if not, how much damage is done to monster2. To do so, you must implement the following logic:

The attack speed of monster1 is a random value between 1 and monster1.speed. The attack power of monster1 is a random value between 1 and monster1.strength The dodge speed of monster2 is a random value between 1 and monster2.speed. When monster2 dodge speed > monster1 attack speed, then monster2 successfully dodges the

monster1 attack and no damage occurs. If monster2 does not dodge monster1, then monster2.defense tells us the percentage of the

monster1 attack power that is deflected from monster2. o Monster2.health = monster2.health – monster1.attack * (100 – monster2.defense)/100.o If monster2.defense = 0, monster2 has no protection from the attack.o If monster2.defense = 100, monster2 is invincible and is not damaged.

If the health of monster2 goes to zero, the monster dies.

Task 2: Creating the Dungeon class

Your Dungeon class needs to have the following attributes:

Access Type Attribute Name ValuePrivate Monster array array tba

Your Dungeon class needs to have the following methods:

Access

Return Method Name Inputs Purpose

Public none Dungeon count Create array of count Monsters with random attributes

Public none print none Print all of the Monsters

Public int getMonsterNum

none Prompt user for Monster number between [0..count-1]

Public void battle two monster numbers

Battle two Monsters until one Monster kills the other

Page 3:  · Web viewThe Dungeon constructor function should allocate an array of count Monster objects, and initialize all of the Monster attributes using a random number generator. The Math.Random()

The Dungeon constructor function should allocate an array of count Monster objects, and initialize all of the Monster attributes using a random number generator. The Math.Random() method returns double values between [0.0..1.0] which is not convenient for this application since the Monster attributes are almost all integers. Instead, you should use the Random class to create random integers between [0..range-1]. See example below:

Random rand = new Random();int value = rand.getInt(range);

The battle method should have monster1 attack monster2 and monster2 attack monster1 over and over again until one of the two Monsters dies (health value <= 0). Your Monster attack method should print out the “blow by blow” details so the user can see what is happening. You will discover that some battles are over after only two or three attack cycles, while others last over 50 turns.

Task 3 – Play the Game

You can use the following main program to create a Dungeon object and play the game to see which Monster wins the battle.

public static void main(String[] args){ // Create the dungeon System.out.println("\nWelcome to the Dungeon"); Dungeon dungeon = new Dungeon(5); dungeon.print();

// Get user input int player1 = dungeon.getMonsterNum("\nPlayer1 - Choose a Monster number: "); int player2 = dungeon.getMonsterNum("\nPlayer2 - Choose a Monster number: ");

// Have monsters battle dungeon.battle(player1, player2);}

2. Design:

The high level design for this project (classes, private variables, methods) is provided above. Your main task is to work out the algorithms needed to implement key parts of this program. For example, how to implement the “attack” and “battle” methods. The other big challenge is to construct the Dungeon with count Monsters with random attributes. You may want to refer back to your labs.

3. Implementation:

You are starting this programming project without any sample code, so you should start with skeleton methods and add code to implement methods one at a time. It is very important to make these changes incrementally one feature at a time, writing comments, adding code, compiling, and debugging. This way, you always have a program that "does something" even if it is not complete.

4. Testing:

You should test your program to demonstrate that your program is working correctly. Save a copy of your program input/output to include in your project report. A sample output is provided as a sample of what your program should output. Your numbers will be different because we are using a random number generator to initialize Monsters and do the battle.

Page 4:  · Web viewThe Dungeon constructor function should allocate an array of count Monster objects, and initialize all of the Monster attributes using a random number generator. The Math.Random()

5. Documentation:

When you have completed your program, write a short report using the “Programming Project Report Template” describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this project report in a separate document to be submitted electronically.

6. Project Submission:

In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic plagiarism analysis of all programs that are submitted.

When you have completed the tasks above go to Blackboard to upload your documentation as a docx or pdf file, and your Java program file.

The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:

10% off if less than 1 day late,20% off if less than 2 days late,30% off if less than 3 days late,no credit if more than 3 days late.

You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.

7. Academic Honesty Statement:

Students are expected to submit their own work on all programming projects, unless group projects have been explicitly assigned. Students are NOT allowed to distribute code to each other, or copy code from another individual or website. Students ARE allowed to use any materials on the class website, or in the textbook, or ask the instructor and/or GTAs for assistance.

This course will be using highly effective program comparison software to calculate the similarity of all programs to each other, and to homework assignments from previous semesters. Please do not be tempted to plagiarize from another student.

Violations of the policies above will be reported to the Provost's office and may result in a ZERO on the programming project, an F in the class, or suspension from the university, depending on the severity of the violation and any history of prior violations.