Module: BloodChalice::ArtificialIntelligence
Instance Method Summary collapse
Instance Method Details
#bited ⇒ Object
24 25 26 27 28 29 |
# File 'lib/bloodchalice/ai.rb', line 24 def bited() @blood -= 1 if @blood <= 0 die() end end |
#die ⇒ Object
19 20 21 22 |
# File 'lib/bloodchalice/ai.rb', line 19 def die() @game.remove_npc(self) @map.set_tile @position, Tile.new(@position, ' ') end |
#hit(damage) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/bloodchalice/ai.rb', line 31 def hit(damage) @life -= damage if @life <= 0 die() end end |
#reacts_to(tile) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/bloodchalice/ai.rb', line 11 def reacts_to(tile) if tile.wall? return :stop elsif tile.empty? return :move end end |
#think ⇒ Object
7 8 9 |
# File 'lib/bloodchalice/ai.rb', line 7 def think() self.speed.times { move(Movable::DIRECTIONS.keys.sample) } end |