Background – A role-playing game (RPG) is a traditional game in which players can pretend to be characters that partake several roles in a fictional setting. Although many different styles exist, we will be focusing on a fantasy game in which Player can play a Mage, or a Warrior. The goal of the program is to simulate a very basic interaction between a hero character and an enemy in a turn-based battle.

Background –

A role-playing game (RPG) is a traditional game in which players can pretend to be characters that partake several roles in a fictional setting. Although many different styles exist, we will be focusing on a fantasy game in which Player can play a Mage, or a Warrior. The goal of the program is to simulate a very basic interaction between a hero character and an enemy in a turn-based battle.

Program you will need –

You will need to have the DICE Class program which you created in Assignment 5.

Part 1 – Creating Hero Characters

            Overview

In this game, the player will be able to create a character and choose a role of his/her choice. There should be a superclass that represents a HERO which then specializes in a specific role such as mage and warrior and a third specialization of your choice.

 
 

Superclass: Hero (Hero.java)

Create a file named Hero.java which will contain the Hero class.  A hero will have the following information:

Name Represents the name of the character
Level Represents the Level of the character, most characters start at level 1
Health Points Represents the how many hit points the character can take before losing
Base Damage Represents the amount of hit points that a normal hit by this character would do to another character.
Weapon Represents the name (or type) of the weapon being used by the hero
  1. Create a no-arg constructor that gives default values for all of the fields. A default character should have the name of “Snow”, start at level 1, have 100 health, have 10 base damage, and utilize a wooden sword as their weapon.

 

  1. Create a constructor that requires all fields as arguments. Initialize all fields to be equal to the corresponding arguments.
  2. Create a constructor that has another Hero as an argument. Initialize all fields to be equal to the fields of the other Hero.

 

  1. Create setters and getters for all fields.

 

  1. Create a method called attack( ) – This method should return a value that represents how much damage the character has done. This function should utilize Dice object (created in assignment 5. This function needs to create a new 20-sided dice and roll it. Based on the result of the roll the following should occur:
Number Rolled Expected Outcome
1-4 The attack missed, therefore returning 0.
5-15 The attack was successful, therefore return the base damage
16-20 Critical Hit – the attack does 2.5 times more damage than the base damage.
  1. Create a method called adjustHealth( ) – This method should take 1 argument, a value. The purpose of the method is to update the hero’s health based on the given value. For example: assume the hero currently has 58 health. If the argument 13 is passed, then the hero’s health would be updated to 45.

 

  1. Create a method compareLevels( ) – This method should take 1 argument, another Hero. The purpose of the method is to return a string message that warns the player whether the Hero’s level is lower, the same, or higher than the level of the Hero object that was passed as an argument.
  2. Create a method toString( ) – This method should return a string message describing all Hero.

Subclass: Mage Hero (Mage.java)

Create a file named Mage.java which will contain the Mage subclass.  Contains one field:

Mana Mana is a value which represents the resource required by a Mage in order to create spells.

 

  1. Create a no-arg constructor which sets Mana to 100 points and initializes all the fields of the superclass to the default values — A default mage should have the name of “Merlin”, start at level 5, have 500 health, have 40 base damage, and utilize a wooden staff as their weapon.

 

  1. Create a constructor that requires the user to provide the Mana and all fields of the Hero Class. Set all fields accordingly.

 

  1. Create a constructor that has another Mage as an argument. Initialize all fields to be equal to the fields of the other Mage.

 

  1. Create appropriate setters and getters for Mana field

 

  1. Override the attack( ) method: This method should return a value that represents how much damage the character has done. This function should utilize Dice object (created in assignment 5. This function needs to create a new 20-sided dice and roll it. Based on the result of the roll the following should occur:
Number Rolled Expected Outcome
1-9 The Mage tries to perform a powerful attack – this requires 20 mana. If the Mage does not have enough mana, then this attack performs 0 damage. Otherwise, this attack performs 3 times the base damage and reduces the mana by 20 points.
10-19 The attack was successful, therefore dealing the base damage. This also restores 5 points of mana to the mage.
20 Super Attack, the attack deals 5x the base damage and costs no mana

 

  1. Override the toString( ) method to also include the mage’s mana in the description.

 
 

Subclass: Warrior Hero (Warrior.java)

Create a file named Mage.java which will contain the Warrior subclass.  Contains one field:

Stamina Stamina is a value which represents the resource required by a Warrior in order to perform attacks.

 

  1. Create a no-arg constructor which sets Stamina to 100 points and initializes all the fields of the superclass to the default values — A default warrior should have the name of “Arthur”, start at level 5, have 800 health, have 25 base damage, and utilize a iron sword as their weapon.

 

  1. Create a constructor that requires the user to provide the Stamina and all fields of the Hero Class. Set all fields accordingly.

 

  1. Create a constructor that has another Warrior as an argument. Initialize all fields to be equal to the fields of the other Warrior.

 

  1. Create appropriate setters and getters for Stamina field.

 

  1. Override the attack( ) method: This method should return a value that represents how much damage the character has done. This function should utilize Dice object (created in assignment 5. This function needs to create a new 20-sided dice and roll it. Based on the result of the roll the following should occur:
Number Rolled Expected Outcome
1-3 The Warrior tries to perform a powerful attack – this requires 50 stamina. If the Warrior does not have enough stamina, then this attack performs 0 damage. Otherwise, this attack performs 6.5 times the base damage and reduces the stamina by 50 points.
4-12 The attack was successful, therefore dealing the base damage. This also restores 10 points of stamina to the warrior.
13-20 Critical Hit, the attack deals 2.8x the base damage and costs no stamina

 

  1. Override the toString( ) method to also include the warrior’s stamina in the description.

 
 
 
 

Part 2 – Playing the Game

The Program:

Write a program Game.java which contains a main function. This program allows the user to pick which type of character they would like to become (a warrior or a mage). Create the opposite hero to be the enemy (which will be played by the computer).
Allow the user to provide whichever information they want about their character.
Simulate a fight between the player’s hero and the enemy allowing them to attack each other in turns. And adjusting their health accordingly. The two heroes should keep on fighting until one of the characters reaches 0 (or below) health points.
Display a message letting everyone know who the winner is once someone is victorious.
Note: This part is open-ended on purpose! Be creative

Commenting and Style

In this test file, the first 3 lines of you program should have a multiline comment (Starting with /*  and ending with */). This should include the author’s name, the date and the purpose of the file.
You should then include single line comments throughout your main method to explain what you are doing. For example:
Don’t forget to add a space before and after operators and to align braces.

Submission and Grading:

Submit all files through Blackboard.
Your grade will be determined based on the following rubric:

Task Points
Hero Superclass 20 points
Mage subclass 15 points
Warrior Subclass 15 points
Game Program 30 points
Documentation & Style 20 points
Total 100 points

Penalties

If the program does not compile or run, 30 points will be deducted from your total.
It is very important to test your program!
 

Posted in Uncategorized