Develop your own fully functional text-based adventure game

Assignment Help JAVA Programming
Reference no: EM132298517

Brief
Text-based adventure games have been around since the 1960s and have a simple interface in which the player types in commands using the keyboard. These commands allow the player to move through and search the gaming environment, pick up objects and fight monsters.

For this assignment you are to individually develop your own fully functional text-based adventure game. You are allowed to repurpose any example or exercise code you have implemented in the lab, assuming you have written the code yourself.

Gameplay
The player explores a maze of rooms picking up weapons to wield against monsters, food and valuables to store in their inventory. The player wins if they find the exit and escape the maze. The player loses the game if their health points reach 0.

The player has health and confidence points which are boosted by eating food or admiring valuables in the inventory. Weapons are used to fight monsters and are stored in the inventory. Chests may be found throughout the maze. Treasure chests contain valuables and are opened with a key and War chests contain weapons and are opened with a lockpick.

As the player moves between rooms, a monster may attack them. The player must battle the monster by wielding a weapon and exchanging attacks until one is defeated. During battle, the player may wield any weapon in their inventory. The player's confidence and wielded weapon determines their attack strength. A monster's attacks decrease the health and confidence points of the player, based on the strength of the monster.

The tables below describe the commands available in explore and battle modes.

 

 

Description

When the player enters a room the following events occur:

  • A monster may randomly appear (and go to battle mode)
  • A description of the room is displayed

door n Opens door labeled n and enter the room

pickup item Pick up an item in room and add to inventory

exit Search room to find exit. 

Describes the room, list pickups on the floor and number of doors describe available

Admire a valuable pickup in the inventory to increase confidence.

admire valuable The valuable may only be used once to increase confidence, but is not removed from the player's inventory.

Eats a food pickup in the inventory to increase health points. Once

eat food eaten, the food is removed from the player's inventory.

Uses the mobile phone pickup if present in inventory (See note

mobile below for ENSE602 students only)

stats Display player health and confidence points and inventory

wield weapon Player wields weapon from inventory for battle wield fistsoffuryPlayer wields fists of fury (does not appear in inventory)

Opens a treasure or war chest in the inventory using the key or

open chest key lockpick. The contents of the chest is placed in the player's inventory and both the chest and key removed.

help Displays commands in this mode

quit Ends the game

Battle Mode    

Commands

Description

attack Attacks the monster in the room using the wielded weapon

wield weapon Player wields weapon from inventory for battle wield fistsoffuryPlayer wields fists of fury (does not appear in inventory)

help Displays commands in this mode

quit Ends the game

Assignment - Supplied Files

1. Assignment3Start.zip is a project archive file containing all starting code
2. classdiagram.pdf is a document containing an informal UML diagram outlining relationships between classes in the assignment Assignment 3 Eclipse Project

Step 1: Import the Project
You have been supplied with an archive file Assignment3Start.zip to import into your
Eclipse workspace. In Eclipse, go to File -> Import -> Existing Projects into Workspace. Click "Select archive file" and browse to Assignment3Start.zip. Ensure the project is selected in the "Projects" list and click Finish. You should see the gameplay package with three classes: Inventory, ReadWorldDataFile and World. The file folder worlddata contains a text file simpleworld.txt.

Step 2: Implement the Entity Class
Implement the Entity class hierarchy as described in the supplied file classdiagram.pdf. Start by defining the abstract class Entity. Abstract classes are denoted by <<>> on the diagram.

All entities in the game will need a description and a unique identifier String id. Create the Entity(String) constructor which takes a description and sets the unique identifier with the code:

this.id = this.getClass().getSimpleName();

Add get/set methods for the description. Assume throughout that we will need get and set methods for most instance variables, unless stated otherwise. Add a get method for id. The entities in our game will often exhibit randomized behavior. Write a protected method which returns a random integer between two numbers x and y (exclusive):
returnnew Random().nextInt(y-x) + x;

Next, write the compareID(String) method, which determines the entity's id equality to a given string, ignoring case. Lastly, the toString method should return the entity's id.

Step 3: Implement the Pickup Subclasses
Pickup is an abstract class (extends the Entity class). It simply contains a constructor to initialize the description.
Pickup is extended by Openers, Openable, Consumable and Wieldable.
• The Opener abstract class, Lockpick and Key subclasses have constructors to initialize their descriptions.
• The Openable class has a boolean locked and also has a Pickup content instance variable. The constructor should set these values (description and content) (locked is initialized to true). It has an abstract method unlockWith (Opener) that should be overridden in WarChest and TreasureChest subclasses.
• Consumable maintains a boolean instance variable to determine if the object has been consumed.
• Valuables is an abstract class extending Consumable that maintains a number representing the object's value. There are seven subclasses; refer to the class diagram and implement each one, defining an appropriate constructor for each. No new methods or data is needed for these subclasses.
• Food is an abstract class which stores a number representing health points. Refer to the class diagram for the names of the three subclasses extending Food. They do not require any additional methods or data.
• Wieldable is an abstract class which has two integer value instance variables high and low. The hit method returns a random number x such that lo <= x < high (using the random method in Entity class), which represents the strength of the weapon. A constructor should initialize all instance variables. There are three subclasses; refer to the class diagram and implement each one, defining the necessary constructor for each class.

Step 4: Implement the Character Subclasses
The Character class has
• an instance variable to keep track of health points which should always store a nonnegative number
• a constructor to instantiate all instance variables.
• abstract methods oprotectedabstractintdealAttackDamage();opublicabstractintdefendAttack(Character enemy);

The Monster subclass of Character
• has integer values storing the probability of the monster appearing in a room and the amount of damage the Monster can deal in an attack. The constructor initializes these values and the description.
• overrides the above abstract methods. The dealAttackDamage method returns the value damage+r, where r is a randomly selected value between 1 and 10. The defendAttack method simulates an incoming attack from an enemy character. The method invokes d = enemy.dealAttackDamage() and reduces the character's health by d. The value d is returned by the method to report how much damage was dealt to the character.
• has a method booleanappear() to determine whether or not the monster appears in a room. If the monster's health is 0, false is returned. Otherwise, the monster appears with frequency based on its probability value. A simple way to implement this method would be to pick a random number x between 0 and 101 (exclusive) and return x<=probability.

The Player class has instance variables
• confidence value
• name
• Wieldable weapon
• Inventory inventory
• Potentially other variables as needed

The Player class implements the methods
• dealAttackDamage(), which has a different way of calculating the amount of damage dealt by the player's attack. It is based on the formula damage = h + h*c/100, where h is the strength of the user's weapon (hit() return value) and c the confidence of the player.
• defendAttack(Character enemy), behaves similar to the implementation by Monster. It calculates and returns damage from the enemy's d = enemy.dealAttackDamage and decreases the player's health by d. Additionally, the player's confidence is decreased by d/2.

The Room class contains instance variables:
• Monstermonster
• InventorypickupsInRoom
• Room[] connecting
• booleanfinalRoom

The Room objects maintains a list of Pickup objects present in the room by way of the
Inventory class, which maintains an ArrayList (supplied for you in the gameplay package). ArrayList is a dynamic array, in which elements can be added and removed. Room will need the default constructor (which initializes instance variables to null values) and constructor with signature

publicRoom(String description,InventorypickupsInRoom,
Room[] connectingRooms)

Room objects are constructed by the static readFile method in the ReadWorldDataFile class. Thus constructors, get and set methods must match those used.

Step 5: Reading the World File
Now, we are ready to read the world data from a text file. You already have this code in ReadWorldDataFile, so uncomment it and make sure there are no errors. There is a static boolean variable outputToConsole=true, to output debugging information to the console when reading the text file. You do not need to make any other changes to this file.

Step 6: The World Class
You have been supplied with a mostly empty World class. It has a single main method with code to create World and Player objects and invoke a play(Player) method.

World world = ReadWorldDataFile.simpleWorld();
Player playerOne = newPlayer("Sir Kendric","Shiny Armour",100,50); world.play(playerOne);

Step 7: The play method
The World class implements the core playable functionality of the text game in the play(Player) method. This method has been provided to you and is essentially a while loop to processes input from the player depending on the current mode: battle or explore. The while loop continues until the game stops: when the player wins, loses or quits the game. You will need to write the code for private methods:
processExploreUserInput() and processBattleUserInput()

which prompts the player for input using a Scanner and processes it according to the commands available in explore and battle modes respectively (given in the Table).

The pickup command
Suppose processExploreUserInput reads the text "pickup JEWEL" from the player, storing the input in the variable inputCmd. Parse this string into tokens with the code

String[] tokens = inputCmd.toLowerCase().split(" ");

Which splits the string across spaces such that tokens = ["pickup","jewel"]. The processExploreUserInput compares tokens[0] with the commands possible in the explore mode, using a switch statement. Since the player has invoke the pickup command, perhaps a private pickup() method in the World class is invoked. This method would determine if a Pickup object with an id "jewel" was present in the room's inventory (pickupsInRoom). If so, it would be removed from the room and placed in the player's inventory.
The admire command
As another example, suppose the player later types "admire goldbars" in the explore mode prompt and the admire() method is invoked, which carries out the following steps:
1. Determine if goldbars is in the player's inventory (use Inventory's select method)
2. If so, then Pickup pickup = player.getInventory().select(id)
3. Use the code (pickup instanceof Valuable) which returns true if pickup refers to a Valuable object.
4. Since GoldBars is indeed a subclass of Valuable, we cast Valuable valuable =
(Valuable) pickup;
5. Then, we are able to invoke this.player.admire(valuable), which you need to implement In Player class to increase the confidence of the player with the valuable's value if it's not consumed.
(Follow same steps for eat command)

All the other commands are structured similarly.

Step 8: The Mobile Valuable
The Mobile class extends Valuable and can be admired by the player to gain confidence. Like most people, the player finds it difficult being lost in a maze without access to the internet. Thus, the Mobile gives the player a means to check social media. The supplied sample console output file output3.txt demonstrates the following Mobile command:

which returns the most recent tweet posted by Mark Hamill (which happens to be a retweet of an original tweet posted by the President of France).

Attachment:- Brief.rar

Reference no: EM132298517

Questions Cloud

Recruit new employees for health care organization : Discuss several methods that health care managers can use to recruit new employees for a health care organization
Apply the steps to resolving this ethical dilemma : You believe the emergency department has room to care for this patient. Explain how would you apply the steps to resolving this ethical dilemma.
Relationship between media and advertising audiences : How can an organisation use the information about the relationship between media and advertising audiences established by profiling the market?
Discussion guide to conduct the focus groups : Student services at a (any) University want to change the offered events. Develop a Focus Group Discussion Guide to conduct the focus groups.
Develop your own fully functional text-based adventure game : Develop your own fully functional text-based adventure game. You are allowed to repurpose any example or exercise code you have implemented in the lab, assuming
Develop and maintain your professional competence : 1. Your task is to develop your own plan to meet at least four goals of your job role including the following:
Analyze the data based on the survey using SPSS software : Instructions: Need to analyze the data based on the survey using SPSS software. There are two clinics 1 and 2
What is the purpose of process mapping : What is the purpose of process mapping? How is it used to analyze and improve a process? Be specific.
Explain what approach you would : Explain what approach you would take to your presentation and why.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd