Class: MWO::Weapon

Inherits:
Object
  • Object
show all
Extended by:
Utils
Defined in:
lib/mwo/weapon.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

fetch, to_symbol

Constructor Details

#initialize(args = {}) ⇒ Weapon

Returns a new instance of Weapon.



19
20
21
22
23
# File 'lib/mwo/weapon.rb', line 19

def initialize args = {}
  args.each do |k,v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
end

Instance Attribute Details

#ammo_per_shotObject

Returns the value of attribute ammo_per_shot.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def ammo_per_shot
  @ammo_per_shot
end

#ammo_typeObject

Returns the value of attribute ammo_type.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def ammo_type
  @ammo_type
end

#artemis_ammo_typeObject

Returns the value of attribute artemis_ammo_type.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def artemis_ammo_type
  @artemis_ammo_type
end

#categoryObject

Returns the value of attribute category.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def category
  @category
end

#clanObject

Returns the value of attribute clan.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def clan
  @clan
end

#coneoffireObject

Returns the value of attribute coneoffire.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def coneoffire
  @coneoffire
end

#cooldownObject

Returns the value of attribute cooldown.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def cooldown
  @cooldown
end

#crit_chance_increaseObject

Returns the value of attribute crit_chance_increase.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def crit_chance_increase
  @crit_chance_increase
end

#crit_dam_multObject

Returns the value of attribute crit_dam_mult.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def crit_dam_mult
  @crit_dam_mult
end

#damageObject

Returns the value of attribute damage.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def damage
  @damage
end

#durationObject

Returns the value of attribute duration.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def duration
  @duration
end

#empObject

Returns the value of attribute emp.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def emp
  @emp
end

#explode_chanceObject

Returns the value of attribute explode_chance.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def explode_chance
  @explode_chance
end

#falloffexponentObject

Returns the value of attribute falloffexponent.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def falloffexponent
  @falloffexponent
end

#formation_sizeObject

Returns the value of attribute formation_size.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def formation_size
  @formation_size
end

#formation_size_per_indexObject

Returns the value of attribute formation_size_per_index.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def formation_size_per_index
  @formation_size_per_index
end

#formation_speedObject

Returns the value of attribute formation_speed.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def formation_speed
  @formation_speed
end

#gravityObject

Returns the value of attribute gravity.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def gravity
  @gravity
end

#groupedlocallyObject

Returns the value of attribute groupedlocally.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def groupedlocally
  @groupedlocally
end

#healthObject

Returns the value of attribute health.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def health
  @health
end

#heatObject

Returns the value of attribute heat.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def heat
  @heat
end

#heat_penalty_idObject

Returns the value of attribute heat_penalty_id.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def heat_penalty_id
  @heat_penalty_id
end

#heatdamageObject

Returns the value of attribute heatdamage.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def heatdamage
  @heatdamage
end

#heatinctimeObject

Returns the value of attribute heatinctime.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def heatinctime
  @heatinctime
end

#heatpenaltyObject

Returns the value of attribute heatpenalty.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def heatpenalty
  @heatpenalty
end

#hitpointsObject

Returns the value of attribute hitpoints.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def hitpoints
  @hitpoints
end

#impulseObject

Returns the value of attribute impulse.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def impulse
  @impulse
end

#inner_sphereObject

Returns the value of attribute inner_sphere.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def inner_sphere
  @inner_sphere
end

#internal_explosion_dmgObject

Returns the value of attribute internal_explosion_dmg.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def internal_explosion_dmg
  @internal_explosion_dmg
end

#jammed_timeObject

Returns the value of attribute jammed_time.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def jammed_time
  @jammed_time
end

#jamming_chanceObject

Returns the value of attribute jamming_chance.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def jamming_chance
  @jamming_chance
end

#lifetimeObject

Returns the value of attribute lifetime.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def lifetime
  @lifetime
end

#long_rangeObject

Returns the value of attribute long_range.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def long_range
  @long_range
end

#max_depthObject

Returns the value of attribute max_depth.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def max_depth
  @max_depth
end

#max_rangeObject

Returns the value of attribute max_range.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def max_range
  @max_range
end

#maxheightObject

Returns the value of attribute maxheight.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def maxheight
  @maxheight
end

#min_rangeObject

Returns the value of attribute min_range.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def min_range
  @min_range
end

#minheatpenaltylevelObject

Returns the value of attribute minheatpenaltylevel.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def minheatpenaltylevel
  @minheatpenaltylevel
end

#minheightObject

Returns the value of attribute minheight.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def minheight
  @minheight
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def name
  @name
end

#needlockObject

Returns the value of attribute needlock.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def needlock
  @needlock
end

#null_rangeObject

Returns the value of attribute null_range.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def null_range
  @null_range
end

#num_firingObject

Returns the value of attribute num_firing.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def num_firing
  @num_firing
end

#num_per_shotObject

Returns the value of attribute num_per_shot.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def num_per_shot
  @num_per_shot
end

#peakdistObject

Returns the value of attribute peakdist.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def peakdist
  @peakdist
end

#peaktimeObject

Returns the value of attribute peaktime.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def peaktime
  @peaktime
end

#projectileclassObject

Returns the value of attribute projectileclass.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def projectileclass
  @projectileclass
end

#radiusObject

Returns the value of attribute radius.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def radius
  @radius
end

#rofObject

Returns the value of attribute rof.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def rof
  @rof
end

#shots_during_cooldownObject

Returns the value of attribute shots_during_cooldown.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def shots_during_cooldown
  @shots_during_cooldown
end

#slotsObject

Returns the value of attribute slots.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def slots
  @slots
end

#speedObject

Returns the value of attribute speed.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def speed
  @speed
end

#splash_percentObject

Returns the value of attribute splash_percent.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def splash_percent
  @splash_percent
end

#spreadObject

Returns the value of attribute spread.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def spread
  @spread
end

#tagObject

Returns the value of attribute tag.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def tag
  @tag
end

#tag_decayObject

Returns the value of attribute tag_decay.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def tag_decay
  @tag_decay
end

#tag_durationObject

Returns the value of attribute tag_duration.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def tag_duration
  @tag_duration
end

#tag_spread_factorObject

Returns the value of attribute tag_spread_factor.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def tag_spread_factor
  @tag_spread_factor
end

#tonsObject

Returns the value of attribute tons.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def tons
  @tons
end

#trackingstrengthObject

Returns the value of attribute trackingstrength.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def trackingstrength
  @trackingstrength
end

#trgheatinctimeObject

Returns the value of attribute trgheatinctime.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def trgheatinctime
  @trgheatinctime
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def type
  @type
end

#use_tagObject

Returns the value of attribute use_tag.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def use_tag
  @use_tag
end

#uselockObject

Returns the value of attribute uselock.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def uselock
  @uselock
end

#vis_rangeObject

Returns the value of attribute vis_range.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def vis_range
  @vis_range
end

#volleydelayObject

Returns the value of attribute volleydelay.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def volleydelay
  @volleydelay
end

#volleysizeObject

Returns the value of attribute volleysize.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def volleysize
  @volleysize
end

#weapon_idObject

Returns the value of attribute weapon_id.



3
4
5
# File 'lib/mwo/weapon.rb', line 3

def weapon_id
  @weapon_id
end

Class Method Details

.all(overrides: {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mwo/weapon.rb', line 30

def self.all(overrides: {})
  weapons = []

  all_raw.each do |weapon_id, attrs|
    if attrs["category"] == "weapon"

      weapon = {weapon_id: weapon_id.to_i,
                name: attrs["name"],
                category: attrs["category"]
      }

      if attrs["factions"]
        weapon[:clan] = attrs["factions"]["Clan"]
        weapon[:inner_sphere] = attrs["factions"]["InnerSphere"]
      end

      attrs["stats"].each do |k,v|
        weapon[to_symbol(k)] = v
      end

      weapons << new(weapon)
    end

  end

  return weapons.extend MWO::CollectionUtils

end

.all_raw(overrides: {}) ⇒ Object



25
26
27
28
# File 'lib/mwo/weapon.rb', line 25

def self.all_raw(overrides: {})
  client = MWO::Client.new(overrides: {})
  raw = fetch(client.items_url)
end

.ballisticObject



63
64
65
# File 'lib/mwo/weapon.rb', line 63

def self.ballistic
  all.filter({type: 'Ballistic'})
end

.clanObject



75
76
77
# File 'lib/mwo/weapon.rb', line 75

def self.clan
  all.filter({clan: true})
end

.energyObject



59
60
61
# File 'lib/mwo/weapon.rb', line 59

def self.energy
  all.filter({type: 'Energy'})
end

.inner_sphereObject



71
72
73
# File 'lib/mwo/weapon.rb', line 71

def self.inner_sphere
  all.filter({inner_sphere: true})
end

.missileObject



67
68
69
# File 'lib/mwo/weapon.rb', line 67

def self.missile
  all.filter({type: 'Missile'})
end