Skip to content

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
      └── Boss

where

  • Buff represents 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.
  • Equipment represents items that characters can equip to enhance their stats. There are two types of equipments: weapons that increase attack and armor that increases defense.
  • Character is the base class for all characters, with Player and Enemy subclasses
  • Player has 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.
  • Enemy can gain buffs during combat. There are two types of enemies: TA and Boss.

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, and Armor classes
  • Problem 2.2: Implement the Character base class with combat mechanics
  • Problem 2.3: Implement Player, Enemy, TA, and Boss classes with specific behaviors

After completing all parts, you can start the game by running the provided game.py script!

在本问题中,您将实现一个简化的回合制 RPG(角色扮演游戏)系统,以练习面向对象编程的概念。 在这个游戏中,您将首先逐一击败五个邪恶的助教,在此过程中获得等级和装备升级,最后在史诗般的对决中迎战强大的 Boss

您将实现以下类层次结构:

Buff

Equipment
  ├── Weapon
  └── Armor

Character
  ├── Player
  └── Enemy
      ├── TA
      └── Boss

其中

  • Buff 代表临时的属性修改。 每个 Buff 都有一个持续时间(回合数),在此期间它可以增加或减少角色的攻击和/或防御属性。
  • Equipment 代表角色可以装备以增强其属性的物品。有两种类型的装备:增加攻击的武器Weapon)和增加防御的护甲Armor)。
  • Character 是所有角色的基类,具有 PlayerEnemy 子类
  • 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:实现 BuffEquipmentWeaponArmor
  • 问题 2.2:实现具有战斗机制的 Character 基类
  • 问题 2.3:实现具有特定行为的 PlayerEnemyTABoss

完成所有部分后,您可以通过运行提供的 game.py 脚本开始游戏!

python game.py