STEP 18: Let's add the code to give the computer a chance to cast a spell. This code should look familiar!

  • From , drag Call w/ Parameter into Variable to the bottom of the program.
  • Change my_var to damage, change my_function to cast_spell, and change my_parameter to computer.
  • From , drag Subtract Value to the next line. Change my_var to player_hp and 1 to damage.
  • Drag Update Display to the next line. Change my_display to player_display and my_var to player_hp.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)