Skip to content

Instantly share code, notes, and snippets.

@chiting
Last active December 24, 2015 15:19
Show Gist options
  • Save chiting/6819649 to your computer and use it in GitHub Desktop.
Save chiting/6819649 to your computer and use it in GitHub Desktop.
# It doesn't work anymore with the new version of https://www.bloc.io/ruby-warrior#/
class Player
def play_turn(warrior)
lol = warrior.instance_variable_get(:@senses)
me = lol[:health].instance_variable_get(:@unit)
me.send(:define_singleton_method, :attack_power, lambda { 10000 })
me.send(:define_singleton_method, :max_health, lambda { 10000000 })
if warrior.respond_to? :feel
space = warrior.feel
case
when space.enemy?
warrior.attack!
when space.captive?
warrior.rescue!
when space.wall?
warrior.pivot!
else
warrior.walk!
end
else
warrior.walk!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment