ryanb / ruby-warrior

Game written in Ruby for learning Ruby.
MIT License
3.83k stars 838 forks source link

Bug after dying slug in level 2 #25

Closed Lykos closed 14 years ago

Lykos commented 14 years ago

Hi, I got a problem in level 2. Here is my player:

class player
DIRECTIONS = [:forward, :right, :left, :backwards] MAX_HEALTH = 20

def play_turn(warrior) @warrior = warrior
if injured? and in_peace? warrior.rest!
elsif in_peace? warrior.walk!(warrior.direction_of_stairs)
else warrior.attack!(enemy_direction) end end

def enemy_direction DIRECTIONS.first { |d| @warrior.feel(d).enemy? } end

def injured? @warrior.health < MAX_HEALTH end

def in_peace? DIRECTIONS.all? { |d| not @warrior.feel(d).enemy? } end
end

And here is my whole output, I hope that helps:

Welcome to Ruby Warrior
Starting Level 2

gregorym commented 14 years ago

I have the same error after moving backward

Lykos commented 14 years ago

Yes, that actually WAS the problem. I wrote "backwards" instead of "backward" and when I changed it, it worked.

Lykos commented 14 years ago

So it was my fault and not really an issue.

agrimm commented 14 years ago

It's not really a bug, but providing an informative error message for an invalid direction would be useful. I've also used invalid directions.

ryanb commented 14 years ago

Good point, providing a more useful error message when given a wrong direction is a good idea. I'll make a separate ticket for that.