Module: Petli::Pet::Happy
Constant Summary collapse
- MOOD_SCALE =
%i(angry annoyed normal happy great)
Instance Method Summary collapse
Methods included from Tatty::DB::Attributes
Instance Method Details
#lose ⇒ Object
29 30 31 |
# File 'lib/petli/pet/happy.rb', line 29 def lose # todo I dont really want it to become more unhappy if they lose end |
#play(game: :dice) ⇒ Object
20 21 22 23 |
# File 'lib/petli/pet/happy.rb', line 20 def play(game: :dice) self.last_play = Time.now react(:stand) end |
#update_happiness ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/petli/pet/happy.rb', line 11 def update_happiness for_hours_since(last_play) do |i| self.last_play = Time.now next if rand <= 0.3 self.happiness = [[1, self.happiness-1].max, self.health <= 3 ? 5 : 10].min end self.mood = MOOD_SCALE[((self.happiness.to_f/10.0)*(MOOD_SCALE.count - 1)).floor] end |
#win ⇒ Object
25 26 27 |
# File 'lib/petli/pet/happy.rb', line 25 def win self.happiness = [10, self.happiness+1].min end |