Fantasy Quest Adventure Game. You will create a small interactive console-based (i.e. text based)

W.e,C.h’a’t : help-assignment

Assignment Overview
You will create a small interactive console-based (i.e. text based)game. The project consists of 7 tasks. You are expected to use Visual Studio 2022 Community Edition to build your game. You should complete the tasks in order, as some tasks assume that previous tasks have been done. Each task builds upon the previous one. Do as much as you can and then package your project for submission. Your solution should demonstrate your knowledge of C++. Work alone: You must work alone on the assignment. Plagiarism checks will be run. If you notice any typos or mistakes in the assignment that I may have missed, or if you feel something is unclear, please contact me andy rox@live rpool. ac. uk) or post a question in the Canvas COMP282 Discussion page (there is a specific discussion relating to clarification of the assignments). If I update this page with further information or corrections, I will make an announcement via the Canvas Announcements feature. I will also change the Revision History log at the top of the document so that you know you are viewing the latest revision.
Submission Requirements
I will update this document with detailed submission requirements but the intention is that you will upload your cpp and h files to Canvas via Codegrade.
I hope to be able to make codegrade tests available for you to test your code against.

Fantasy Quest Adventure Game
The assignment is to create a basic command-line game using C++ and organise the game structure using C++ OOP methods.
The game has a fantasy theme, in a style similar to Dungeons and Dragons, consisting of a player that can navigate a series of connected locations. The player can collect items and engage in combat with monsters. The player’s score in the game increases when they defeat a monster. The objective of the game is to achieve a high score(by defeating monsters) and to collect the Eldritch Ring which is held by the End Of Level boss.
There should be some introductory text at the start of the game to set the scene
Commands
north or n: take the North exit.
south or s: take the South exit.
east or e: take the East exit.
west or w: take the West exit.
inventory or inv display a list of all the items that the player holds.
fight or f: engage in combat with a monster.
collect or c: collect all items in the current room.
drink or d: drink all potions currently held by the player.
quit or q: quit the game.
Please use the specified class and method names to ensure your code can be tested.
You are free to add further methods/variables/functions as you wish. Be sure to add comments to your code, briefly explaining the purpose and functionality of classes, methods, and significant blocks of code. Also remember to implement error handling.
I have specified most of the monsters, locations, and objects- this is so that the gameplay can be tested. You can add to the game if you want.

Task 1- Create game classes
The following classes should be written.
You decide on the appropriate member variable types and access specifiers.
Gameworld class
An object of the Gameworld class should hold the game world. It should also hold data about the game state. It should include the following methods:
bool isGameOver( ) Returns a bool representing if the game is over.
void setGameover(bool gameover)-Sets a flag to say that the game is over.
void loadWorld()- Creates and populates the game world (implement this in task 2).
Character Class
The Character class defines characters in the game.
Characters all have a name, description, armour, can hold items, are associated with a location, have hitpoints(i.e. health), and a skill rating. You decide on the appropriate member variable types.
The class should include the following methods:
int getArmourProtection () Calculates total armour protection based on armour items.
void addItem(Item* item)- Adds an item to the character’s inventory. Use of a smart pointer here instead is also acceptable.
void removeItem(Item* item)-Removes an item from the inventory.
void dropItem(Item* item); -Drop item from character’s inventory into character’s current location. Use of a smart pointer here instead is also acceptable.
Location* getLocation() const- Retrieves the current location of the character.
bool moveTo(Location* newLocation)-Moves the character to a new location.
void setSkill(int sk)-Sets the character’s skill rating.
int getSkill() const- Gets the character’s skill rating.
void setHitpoints( int hp)-Sets the character’s hit points.
int getHitpoints ( const- Gets the character’s hit points.
void setName(const std: string &newName)- Sets the name of the character.
std: string getName() const-Retrieves the name of the character.
void setArmour(int ar)- Sets the character’s armour value.
int getArmour() const-Gets the character’s armour value.
void takeHit( int hit)- Reduces the character’s hitpoints by the specified value.
std: string getInventory()- Returns a string displaying the character’s inventory.
Monster Class
The Monster class should be derived from Character. Monsters don’t move around the map. Monsters do have a feature called a swansong which is some text that is displayed when the monster dies. For example “The vampire lets out a final scream”. They also have a bounty value, which is the number added to the player’s score if they defeat the monster. Monsters also have a Power rating. They do not use weapons(although they may carry a weapon), and rely on their Power rating when inflicting damage(see Combat section).
std: string getSwansong ( const- Retrieves the swansong of the monster.
void setSwansong const std: string &newSwansong)-Sets the monster’s swansong.
int getBounty() const- Gets the monster’s bounty value.
void setBounty (int bounty)- Sets the monster’s bounty value.
void setPower( int pw)- Sets the monster’s power.
int getPower() const-Retrieves the monster’s power.

Boss Class
The Boss class should be derived from Monster.
The Boss will also hold the Eldritch Ring, which is the item that must be collected to win the game.
Player Class
The Player class should also be derived from Character. The Player class should have member variables that represent the player’s score, and the current location. You decide on the appropriate member variable types.
The class should have the following member functions:
void setScore(int s)-set the player’s score int getScore() const- get the player’s score
void setLocation(Location* loc)-set the player’s location.
Location* getLocation() const-get the player’s location.
void collectItems(Location* loc)-collect all items in the current location.
bool moveTo(const std: string &direction)- attempt to move the character in the specified direction. Returns true if the character has moved, otherwise returns false.
std: string drinkPotions()- Drink the potions in the inventory. Returns a string explaining the effect on the player (increased hp)
std: string combat()-Engage in combat with any monsters in the player’s location. Returns a string revealing the result of the fight.
Item Class
The Item class represents in-game objects that the player can interact with. It should store the following data:
The name of the item.
It should have the following member functions:
void setName( const std: string &newName)-Sets the name of the item.
std: string getName() const- Retrieves the name of the item.
Potion Class
The Pot ion class should be derived from Item. It should store the following data:
The healing strength of the potion.
Accessible through the following member functions:
void setStrength(int hp)- Sets the potion’s strength.
int getStrength() const- Retrieves the potion’s strength.
Weapon Class
The Weapon class should be derived from Item. It should store the following data:
The attack power of the weapon.
Accessible through the following member functions:
void setPower(int ap)-Sets the weapon’s power.
int getPower() const- Retrieves the weapon’s power.

Treasure Class
The Treasure class should be derived from Item. It should store the following data:
The value of the treasure.
Accessible through the following member functions:
void setValue(int val)-Setsthe treasure’s value.
int getValue() const -Retrieves the treasure’s value.
Location Class
A Locat ion object represents a place within the game. It should store the following data:
The name of the location.
A description of the location.
Some container of items available at this location.
The available exits leading to other Location objects.
These attributes should be accessible through the following member functions:
void setName(const std::string &newName)-Sets the name ofthe location.
std::string getName() const-Retrieves the name of the location.
setDescription(const std::string &newDesc)-Sets the description ofthe location.
std::string getDescription() const - Retrieves the description ofthelocation.
void addExit(const std::string &direction, Location* loc) -Createsanexit (N, S, E, or W) leading to another Locat ion object.
std::string showExits() const - Displays alist of available exits to the player (e.g. “Exits: NORTH, EAST, SOUTH”)
void addMonster(Monster* monster)-Places a specific monster at this location. Use ofa smart pointer here instead is also acceptable.
void delMonster(Monster* monster) - Removes a monster from this location. Use ofa smart pointer here instead is also acceptable.
void addItem (Item* item) - Places a specific item at this location. Use of a smart pointer here instead is also acceptable.

File Structure
The File Structure should be according to good C++ practice, with declarations in the h files and implementations in the cpp files. However for simple one or two line functions, those implementations can be kept in the h file, allowing the compiler to inline them and reduce function call overhead. Files are:
AdventureGame.cpp- Contains the main routine and sets up the game.
Gameworld.h Gameworld.cpp- Defines the Gameworld class, which holds the game world and state.
Character.h Character.cpp- Defines the base Character class
Monster.h/ Monster.cpp- Defines the Monster class derived from Character
Boss.h/Boss.cpp-Defines the Boss class derived from Monster
Player.h Player.cpp-Defines the Player class derived from Character, including score and movement methods.
Item.h Item.cpp- Defines the Item class
Potion.h/ Potion.cpp- Defines the Potion class derived from Item
Weapon.h/Weapon.cpp-Defines the Weapon class derived from Item
Treasure.h/Treasure.cpp-Defines the Treasure class derived from Item
Location.h/ Location.cpp- Defines the Location class

Task 2- Build the game map
Build the game from the gameworld’s loadWorld() member function, by creating location objects and linking them together using the objects’ exits member variable. Create 17 location objects that are linked to each other according to the map and list shown. Consider using a STL container to hold the game map.
You can change the descriptions if you want, but keep the location names and the connections to other locations.
ID Name Description Exits
19 The Central Nexus An ancient crossroads where time and space intertwine. WEST→1, NORTH→2, EAST→3
1 The Great Abercromby Gates Massive stone gates carved with arcane runes. EAST→19
2 The Guildhall of Scholars A grand hall where traders, scribes, and mysterious figures gather. SOUTH→19,
NORTH→5,
EAST→13,
WEST→15
5 The Thompson Observatory A domed tower where the stars reveal glimpses of fate. SOUTH→2,
NORTH→30,
EAST→31
30 The Scholar’s Ascent A winding staircase that tests the mind as much as the body. SOUTH→5,
WEST→29
29 The Fenwick Rift A tear in reality… EAST→30,
SOUTH→32
32 The Final Gateway A portal leading to the realm beyond. NORTH→29,
31 The Octagon Spire A mystical tower containing knowledge beyond mortal comprehension. NORTH→20,
WEST→5
20 The Victoria Spire A towering spire with a celestial beacon at its peak. SOUTH→31
13 The Chatham Archives Endless rows of scrolls, each documenting powerful relics lost to time. WEST→2
15 The Sidney Vault A labyrinth of books and stone where scholars vanished centuries ago. EAST→2
3 The Forbidden Harold Temple Ancient tomes whisper secrets from their dusty shelves. WEST→19,
NORTH→6,
EAST→14,
SOUTH→9
6 The Holt Enclave A ruined amphitheater where echoes of past lectures still resonate. SOUTH→3,
EAST→26
14 The Mountford Keep A towering fortress where ancient warriors once trained. SOUTH→7,
NORTH→26,
WEST→3
9 The Rendall Arena The echoes of battle cries ring through the ruined walls. NORTH→3,
WEST→7
7 The Reilly Battlegrounds A coliseum of stone and steel, where warriors train and champions rise. NORTH→14,
EAST→9
26 The Guilded Forge A legendary forge where artifacts of immense power were once crafted. SOUTH→14,
WEST→6

After building the game, create the player object and set the player’s current location to Location 19, The Central Nexus-that will be the start location of the game.
Give the player a skill level of 6, armour 0, hitpoints 50. Give the player a name. Create a game loop in the main() function.
At this stage the game loop should simply get a command from the player, and then describe the location.

Task 3- Room Navigation
Modify the game loop so that it now tells the player where they are (use the location’s getName () and getDescription()), and what exits are available (N, S, E or W)- use the location’s showExits ()
If the player types a direction (N, S, Eor W,orNorth, South, East, West,orn, s, e, w), the game should work out if an exit exists in that direction, and if it does, the player’s location should change to that location.
If an exit does not exist, the game should tell the player this, and the player remains at the current location.
Modify the game loop to check if the game has ended (using the gameworld’s isGameOver( )). By the end of this task the player should be able to navigate around the game, and quit the game if necessary.
‘Quit’ should use the gameworld’s setGameOver () which the gameloop should detect and end the game.

Task 4-Adding Monsters
In the gameworld’s loadWorld function, Use the Location’s method addMonster() to add monsters to locations.
Arrange the monsters in the game as in the table below, with the given stats.
Also add a’swansong’ and ‘description’ to each monster -suggestions are in the table but feel free to change these.

Class Name Skill Location HP Power Armour Items Description Swansong
Monster Raider 3 6 30 10 5 Red Healing Potion, Diamond A swift and ruthless attacker. The final blow before falling.
Monster Warrior 4 5 40 12 8 Ancient Scroll, Gold Crown A stalwart defender of ancient traditions. Dies honourably in battle.
Monster Brute 2 29 50 15 10 Leather Armour A formidable opponent with crushing strength. Falls with a feafening roar.
Monster Troll 2 29 60 18 12 Great Axe An ancient creature lurking beneath the shadows. Its final roar shakes the earth.
Monster Bandit 4 2 45 20 7 Iron Sword, Silver Key A cunning thief with a taste for blood. Slumps quietly after a fatal misstep.
Monster Wraith 2 30 35 8 4 Mystic Amulet An ethereal entity from beyond the grave. Fades into the mist with a haunting whisper.
Monster Knight 5 31 50 18 12 Plate Armour, Great Axe A noble warrior sworn to protect his honour. Falls with dignity in his final charge.
Monster Sprite 1 9 25 10 3 Gold Coin, Blue Healing Potion, Gemstone A mischievous and elusive fae creature. Disappears with a final burst of light.

Task 6-Items/Inventory
Change the game loop so that it announces what items are in the location, if any. This information should be obtainable from the player’s current location.
If the user types collect, all of the items in the location should be collected by the user.
If the user types inv or inventory they should see a list of all their items, in the three groups (Potions, Treasures, Weapons). Sort the lists alphabetically.
If the user types drink, all the healing potions in the user’s inventory should be deleted, and their healing strength points should be added to the player’s HitPoints.
Armour reduces the effect of damage inflicted on the character. All Character objects should have the ability to use armour, so it should be implemented at the Character (parent class) level. All armour items should be listed to the user when they type inv or inventory. By the end of this task the user should be able to collect all items from rooms, drink the healing potions, and list the items in the inventory.
Make sure that items listed in the monster table above exist in the game, but feel free to add whatever additional items and their properties as you wish to the game locations, or use the ones I have suggested below (the bold items are the ones specified in the monster table above):

Armour Name Location or Holder Armour Protection
Leather Armour Brute 5
Plate Armour Knight 20
Steel Shield Mountford Keep (Location 14) 10

Potion Name Location or Holder Potion Strength
Red Healing Potion Raider 40
Blue Healing Potion Sprite 50
Green Healing Potion Central Nexus (Location 19) 30
Ultimate Healing Final Gateway (Location 32) 200

Treasure Name Location or Holder Treasure Value
Diamond Raider 100
Gold Crown Warrior 150
Gold Coin Sprite 50
Gemstone Sprite 75
Silver Coin Great Abercromby Gates (Location 1) 25
Scholar’s Medallionn Guildhall of Scholars (Location 2) 50
Ruby Gemstone Sidney Vault (Location 15) 70
Celestial Orb Octagon Spire (Location 31) 150
Silver Key Bandit 20
Ancient Scroll Warrior 30
Mystic Amulet Wraith 40
Eldritch Ring Boss 200

Weapon Name Location or Holder Weapon Power
Great Axe Troll 15
Iron Sword Banndit 12
Great Axe Knight 15
Rusty Sword Central Nexus (Location 19) 5
Ceremonial Dagger Forbidden Harold Temple (Location 3) 8
Knight’s Sword Mountford Keep (Location 14) 12
Gladiator’s Spear Rendall Arena (Location 9) 10
Battle Axe Reilly Battlegrounds (Location 7) 14
Master’s Hammer Guilded Forge (Location 26) 18
Enchanted Staff Octagon Spire (Location 31) 15

Task 7-Combat
In this task, you will implement the combat system for the game. When the player types fight, the game should initiate combat with one of the monsters (or enemies) in the player’s current location.
Create a function called rollDice that returns a random integer between 1 and 6(inclusive).This function simulates the roll of a six-sided die.
Add a member function called combat to the Player class. This function will manage the entire combat sequence between the player and an enemy.
Combat is conducted in rounds. In each round, both the player and the monster perform an attack roll, and the highest total wins the round. The details are as follows:
Player: The player’s attack total is calculated by taking the player’s base Skill of 6, adding the Power value of the currently equipped weapon, and then adding the result of rollDice() (simulate a 2-12 total roll if you roll two dice).
Monster: The monster’s attack total is calculated by taking its Skill value and adding the result of rollDice()(again, assume two dice for a range of 2-12).
The combat round is won by the combatant with the highest total attack value. If both totals are equal, the round is repeated until there is a clear winner.
For a monster: Damage inflicted is based solely on the monster’s Power score. (Use rollDice() if you want to introduce variability.)
For a player: Damage inflicted is the sum of the weapon’s Power value and a base value of 6. If the player is unarmed, they should inflict a fixed 1 HP of damage.
After the raw damage is determined, subtract the target’s ARMOUR value (taking into account any armour effects)to get the final damage.
The combat round ends when one side wins the attack, and the winning combatant inflicts damage on the opponent. After the damage is applied, both combatants’ hitpoints are updated and displayed to the player.
Rounds continue until either the player or the enemy’s hitpoints reach 0.
Additional Combat Rules and Behaviour

  1. Both Monsterand Playerhave a hitpoint (HP)value and a skill value. When a character’s HP reaches 0, that character is defeated.
  2. After each combat round, output the current hitpoints of both combatants to the user.
  3. If there is more than one monster in the room, only one monster is engaged in combat when the user types fight. The monsters should be ordered by hitpoints (strongest first), so that the player fights the monster with the highest HP before engaging others.
  4. Add a member function takeHit to the Characterclass that decreases the character’s hitpoints by the damage received.
  5. If a monster is defeated:
    o The monster should drop its items in the current location.
    o Its"Swansong" text should be output.
    o The monster is then removed from the game, and its bounty value is added to the player’s score.
  6. If the player is defeated:
    o Display the player’s final score and end the game.
  7. Damage cannot be less than 1.
    Example Combat Scenario
    Player: Base SKILL =6; Equipped with a Dagger(POWER 2)- Total SKILL=8; ARMOUR=0. Troll: Base SKILL =9; POWER =6; ARMOUR=3.

Combat begins:
Round 1:
-Player rolls a total of 11(e.g. 5+6)- Total attack =8+11=19.
-Troll rolls a total of 8(e.g. 4+4)- Total attack =9+8=17.
-The player wins the round and hits the Troll.
-Damage calculation for the player: For example, the dagger might inflict 1-2 damage; if a roll of 2 is obtained, then damage =2.
-The Troll’s damage is reduced by any ARMOUR it is carrying (its ARMOUR value is 3, which might reduce the damage by 3). The Troll takes 3 points of damage.
Use this scenario as a reference for implementing your combat function. Ensure that all aspects of the combat process (rolling, attack comparisons, damage calculations, armour effects, and updating hitpoints)are handled correctly.

Task 8 - The Boss
Create a new Boss character with a name and description of your choice.
The boss is a separate class to Monster so that it can have extra functionality if necessary, although we will not implement that for this assignment.
Add the boss to the game, in the Victoria Spire (location 20).
Give the Boss the Eldritch Ring.
Modify the game loop so that when the player collects the Eldritch Ring (dropped when the boss is defeated), the game ends.

W.e,C.h’a’t : help-assignment

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值