Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
RubyWarrior - https://www.bloc.io/ruby-warrior/#/ を攻略した時のソース
class Player
def play_turn(warrior)
warrior.walk!
end
end
class Player
def play_turn(warrior)
if warrior.feel.enemy? then
warrior.attack!
else
warrior.walk!
end
end
end
class Player
def initialize
@health = 20
@rest_flag = false
end
def play_turn(warrior)
if warrior.health < 10 or @rest_flag
@rest_flag = true
if warrior.feel.enemy? or @health > warrior.health then
warrior.walk! :backward
else
warrior.rest!
end
if warrior.health == 20 then
@rest_flag = false
else
@rest_flag = true
end
@health = warrior.health
elsif warrior.feel.enemy? then
warrior.attack!
else
warrior.walk!
end
end
end
# ruby_warriior_lv3.rb と同じ
class Player
def initialize
@health = 20
@rest_flag = false
end
def play_turn(warrior)
if warrior.health < 10 or @rest_flag
@rest_flag = true
if warrior.feel.enemy? or @health > warrior.health then
warrior.walk! :backward
else
warrior.rest!
end
if warrior.health == 20 then
@rest_flag = false
else
@rest_flag = true
end
@health = warrior.health
elsif warrior.feel.enemy? then
warrior.attack!
else
warrior.walk!
end
end
end
class Player
def initialize
@health = 20
@rest_flag = false
end
def play_turn(warrior)
if warrior.health < 10 or @rest_flag
@rest_flag = true
if warrior.feel.enemy? or @health > warrior.health then
warrior.walk! :backward
else
warrior.rest!
end
if warrior.health == 20 then
@rest_flag = false
else
@rest_flag = true
end
@health = warrior.health
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.feel.enemy? then
warrior.attack!
else
warrior.walk!
end
end
end
class Player
def initialize
@turn = 0
@health = 20
@movement = :forward
@rest_flag = false
end
def turn
@movement = @movement==:forward ? :backward : :forward
end
def play_turn(warrior)
@turn += 1
if @turn == 1 and !warrior.feel(:backward).wall? then
turn
elsif warrior.health < 10 or @rest_flag
@rest_flag = true
if warrior.feel.enemy? or @health > warrior.health then
turn
warrior.walk! @movement
turn
else
warrior.rest!
end
if warrior.health == 20 then
@rest_flag = false
else
@rest_flag = true
end
@health = warrior.health
elsif warrior.feel(@movement).wall?
turn
elsif warrior.feel(@movement).captive?
warrior.rescue! @movement
elsif warrior.feel(@movement).enemy? then
warrior.attack! @movement
else
warrior.walk! @movement
end
end
end
class Player
def initialize
@turn = 0
@health = 20
@rest_flag = false
end
def play_turn(warrior)
@turn += 1
if @turn == 1 and !warrior.feel(:backward).wall? then
warrior.pivot!
elsif warrior.health < 10 or @rest_flag
@rest_flag = true
if warrior.feel.enemy? or @health > warrior.health then
warrior.walk! :backward
else
warrior.rest!
end
if warrior.health == 20 then
@rest_flag = false
else
@rest_flag = true
end
@health = warrior.health
elsif warrior.feel.wall? then
warrior.pivot!
elsif warrior.feel.captive? then
warrior.rescue!
elsif warrior.feel.enemy? then
warrior.attack!
else
warrior.walk!
end
end
end
class Player
def initialize
@health = 20
@turn = 0
@rest_flag = false
end
def play_turn(warrior)
@turn += 1
if @turn == 1 and !warrior.feel(:backward).wall? then
warrior.pivot!
elsif warrior.health < 10 or @rest_flag
@rest_flag = true
if warrior.feel.enemy? or @health > warrior.health then
warrior.walk! :backward
else
warrior.rest!
end
if warrior.health == 20 then
@rest_flag = false
else
@rest_flag = true
end
@health = warrior.health!
elsif warrior.feel.wall?
warrior.pivot!
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.look[1].captive? or warrior.look[2].captive?
warrior.walk!
elsif warrior.look[1].enemy? or warrior.look[2].enemy?
warrior.shoot!
elsif warrior.feel.enemy?
warrior.atack!
else
warrior.walk!
end
end
end
class Player
def initialize
@health = 20
@turn = 0
@rest_flag = false
@can_clear = true
end
def play_turn(warrior)
@turn += 1
if @turn == 1 and !warrior.feel(:backward).wall? then
warrior.pivot!
elsif warrior.health < 10 or @rest_flag
@rest_flag = true
if warrior.feel.enemy? or @health > warrior.health then
warrior.walk! :backward
else
warrior.rest!
end
if warrior.health == 20 then
@rest_flag = false
else
@rest_flag = true
end
@health = warrior.health
elsif warrior.feel.stairs? and @can_clear then
@can_clear = false
warrior.pivot!
elsif warrior.feel.wall?
warrior.pivot!
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.look[1].captive? or warrior.look[2].captive?
warrior.walk!
elsif warrior.look[1].enemy? or warrior.look[2].enemy?
warrior.shoot!
elsif warrior.feel.enemy?
warrior.atack!
else
warrior.walk!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment