Class: Lich::Gemstone::Gift

Inherits:
Object
  • Object
show all
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.

See Also:

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.gift_startObject (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_countObject (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

.endedvoid

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_giftvoid

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.

Parameters:

  • array (Array)

    an array containing the gift start time and pulse count



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

.pulsevoid

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

.remainingFloat

Calculates the remaining time for the gift in seconds.

Returns:

  • (Float)

    remaining time in seconds



35
36
37
# File 'documented/gemstone/gift.rb', line 35

def remaining
  ([360 - @pulse_count, 0].max * 60).to_f
end

.restarts_onTime

Calculates the time when the gift will restart.

Returns:

  • (Time)

    the restart time



41
42
43
# File 'documented/gemstone/gift.rb', line 41

def restarts_on
  @gift_start + 594000
end

.serializeArray

Serializes the gift's state into an array.

Returns:

  • (Array)

    an array containing the gift start time and pulse count



47
48
49
# File 'documented/gemstone/gift.rb', line 47

def serialize
  [@gift_start, @pulse_count]
end

.startedvoid

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

.stopwatchnil

Placeholder method for a stopwatch functionality.

Returns:

  • (nil)


67
68
69
# File 'documented/gemstone/gift.rb', line 67

def stopwatch
  nil
end