title: Changing a stored property in a class using protocol extensions
body: <p>I am in the process of learning protocol oriented programming, I have a model of an enemy and player where the player can damage the enemy like so:</p>
  
  <pre><code>protocol Targetable {
      func takeDamage(damage: Int)
  }
  
  protocol Shootable {
      func shoot(target: Targetable)
  }
  
  class Pistol: Shootable {
       func shoot(target: Targetable) {
           target.takeDamage(damage: 5)
       }
  }
  
  class Enemy: Targetable {
  
      var health = 100
  
      func takeDamage(damage: Int) {
          health = health - damage
          print("Current health is: \(health)")
      }
  }
  
  class Player {
  
      var gun: Shootable
  
      func shoot(target: Targetable) {
          gun.shoot(target: target)
      }
  
      init(gun: Shootable) {
          self.gun = gun
      }
  }
  
  let player = Player(gun: Pistol())
  let enemy = Enemy()
  
  player.shoot(target: enemy)
  </code></pre>
  
  <p>Now, I want to create a protocol extension on <code>Targetable</code> when whichever class conforms to <code>Targetable</code> will have a default implementation of <code>takeDamage</code> which reduces the <code>health</code> property. The problem is since <code>health</code> property is a stored value I can't access <code>health</code> in the protocol extension. </p>
  
  <p>I have tried doing this:</p>
  
  <pre><code>extension Targetable {
      func takeDamage(damage: Int, health: Int) {
  
      }
  }
  </code></pre>
  
  <p>But at the call site, it doesn't seem to make sense to pass <code>health</code> into the function that way.</p>
  
  <p>How should I go about implementing this? thanks!</p>