I’m sure this looks like shit

…but it got me pass Level 4 & 5!

class Player

  @health = true

  def play_turn(warrior)
  if warrior.feel.enemy?
    warrior.attack!
  elsif @health == false
    rest_up(warrior)
    if warrior.health >= 20
      @health = true
    end
  else
    if warrior.health < 8 
      rest_up(warrior)
    else
        warrior.walk!
    end #embedded if
  end #if
  end #play_turn method

  def rest_up(warrior)
      warrior.rest!
      @health = false
  end #rest_up

end #class
but seriously… play this game: Ruby Warrior
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s