This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def initialize | |
@health = 0 | |
end | |
def play_turn(warrior) | |
if warrior.feel.empty? | |
enemies_around = false | |
warrior.look.each do |space| | |
space.captive? ? enemies_around = false : enemies_around = space.enemy? # Don't attack if there's a captive in the way |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
@units = warrior.listen | |
@enemies = @units.select { |unit| unit.enemy? } | |
@captives = @units.select { |unit| unit.captive? } | |
@hurry_captives = @captives.select { |captive| captive.ticking? } | |
[@hurry_captives, @enemies, @captives].each do |units| | |
if not units.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
warrior.walk! | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
warrior.feel.empty? ? warrior.walk! : warrior.attack! | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
if warrior.feel.empty? | |
warrior.health < 20 ? warrior.rest! : warrior.walk! | |
else | |
warrior.attack! | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
@health = 0 if not @health | |
if warrior.feel.empty? | |
(warrior.health < 20 and not taking_damage? warrior) ? warrior.rest! : warrior.walk! | |
else | |
warrior.attack! | |
end | |
@health = warrior.health |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
@health = 0 if not @health | |
if warrior.feel.empty? | |
(warrior.health < 20 and not taking_damage? warrior) ? warrior.rest! : warrior.walk! | |
else | |
warrior.feel.captive? ? warrior.rescue! : warrior.attack! | |
end | |
@health = warrior.health |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def play_turn(warrior) | |
@health = 0 if not @health | |
@direction = :forward if not @direction | |
@direction = :forward if @direction == :backward and warrior.feel(@direction).wall? | |
if warrior.feel(@direction).empty? | |
if warrior.health < 20 and not taking_damage? warrior | |
warrior.rest! | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def initialize | |
@health = 0 | |
end | |
def play_turn(warrior) | |
if warrior.feel.empty? | |
if warrior.health < 20 and not taking_damage? warrior | |
warrior.rest! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def initialize | |
@health = 0 | |
end | |
def play_turn(warrior) | |
if warrior.feel.empty? | |
if warrior.health < 20 and not taking_damage? warrior | |
warrior.rest! |
OlderNewer