Class: Gemwarrior::Creature

Inherits:
Entity
  • Object
show all
Defined in:
lib/gemwarrior/entities/creature.rb

Direct Known Subclasses

Cow, Goat, Monster, Person, Pig, Player

Instance Attribute Summary collapse

Attributes inherited from Entity

#consumable, #description, #display_shopping_cart, #equippable, #equipped, #name, #name_display, #number_of_uses, #takeable, #talkable, #useable, #useable_battle, #used, #used_again

Instance Method Summary collapse

Methods inherited from Entity

#puts

Constructor Details

#initializeCreature

Returns a new instance of Creature.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gemwarrior/entities/creature.rb', line 25

def initialize
  super

  self.name         = 'creature'
  self.name_display = Formatting::upstyle(name)
  self.description  = 'A creature.'
  self.face       = 'face-y'
  self.hands      = 'handsy'
  self.mood       = 'moody'
  self.level      = 1
  self.xp         = 0
  self.hp_cur     = 10
  self.hp_max     = 10
  self.atk_lo     = 1
  self.atk_hi     = 1
  self.defense    = 1
  self.dexterity  = 1
  self.inventory  = Inventory.new
  self.rox        = 0
  self.talkable   = true
  self.used       = false
end

Instance Attribute Details

#atk_hiObject

Returns the value of attribute atk_hi.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def atk_hi
  @atk_hi
end

#atk_loObject

Returns the value of attribute atk_lo.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def atk_lo
  @atk_lo
end

#defenseObject

Returns the value of attribute defense.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def defense
  @defense
end

#dexterityObject

Returns the value of attribute dexterity.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def dexterity
  @dexterity
end

#faceObject

Returns the value of attribute face.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def face
  @face
end

#handsObject

Returns the value of attribute hands.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def hands
  @hands
end

#hp_curObject

Returns the value of attribute hp_cur.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def hp_cur
  @hp_cur
end

#hp_maxObject

Returns the value of attribute hp_max.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def hp_max
  @hp_max
end

#inventoryObject

Returns the value of attribute inventory.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def inventory
  @inventory
end

#levelObject

Returns the value of attribute level.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def level
  @level
end

#moodObject

Returns the value of attribute mood.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def mood
  @mood
end

#roxObject

Returns the value of attribute rox.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def rox
  @rox
end

#speak(s, no_end_quote = false, no_line_feed = false) ⇒ Object (readonly)

Returns the value of attribute speak.



22
23
24
# File 'lib/gemwarrior/entities/creature.rb', line 22

def speak
  @speak
end

#use(world) ⇒ Object (readonly)

Returns the value of attribute use.



22
23
24
# File 'lib/gemwarrior/entities/creature.rb', line 22

def use
  @use
end

#xpObject

Returns the value of attribute xp.



8
9
10
# File 'lib/gemwarrior/entities/creature.rb', line 8

def xp
  @xp
end

Instance Method Details

#describeObject



52
53
54
55
56
57
# File 'lib/gemwarrior/entities/creature.rb', line 52

def describe
  desc_text = "#{description}".colorize(:white)
  desc_text << "\n"
  desc_text << "The creature has several distinguishing features, as well: face is #{face.colorize(:yellow)}, hands are #{hands.colorize(:yellow)}, and mood is, generally, #{mood.colorize(:yellow)}."
  desc_text
end

#describe_detailedObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/gemwarrior/entities/creature.rb', line 59

def describe_detailed
  desc_text =  "\"#{name_display}\"\n".colorize(:yellow)
  desc_text << "(#{name})\n".colorize(:green)
  desc_text << "#{description}\n".colorize(:white)
  desc_text << "FACE      : #{face}\n".colorize(:white)
  desc_text << "HANDS     : #{hands}\n".colorize(:white)
  desc_text << "MOOD      : #{mood}\n".colorize(:white)
  desc_text << "LEVEL     : #{level}\n".colorize(:white)
  desc_text << "XP        : #{xp}\n".colorize(:white)
  desc_text << "HP        : #{hp_cur}/#{hp_max}\n".colorize(:white)
  desc_text << "ATK_RANGE : #{atk_lo}-#{atk_hi}\n".colorize(:white)
  desc_text << "DEFENSE   : #{defense}\n".colorize(:white)
  desc_text << "DEXTERITY : #{dexterity}\n".colorize(:white)
  desc_text << "ROX       : #{rox}\n".colorize(:white)
  desc_text << "INVENTORY : #{inventory.contents}\n".colorize(:white)
  desc_text
end