Dungeon Adventure Game is a text-based adventure game where the player explores a dungeon filled with rooms, items, and creatures. The player can move between rooms, interact with objects, and engage in battles with enemies.
Survive the dungeon by battling creatures, collecting powerful items, and navigating through interconnected rooms. Manage your inventory, plan your moves, and defeat all enemies to progress.
The game accepts the following commands:
move <R/L/U/D/B>: Move right (R), left (L), up (U), down (D), or back to the previous room (B).look: Observe the current room to see its description, items, and creatures.inventory: View your inventory and equipped items.pickup: Pick up an item in the room (if available).equip <1/2>: Equip an item from your inventory (slot 1 or 2).attack: Attack the creature in the room (if present).save <file>: Save the current game state to a file.load <file>: Load a previously saved game state from a file.exit: Exit the game.
- Start in the entrance room with basic stats and no items equipped.
- Move to adjacent rooms using commands like
move R. - Encounter a creature and attack it using
attack. - Collect items using
pickupand manage your inventory withequip. - Save progress with
saveand reload it later withload.
The game is divided into several modular components for clarity and reusability:
Defines the core structures used in the game:
Item: Represents weapons and utility objects with attributes likename,power,durability, and whether it is a weapon.Creature: Represents enemies with attributes likename,life,power, and adefinitionthat describes the creature.Room: Represents a dungeon room containing a description, an optional item, and an optional creature.
Implements the main functionality for interacting with the game:
moveCharacter: Allows the player to navigate between connected rooms.attack: Enables combat with creatures in the room.pickup: Allows the player to collect items.inventory: Displays the player's current inventory and equipped item.equipItem: Equips an item from the inventory.
Handles saving and loading the game state:
saveCommand: Logs player commands to a file for potential replay or restoration.loadGame: Reads commands from a file and replays them usingloadParseCommand.
Facilitates user interaction with the game:
parseCommand: Processes player inputs and executes corresponding actions.look: Provides a detailed description of the current room.
Manages memory allocation and deallocation:
freeRoom: Releases memory allocated for a room and its contents.resetLogFile: Clears the log file when a new game starts or the player dies.
-
Room Navigation
- Rooms are represented as a grid where the player can move in four cardinal directions or back to the previous room.
- Each room can optionally contain an item and/or a creature.
-
Combat System
- The player can attack creatures using their
powerattribute, enhanced by equipped items. - Creatures retaliate, reducing the player's life.
- If the player's equipped item loses all durability, it breaks and must be replaced.
- The player can attack creatures using their
-
Inventory Management
- The player has two inventory slots and one equipped item slot.
- Items can be picked up from rooms and managed through inventory commands.
-
Game State Management
- All commands are logged to a file (
logfile.txt) for persistence. - The game state can be restored by replaying logged commands from the file.
- All commands are logged to a file (