#C10364. Dungeon Crawler: Character Inventory Management
Dungeon Crawler: Character Inventory Management
Dungeon Crawler: Character Inventory Management
In this problem, you are tasked with simulating a character's inventory in a dungeon crawler game. The character has the attributes \(health\), \(mana\), \(strength\), and \(defense\). Initially, the character starts with \(health = 100\), \(mana = 40\), \(strength = 20\), and \(defense = 30\) with an empty inventory that can hold at most 5 items.
You will be given a series of commands to manipulate the inventory. The valid commands are:
- ADD <item>: Add an item to the inventory. The valid items are
HP
,MP
,SE
, andDE
. - REMOVE <item>: Remove an item from the inventory.
- USE <item>: Use an item from the inventory to apply its effect. The effects are defined as follows:
Using \(HP\) increases \(health\) by 50, \(MP\) increases \(mana\) by 30, \(SE\) increases \(strength\) by 10, and \(DE\) increases \(defense\) by 15.
If an operation fails (e.g., attempting to add an invalid item, adding an item when the inventory is full, or removing/using an item that is not present), immediately print the corresponding error message.
After processing all commands, output the final attribute values and the inventory content.
inputFormat
The first line contains an integer \(T\), representing the number of commands. Each of the next \(T\) lines contains a command in one of the following formats:
ADD <item>
REMOVE <item>
USE <item>
outputFormat
For each command that fails, print the error message on a separate line immediately when it occurs. After processing all commands, print two lines:
- First line: Four integers separated by a space representing \(health\), \(mana\), \(strength\), and \(defense\) respectively.
- Second line: The items in the inventory separated by a space. If the inventory is empty, print
Empty
.
6
ADD HP
ADD MP
ADD SE
ADD DE
ADD HP
ADD MP
Inventory is full. Cannot add more items.
100 40 20 30
HP MP SE DE HP
</p>