Closed Lykos closed 14 years ago
I have the same error after moving backward
Yes, that actually WAS the problem. I wrote "backwards" instead of "backward" and when I changed it, it worked.
So it was my fault and not really an issue.
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.
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.
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
Bombana attacks Sludge Sludge takes 5 damage, 7 health power left Sludge attacks Bombana Bombana takes 3 damage, 17 health power left
turn 2 -
|@s | | sS>|
Bombana attacks Sludge Sludge takes 5 damage, 2 health power left Sludge attacks Bombana Bombana takes 3 damage, 14 health power left
turn 3 -
|@s | | sS>|
Bombana attacks Sludge Sludge takes 5 damage, -3 health power left Sludge dies Bombana earns 12 points
turn 4 -
|@ | | sS>|
/var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/base.rb:16:in
offset': undefined method
map' for nil:NilClass (NoMethodError) from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/base.rb:20:inspace' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/feel.rb:9:in
perform' from (eval):2:infeel' from ./player.rb:25:in
in_peace?' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/turn.rb:30:inall?' from ./player.rb:25:in
each' from ./player.rb:25:inall?' from ./player.rb:25:in
in_peace?' from ./player.rb:7:inplay_turn' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/units/warrior.rb:12:in
play_turn' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/units/base.rb:72:inprepare_turn' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:50:in
play' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:50:ineach' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:50:in
play' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:46:intimes' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:46:in
play' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:72:inplay_current_level' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:63:in
play_normal_mode' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:23:instart' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/runner.rb:17:in
run' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/bin/rubywarrior:5 from /var/lib/gems/1.8/bin/rubywarrior:19:in `load' from /var/lib/gems/1.8/bin/rubywarrior:19