Extending the Combat System

The current combat system is simple. An entity attacks another entity—and always inflicts one point of damage. This type of combat system doesn’t provide much of a difficulty curve as the adventurer progresses through the dungeon.

Let’s fix this problem by allowing different entities to inflict varying amounts of damage. Specifically, you’ll adjust the game so that the player can inflict more damage as they find better weapons, and some monsters cause more damage to the player thanks to bigger claws.

Damage from Weapons and Claws

Open spawner/template.rs, and add a base_damage field to the Template structure:

 #​[​derive​(Clone, Deserialize, Debug)]
 pub​ ​struct​ Template ...

Get Hands-on Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.