Last active
December 20, 2015 09:40
-
-
Save ryan-scott-dev/6109905 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) | |
@direction = :forward if @direction.nil? | |
if warrior.look(@direction)[1].empty? and warrior.health == @health or @health.nil? | |
warrior.walk! | |
elsif warrior.look(@direction)[1].empty? and warrior.health < @health | |
if warrior.look(@direction)[1].enemy? | |
warrior.shoot! | |
end | |
elsif warrior.feel(@direction).enemy? | |
warrior.attack! | |
elsif warrior.look(@direction)[1].enemy? | |
warrior.shoot! | |
elsif warrior.feel(@direction).captive? | |
warrior.rescue!(@direction) | |
elsif warrior.feel(@direction).wall? | |
warrior.pivot! | |
end | |
@health = warrior.health | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment