Class: Lich::Gemstone::Treasure

Inherits:
Object
  • Object
show all
Defined in:
documented/gemstone/creature.rb

Overview

Treasure drops available on a creature template.

Tracks currency (coins/gems), loot boxes, corpse harvest items (skin), and equipment by category (magic items, armaments, transmogs).

Examples:

treasure = Treasure.new(coins: true, gems: false, blunt_required: true)
treasure.has_coins? #=> true
treasure.to_h #=> {coins: true, gems: false, ...}

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ void

Initializes treasure configuration from a creature template data hash.

Merges provided data into defaults (all false/nil), allowing partial specs.

Parameters:

  • data (Hash) (defaults to: {}) —

    treasure attributes; unspecified keys retain defaults



864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'documented/gemstone/creature.rb', line 864

def initialize(data = {})
  @data = {
    coins: false,
    gems: false,
    boxes: false,
    skin: nil,
    magic_items: nil,
    other: nil,
    armaments: nil,
    transmogs: nil,
    blunt_required: false
  }.merge(data)
end

Instance Method Details

#blunt_required? ⇒ Boolean

Returns whether the creature must be killed with blunt damage for item drops.

Returns:

  • (Boolean)


905
# File 'documented/gemstone/creature.rb', line 905

def blunt_required? = !!@data[:blunt_required]

#has_armaments? ⇒ Boolean

Returns whether the creature carries armaments (weapons/armor).

Returns:

  • (Boolean)


897
898
899
900
# File 'documented/gemstone/creature.rb', line 897

def has_armaments? = !!(@data[:armaments] && !Array(@data[:armaments]).empty?)
# Returns whether the creature carries transmog items.
#
# @return [Boolean]

#has_boxes? ⇒ Boolean

Returns whether the creature drops loot boxes.

Returns:

  • (Boolean)


889
890
891
892
# File 'documented/gemstone/creature.rb', line 889

def has_boxes? = !!@data[:boxes]
# Returns whether the creature's corpse yields harvestable skin.
#
# @return [Boolean]

#has_coins? ⇒ Boolean

Returns whether the creature drops coins.

Returns:

  • (Boolean)


881
882
883
884
# File 'documented/gemstone/creature.rb', line 881

def has_coins? = !!@data[:coins]
# Returns whether the creature drops gems.
#
# @return [Boolean]

#has_gems? ⇒ Boolean

Returns whether the creature drops gems.

Returns:

  • (Boolean)


885
886
887
888
# File 'documented/gemstone/creature.rb', line 885

def has_gems? = !!@data[:gems]
# Returns whether the creature drops loot boxes.
#
# @return [Boolean]

#has_skin? ⇒ Boolean

Returns whether the creature's corpse yields harvestable skin.

Returns:

  • (Boolean)


893
894
895
896
# File 'documented/gemstone/creature.rb', line 893

def has_skin? = !!@data[:skin]
# Returns whether the creature carries armaments (weapons/armor).
#
# @return [Boolean]

#has_transmogs? ⇒ Boolean

Returns whether the creature carries transmog items.

Returns:

  • (Boolean)


901
902
903
904
# File 'documented/gemstone/creature.rb', line 901

def has_transmogs? = !!(@data[:transmogs] && !Array(@data[:transmogs]).empty?)
# Returns whether the creature must be killed with blunt damage for item drops.
#
# @return [Boolean]

#to_h ⇒ Hash

Returns the treasure configuration as a hash.

Returns:

  • (Hash) —

    the underlying treasure data



910
# File 'documented/gemstone/creature.rb', line 910

def to_h = @data