Ruby Warrior ist ein nostalgisches Code-Spiel

image.png

Site is here

Ruby Warrior

Regel

[^ 1]: Ich erhalte die Fehlermeldung "Es kann nur eine Aktion pro Runde ausgeführt werden."

Level 1

You see before yourself a long hallway with stairs at the end. There is nothing in the way.

class Player
  def play_turn(warrior)
    # cool code goes here
    warrior.walk!
  end
end

Höhepunkte dieses Levels: Glücklich gehen: Gehen:

Level 2

It is too dark to see anything, but you smell sludge nearby.

class Player
  def play_turn(warrior)
    if warrior.feel.empty?
      warrior.walk!
    else
      warrior.attack!
    end
  end
end

Höhepunkte dieses Levels: Erster Feind: dragon_face:

Level 3

The air feels thicker than before. There must be a horde of sludge.

class Player
  def play_turn(warrior)
    if warrior.feel.empty?
      if warrior.health < 15
        warrior.rest!
      else
        warrior.walk!
      end
    else
      warrior.attack!
    end
  end
end

Höhepunkte dieser Stufe: Ruhe, wenn du dich ausruhst: Schlafunterkunft:

Level 4

You can hear bow strings being stretched.

class Player
  def play_turn(warrior)
    @health = warrior.health unless @health
    if warrior.feel.empty?
      if @health <= warrior.health && warrior.health < 12
        warrior.rest!
      else
        warrior.walk!
      end
    else
      warrior.attack!
    end
    @health = warrior.health
  end
end

Highlights dieser Stufe: Management der körperlichen Verfassung: Bett:

Level 5

You hear cries for help. Captives must need rescuing.

class Player
  def play_turn(warrior)
    @health = warrior.health unless @health
    if warrior.feel.captive?
      warrior.rescue!
    elsif warrior.feel.empty?
      if @health <= warrior.health && warrior.health < 13
        warrior.rest!
      else
        warrior.walk!
      end
    else
      warrior.attack!
    end
    @health = warrior.health
  end
end

Höhepunkte dieses Levels: Feind oder Verbündeter? : sperren:

Level 6

The wall behind you feels a bit further away in this room. And you hear more cries for help.

class Player
  
  def initialize()
    @captive = true
  end
  
  def play_turn(warrior)
    @health = warrior.health unless @health
    if @captive
      if warrior.feel(:backward).captive?
        warrior.rescue!(:backward)
        @captive = false
      else
        warrior.walk!(:backward)
      end
    else
      if warrior.feel.empty?
        if @health > warrior.health && warrior.health < 10
          warrior.walk!(:backward)
        elsif @health <= warrior.health && warrior.health < 20
          warrior.rest!
        else
          warrior.walk!
        end
      else
        warrior.attack!
      end
      @health = warrior.health
    end
  end
  
end

Höhepunkte dieses Levels: Hits & Away: zurück:

Ich habe versucht, den Prozess zu ändern, indem ich markiert habe, ob es "captive" gibt und es nicht funktioniert hat, aber schließlich habe ich es in "initialize ()" geschrieben und es hat funktioniert.

Level 7

You feel a wall right in front of you and an opening behind you.

class Player
  def play_turn(warrior)  
    @health = warrior.health unless @health
    if warrior.feel.wall?
      warrior.pivot!
    else
      if warrior.feel.empty?
        if @health > warrior.health && warrior.health < 10
          warrior.walk!(:backward)
        elsif @health <= warrior.health && warrior.health < 20
          warrior.rest!
        else
          warrior.walk!
        end
      else
        warrior.attack!
      end
    end
    @health = warrior.health
  end  
end

Höhepunkte dieses Levels: Drehen Sie sich um und sehen Sie eines Tages die Landschaft

Level 8

You hear the mumbling of wizards. Beware of their deadly wands! Good thing you found a bow.

class Player
  
  def initialize()
    @captive = true
  end
  
  def play_turn(warrior)
    @health = warrior.health unless @health
    if @captive
      if warrior.feel.captive?
        warrior.rescue!
        @captive = false
      else
        warrior.walk!
      end
    else
      if warrior.look.any?{|s| s.enemy?}
        warrior.shoot!
      else
        warrior.walk!
      end
    end
  end  
  
end

Höhepunkte dieses Levels: Far Mongachi: bow_and_arrow:

Level 9

Time to hone your skills and apply all of the abilities that you have learned.

class Player

  def initialize()
    @left_captive = true
  end

  def play_turn(warrior)
    if @left_captive
      if warrior.look(:backward).any?{|s| s.enemy?}
        warrior.shoot!(:backward)
      elsif warrior.feel(:backward).captive?
        warrior.rescue!(:backward)
        @left_captive = false
      else
        warrior.walk!(:backward)
      end
    else
      if warrior.look.any?{|s| s.enemy?}
        warrior.shoot!
      elsif warrior.feel.captive?
        warrior.rescue!
      elsif warrior.feel.wall?
        warrior.pivot!
      else
        warrior.walk!
      end
    end
  end
  
end


Höhepunkte dieses Levels: Moonwalk: walk_tone2 :: bow_and_arrow:

――Wie man gewinnt, wenn man sich nur auf den Bogen verlässt! Ein Schütze, der einen Pfeil nach hinten schießt und niemals "Krieger. Ruhe!". Ich benutze nicht das, was ich gelernt habe. Ist es okay das zu tun?

Werde ein Rubinkrieger

image.png

Bitte lassen Sie mich wissen, wenn Sie einen besseren Code haben!

Recommended Posts

Ruby Warrior ist ein nostalgisches Code-Spiel
Code schreiben Ruby