Class: Lich::Gemstone::Gift
- Inherits:
-
Object
- Object
- Lich::Gemstone::Gift
- Defined in:
- documented/gemstone/gift.rb
Overview
Represents a gift in the Lich game.
This class manages the timing and pulse count of a gift.
Class Attribute Summary collapse
-
.gift_start ⇒ Object
readonly
Returns the value of attribute gift_start.
-
.pulse_count ⇒ Object
readonly
Returns the value of attribute pulse_count.
Class Method Summary collapse
-
.ended ⇒ void
Marks the gift as ended by setting the pulse count to 360.
-
.init_gift ⇒ void
Initializes the gift's starting time and pulse count.
-
.load_serialized=(array) ⇒ void
Loads the gift's state from a serialized array.
-
.pulse ⇒ void
Increments the pulse count by one.
-
.remaining ⇒ Float
Calculates the remaining time for the gift in seconds.
-
.restarts_on ⇒ Time
Calculates the time when the gift will restart.
-
.serialize ⇒ Array
Serializes the gift's state into an array.
-
.started ⇒ void
Marks the start of the gift, resetting the pulse count.
-
.stopwatch ⇒ nil
Placeholder method for a stopwatch functionality.
Class Attribute Details
.gift_start ⇒ Object (readonly)
Returns the value of attribute gift_start.
11 12 13 |
# File 'documented/gemstone/gift.rb', line 11 def gift_start @gift_start end |
.pulse_count ⇒ Object (readonly)
Returns the value of attribute pulse_count.
11 12 13 |
# File 'documented/gemstone/gift.rb', line 11 def pulse_count @pulse_count end |
Class Method Details
.ended ⇒ void
This method returns an undefined value.
Marks the gift as ended by setting the pulse count to 360.
61 62 63 |
# File 'documented/gemstone/gift.rb', line 61 def ended @pulse_count = 360 end |
.init_gift ⇒ void
This method returns an undefined value.
Initializes the gift's starting time and pulse count.
15 16 17 18 |
# File 'documented/gemstone/gift.rb', line 15 def init_gift @gift_start = Time.now @pulse_count = 0 end |
.load_serialized=(array) ⇒ void
This method returns an undefined value.
Loads the gift's state from a serialized array.
54 55 56 57 |
# File 'documented/gemstone/gift.rb', line 54 def load_serialized=(array) @gift_start = array[0] @pulse_count = array[1].to_i end |
.pulse ⇒ void
This method returns an undefined value.
Increments the pulse count by one.
29 30 31 |
# File 'documented/gemstone/gift.rb', line 29 def pulse @pulse_count += 1 end |
.remaining ⇒ Float
Calculates the remaining time for the gift in seconds.
35 36 37 |
# File 'documented/gemstone/gift.rb', line 35 def remaining ([360 - @pulse_count, 0].max * 60).to_f end |
.restarts_on ⇒ Time
Calculates the time when the gift will restart.
41 42 43 |
# File 'documented/gemstone/gift.rb', line 41 def restarts_on @gift_start + 594000 end |
.serialize ⇒ Array
Serializes the gift's state into an array.
47 48 49 |
# File 'documented/gemstone/gift.rb', line 47 def serialize [@gift_start, @pulse_count] end |
.started ⇒ void
This method returns an undefined value.
Marks the start of the gift, resetting the pulse count.
22 23 24 25 |
# File 'documented/gemstone/gift.rb', line 22 def started @gift_start = Time.now @pulse_count = 0 end |
.stopwatch ⇒ nil
Placeholder method for a stopwatch functionality.
67 68 69 |
# File 'documented/gemstone/gift.rb', line 67 def stopwatch nil end |