Module: BloodChalice::ArtificialIntelligence

Included in:
Knight, Peasant, Zombie
Defined in:
lib/bloodchalice/ai.rb

Instance Method Summary collapse

Instance Method Details

#bitedObject



24
25
26
27
28
29
# File 'lib/bloodchalice/ai.rb', line 24

def bited()
  @blood -= 1
  if @blood <= 0
    die()
  end
end

#dieObject



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

#thinkObject



7
8
9
# File 'lib/bloodchalice/ai.rb', line 7

def think()
  self.speed.times { move(Movable::DIRECTIONS.keys.sample) }
end