Problem 2: RPG Maker (300pts)
In this problem, you will implement a simplified turn-based RPG (Role-Playing Game) system to practice object-oriented programming concepts. In this game, your will first defeat the five evil TAs one by one, getting level and equipment upgrades along the way, before finally facing off against the mighty Boss in an epic showdown.
You will implement the following class hierarchy:
Buff Equipment ├── Weapon └── Armor Character ├── Player └── Enemy ├── TA └── Bosswhere
Buffrepresents temporary stat modifications. Each buff has a duration (number of turns), and during that time it can increase or decrease a character's attack and/or defense stats.Equipmentrepresents items that characters can equip to enhance their stats. There are two types of equipments: weapons that increase attack and armor that increases defense.Characteris the base class for all characters, withPlayerandEnemysubclassesPlayerhas leveling, equipment, and inventory systems. Players can gain experience and gold from defeating enemies. After gaining enough experience, they level up, increasing their stats and can get a full heal.Enemycan gain buffs during combat. There are two types of enemies:TAandBoss.During combat:
- Characters have HP (health points), attack, and defense stats
- Players can perform:
- Basic Attack: Deal damage equal to attack stat
- Magic Attack: Deal 1.5x damage but gain "Exhaustion" debuff (-5 ATK, -3 DEF for 2 turns)
- Use Potion: Restore 50 HP (limited supply)
- Apply Buff: Temporarily increase stats
You will implement this system across three sub-problems:
- Problem 2.1: Implement
Buff,Equipment,Weapon, andArmorclasses- Problem 2.2: Implement the
Characterbase class with combat mechanics- Problem 2.3: Implement
Player,Enemy,TA, andBossclasses with specific behaviorsAfter completing all parts, you can start the game by running the provided
game.pyscript!
在本问题中,您将实现一个简化的回合制 RPG(角色扮演游戏)系统,以练习面向对象编程的概念。 在这个游戏中,您将首先逐一击败五个邪恶的助教,在此过程中获得等级和装备升级,最后在史诗般的对决中迎战强大的 Boss。
您将实现以下类层次结构:
Buff
Equipment
├── Weapon
└── Armor
Character
├── Player
└── Enemy
├── TA
└── Boss
其中
Buff代表临时的属性修改。 每个 Buff 都有一个持续时间(回合数),在此期间它可以增加或减少角色的攻击和/或防御属性。Equipment代表角色可以装备以增强其属性的物品。有两种类型的装备:增加攻击的武器(Weapon)和增加防御的护甲(Armor)。Character是所有角色的基类,具有Player和Enemy子类Player具有升级、装备和物品栏系统。玩家可以通过击败敌人获得经验和金钱。获得足够的经验后,他们会升级,增加他们的属性并可以获得完全治疗。Enemy可以在战斗中获得 Buff。有两种类型的敌人:助教(TA)和 Boss。
在战斗中:
- 角色具有 HP(生命值)、攻击和防御属性
- 玩家可以执行:
- 普通攻击(Basic Attack):造成等同于攻击属性的伤害
- 魔法攻击(Magic Attack):造成 1.5 倍伤害,但获得“精疲力尽”debuff(-5 攻击,-3 防御,持续 2 回合)
- 使用药水(Use Potion):恢复 50 HP(供应有限)
- 施加 Buff(Apply Buff):暂时增加属性
您将通过三个子问题实现该系统:
- 问题 2.1:实现
Buff、Equipment、Weapon和Armor类 - 问题 2.2:实现具有战斗机制的
Character基类 - 问题 2.3:实现具有特定行为的
Player、Enemy、TA和Boss类
完成所有部分后,您可以通过运行提供的 game.py 脚本开始游戏!
python game.py