Human VS Orc

See the project's GitHub page: HumanVSOrc

Project Description and Goal

The "Human VS Orc" project is a C++ simulation that simulates a battle between two RPG units, a human and an orc. The goal is to design a modular architecture of RPG units, skills, bonus and items.

The primary goal of this project is to demonstrate modularity and a clean code architecture. The design allows for easy addition of new RPG classes, skills, and attributes.

Modularity

Clean code

Modular Skill System

The project defines a robust skill system designed around the Command Pattern enabling the dynamic creation of skills into distinct command objects. This architecture enhances flexibility and extensibility, allowing new skills to be seamlessly integrated into the system.

  Unit unit;
float fireball_damage = 15.0f;
int cooldown = 3;
float success_rate = 0.95f;
unit.AddSkill(std::make_unique<Skill>("Fireball",
  cooldown, success_rate,
  std::make_unique<DealDamageCommand>(fireball_damage))
);

      Unit unit;
float base_value = 10.0f;
std::string display_name = "Dexterity";
unit.AddAttribute(
    AttributeType::DEXTERITY,
    display_name, base_value
);

// Add a dexterity bonus
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>(
  10.0f, 0.05f,
  AttributeType::DEXTERITY,
  Bonus::Type::RAW
);
// gain +10 dexterity and +5% dexterity
unit.AddBonus(bonus);

    

Modular Attribute System...

RPG attributes are easy to add, remove or modify and manage at runtime on RPG units. It provides flexibility for various character types and gameplay mechanics.

... with easy Bonus System

Bonuses can be added and removed at runtime. They can be added by skills, items, or any other game mechanics.

Flexible Status Effects

Using again the Command Pattern, status effects are easy to add, remove or modify and manage at runtime on RPG units. It provides flexibility for various character types, skills and gameplay mechanics.

Status effects can be applied by skills, items, or any other game mechanics. They can trigger actions on application, on update, and on removal. This way, a Bleeding Strike skill can easily be implemented.

// Skill that applies a bleeding status effect
int duration = 3;
int cooldown = 5;
float success_rate = 0.60f;
float dmg_per_tick = 2;
float instant_damage = 10;

std::unique_ptr<Command> on_tick_command = std::make_unique<DealDamageCommand>(dmg_per_tick);
std::unique_ptr<Command> on_apply_command = std::make_unique<DealDamageCommand>(instant_damage);
// Create the status effect
std::unique_ptr<StatusEffect> bleeding_status = std::make_unique<StatusEffect>(
  "Bleeding",
  duration,
  StatusEffectType::BLEEDING
);
bleeding_status->SetOnUpdateCommand(std::move(on_tick_command))
  .SetOnApplyCommand(std::move(on_apply_command));

// Create the skill which applies the status effect
std::unique_ptr<Skill> skill = std::make_unique<Skill>(
  "Bleeding Strike",
  cooldown,
  success_rate,
  std::make_unique<ApplyStatusEffectCommand>(
    std::move(bleeding_status)
  )
);

Unit caster, target;
skill.Execute(caster, target);
// target takes 10 damage instantly and 2 damage per tick for 3 turns


Return to project list