Class: Petli::Pet

Inherits:
Object
  • Object
show all
Extended by:
Tatty::DB::Attributes
Includes:
Animation, Death, Food, Happy, Watch
Defined in:
lib/petli/pet.rb,
lib/petli/pet/food.rb,
lib/petli/pet/death.rb,
lib/petli/pet/happy.rb,
lib/petli/pet/animation.rb

Defined Under Namespace

Modules: Animation, Death, Food, Happy

Constant Summary

Constants included from Happy

Happy::MOOD_SCALE

Constants included from Food

Food::POOP_LOCATIONS

Instance Method Summary collapse

Methods included from Tatty::DB::Attributes

db_attr

Methods included from Happy

#lose, #play, #update_happiness, #win

Methods included from Food

#clean, #feed, #feed!, #update_hunger

Methods included from Death

#check_if_dead, #dead?

Methods included from Animation

#animation, #atlas, #avail_animations, #busy?, #celebrate, #embarass, #hatch, #light_switch, #react, #reset, #setup_animation, #sleeping?, #update_animation

Constructor Details

#initializePet

Returns a new instance of Pet.



15
16
17
18
# File 'lib/petli/pet.rb', line 15

def initialize
  super()
  setup_animation
end

Instance Method Details

#displayObject



20
21
22
23
24
25
26
27
# File 'lib/petli/pet.rb', line 20

def display
  return animation.next if self.dead?
  update_hunger
  update_happiness
  check_if_dead
  update_animation
  animation.display
end

#lifetimeObject



29
30
31
# File 'lib/petli/pet.rb', line 29

def lifetime
  (self.died_at.nil? ? days_since(self.birth) : days_since(self.birth, self.died_at)).to_i
end