Exercise: Formatting Text

Let's go through what you’ve learned in this chapter.

We'll cover the following

This exercise is all about formatting text and understanding the control flow of combat systems.

Problem statement

You’ve implemented a combat system, in which monsters battle one another. You have the basics of combat working, but need to output some text to tell the player what’s going on. Extend attack to return one of the following:

  • "\<attacker name> hits \<victim name>, slaying it."
  • \<attacker name> hits \<victim name>.
  • \<attacker name> misses \<victim name>.

Don’t forget to include bracket_lib in your Cargo.toml file.

We encourage you to try solving it yourself before looking at the solution. Your starting combat system is:

Get hands-on with 1400+ tech skills courses.