Class: Lich::Gemstone::Gift

Inherits:
Object
  • Object
show all
Defined in:
lib/gemstone/gift.rb,
lib/games.rb

Overview

Gift class for tracking gift box status

Class Method Summary collapse

Class Method Details

.endedInteger

Ends the gift by setting the pulse count to 360.

Examples:

Gift.ended
# => Ends the gift by setting pulse count to 360

Returns:

  • (Integer)

    the pulse count set to 360



570
571
572
# File 'lib/games.rb', line 570

def Gift.ended
  @@pulse_count = 360
end

.init_giftTime, Integer

Returns the start time of the gift and the pulse count.

Examples:

Gift.init_gift
# => Initializes the gift with the current time and pulse count set to 0

Returns:

  • (Time)

    the time when the gift was started

  • (Integer)

    the current pulse count, initialized to 0



16
17
18
19
# File 'lib/gemstone/gift.rb', line 16

def init_gift
  @gift_start = Time.now
  @pulse_count = 0
end

.load_serialized=(array) ⇒ void

This method returns an undefined value.

Loads the serialized state of the gift from an array.

Examples:

Gift.load_serialized = [Time.now, 5]
# => Loads the serialized state into the gift

Parameters:

  • array (Array)

    an array containing the gift start time and pulse count



562
563
564
565
# File 'lib/games.rb', line 562

def Gift.load_serialized=(array)
  @@gift_start = array[0]
  @@pulse_count = array[1].to_i
end

.pulseInteger

Increments the pulse count by one.

Examples:

Gift.pulse
# => Increments the pulse count by 1

Returns:

  • (Integer)

    the updated pulse count after increment



533
534
535
# File 'lib/games.rb', line 533

def Gift.pulse
  @@pulse_count += 1
end

.remainingFloat

Calculates the remaining time in seconds based on the pulse count.

Examples:

Gift.remaining
# => Returns the remaining time in seconds based on pulse count

Returns:

  • (Float)

    the remaining time in seconds



540
541
542
# File 'lib/games.rb', line 540

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

.restarts_onTime

Calculates the time when the gift will restart.

Examples:

Gift.restarts_on
# => Returns the time when the gift will restart

Returns:

  • (Time)

    the time when the gift restarts



547
548
549
# File 'lib/games.rb', line 547

def Gift.restarts_on
  @@gift_start + 594000
end

.serializeArray

Serializes the current state of the gift.

Examples:

Gift.serialize
# => Returns an array with the gift start time and pulse count

Returns:

  • (Array)

    an array containing the gift start time and pulse count



554
555
556
# File 'lib/games.rb', line 554

def Gift.serialize
  [@@gift_start, @@pulse_count]
end

.startedTime, Integer

Starts the gift timer and resets the pulse count.

Examples:

Gift.started
# => Starts the gift timer and resets pulse count

Returns:

  • (Time)

    the time when the gift was started

  • (Integer)

    the pulse count, reset to 0



525
526
527
528
# File 'lib/games.rb', line 525

def Gift.started
  @@gift_start = Time.now
  @@pulse_count = 0
end

.stopwatchnil

Placeholder for a stopwatch method.

Examples:

Gift.stopwatch
# => Returns nil

Returns:

  • (nil)

    always returns nil



577
578
579
# File 'lib/games.rb', line 577

def Gift.stopwatch
  nil
end