Class: Lich::Gemstone::DefenseAttributes

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

Overview

Combat defense properties for a creature template.

Wraps all defensive metrics: armor skill group (ASG), armor graduate defense (AGD) against melee/ranged/bolt, per-circle threat defense (TD) values, undodgeable defense factor (UDF), immunities, defensive spells, and special defenses. Defense values can be parsed ranges (e.g., "10..15" becomes 10..15) or direct integers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ void

Initializes DefenseAttributes from template data.

Sets ASG directly, parses defense values (melee/ranged/bolt/udf and all threat defense fields) via #parse_td to handle ranges and strings, and defaults array fields (immunities, spells, abilities, special defenses) to [].

Parameters:

  • data (Hash) —

    defense data with keys like :asg, :melee, :bar_td, etc.



985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# File 'documented/gemstone/creature.rb', line 985

def initialize(data)
  @asg = data[:asg]
  @melee = parse_td(data[:melee])
  @ranged = parse_td(data[:ranged])
  @bolt = parse_td(data[:bolt])
  @udf = parse_td(data[:udf])

  %i[bar_td cle_td emp_td pal_td ran_td sor_td wiz_td mje_td mne_td mjs_td mns_td mnm_td].each do |key|
    instance_variable_set("@#{key}", parse_td(data[key]))
  end

  @immunities = data[:immunities] || []
  @defensive_spells = data[:defensive_spells] || []
  @defensive_abilities = data[:defensive_abilities] || []
  @special_defenses = data[:special_defenses] || []
end

Instance Attribute Details

#asg ⇒ Object

Returns the value of attribute asg.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def asg
  @asg
end

#bar_td ⇒ Object

Returns the value of attribute bar_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def bar_td
  @bar_td
end

#bolt ⇒ Object

Returns the value of attribute bolt.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def bolt
  @bolt
end

#cle_td ⇒ Object

Returns the value of attribute cle_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def cle_td
  @cle_td
end

#defensive_abilities ⇒ Object

Returns the value of attribute defensive_abilities.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def defensive_abilities
  @defensive_abilities
end

#defensive_spells ⇒ Object

Returns the value of attribute defensive_spells.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def defensive_spells
  @defensive_spells
end

#emp_td ⇒ Object

Returns the value of attribute emp_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def emp_td
  @emp_td
end

#immunities ⇒ Object

Returns the value of attribute immunities.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def immunities
  @immunities
end

#melee ⇒ Object

Returns the value of attribute melee.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def melee
  @melee
end

#mje_td ⇒ Object

Returns the value of attribute mje_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def mje_td
  @mje_td
end

#mjs_td ⇒ Object

Returns the value of attribute mjs_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def mjs_td
  @mjs_td
end

#mne_td ⇒ Object

Returns the value of attribute mne_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def mne_td
  @mne_td
end

#mnm_td ⇒ Object

Returns the value of attribute mnm_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def mnm_td
  @mnm_td
end

#mns_td ⇒ Object

Returns the value of attribute mns_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def mns_td
  @mns_td
end

#pal_td ⇒ Object

Returns the value of attribute pal_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def pal_td
  @pal_td
end

#ran_td ⇒ Object

Returns the value of attribute ran_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def ran_td
  @ran_td
end

#ranged ⇒ Object

Returns the value of attribute ranged.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def ranged
  @ranged
end

#sor_td ⇒ Object

Returns the value of attribute sor_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def sor_td
  @sor_td
end

#special_defenses ⇒ Object

Returns the value of attribute special_defenses.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def special_defenses
  @special_defenses
end

#udf ⇒ Object

Returns the value of attribute udf.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def udf
  @udf
end

#wiz_td ⇒ Object

Returns the value of attribute wiz_td.



970
971
972
# File 'documented/gemstone/creature.rb', line 970

def wiz_td
  @wiz_td
end