Class: Gemwarrior::Monster

Inherits:
Creature show all
Defined in:
lib/gemwarrior/entities/monster.rb

Constant Summary collapse

INVENTORY_ITEMS_DEFAULT =
[Herb.new]

Instance Attribute Summary collapse

Attributes inherited from Creature

#atk_hi, #atk_lo, #defense, #dexterity, #face, #hands, #hp_cur, #hp_max, #level, #mood, #rox, #xp

Attributes inherited from Entity

#description, #name

Instance Method Summary collapse

Methods inherited from Entity

#status

Constructor Details

#initializeMonster

Returns a new instance of Monster.



13
14
15
16
17
18
19
# File 'lib/gemwarrior/entities/monster.rb', line 13

def initialize
  if [true, false].sample
    self.inventory = Inventory.new([INVENTORY_ITEMS_DEFAULT[rand(0..INVENTORY_ITEMS_DEFAULT.length-1)]])
  else
    self.inventory = Inventory.new
  end
end

Instance Attribute Details

#battlecryObject

Returns the value of attribute battlecry.



11
12
13
# File 'lib/gemwarrior/entities/monster.rb', line 11

def battlecry
  @battlecry
end

#inventoryObject

Returns the value of attribute inventory.



11
12
13
# File 'lib/gemwarrior/entities/monster.rb', line 11

def inventory
  @inventory
end

#is_bossObject

Returns the value of attribute is_boss.



11
12
13
# File 'lib/gemwarrior/entities/monster.rb', line 11

def is_boss
  @is_boss
end

Instance Method Details

#describeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gemwarrior/entities/monster.rb', line 21

def describe
  status_text =  name.upcase.ljust(13).colorize(:green)
  status_text << "#{description}\n".colorize(:white)
  if is_boss
    status_text << '(BOSS)'.ljust(13).colorize(:yellow)
  else
    status_text << ''.ljust(13)
  end
  status_text << "LEVEL: #{level.to_s.rjust(2)}, ".colorize(:white)
  status_text << "HP: #{hp_cur.to_s.rjust(3)}/#{hp_max.to_s.rjust(3)} ".colorize(:white)
  status_text << "ATK: #{atk_lo.to_s.rjust(2)}-#{atk_hi.to_s.rjust(2)} ".colorize(:white)
  status_text << "DEF: #{defense.to_s.rjust(2)} ".colorize(:white)
  status_text << "DEX: #{dexterity.to_s.rjust(2)} ".colorize(:white)
  status_text << "ROX: #{rox.to_s.rjust(3)} ".colorize(:white)
  status_text << "XP: #{xp.to_s.rjust(3)} ".colorize(:white)
  status_text << "\n".ljust(14)
  status_text << "FACE: #{face} ".colorize(:white)
  status_text << "HANDS: #{hands} ".colorize(:white)
  status_text << "MOOD: #{mood} ".colorize(:white)
  status_text << "INV: #{inventory.list_contents}".colorize(:white)
  status_text << "\n"
end