Class: Elvarg::Stats::Skill

Inherits:
Object
  • Object
show all
Defined in:
lib/stats/skill.rb

Overview

Represents a Skill in OldSchool RuneScape

Direct Known Subclasses

Hiscores::Skill

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, id = 0) ⇒ Skill

Creates a new Skill object.

Examples:

Create a Hunter Skill object

hunter = Elvarg::Stats::Skill.new(:hunter, 22)
hunter.level #=> 1

Create a Hitpoints Skill object

hitpoints = Elvarg::Stats::Skill.new(:hitpoints, 4)
hitpoints.level #=> 10

Create a Runecraft Skill, with no id will default to 0

runecraft = Elvarg::Stats::Skill.new(:runecraft)
runecraft.level #=> 1
runecraft.id #=> 0

Parameters:

  • symbol (Symbol)

    the symbol of this skill.

  • id (Integer) (defaults to: 0)

    the unique identifier of this skill, 1 is attack. (0).



36
37
38
39
40
41
42
# File 'lib/stats/skill.rb', line 36

def initialize(symbol, id = 0)
  @id = id
  @symbol = symbol
  @name = symbol.to_s.capitalize
  @icon = 'https://www.runescape.com/img/rsp777/' \
          "hiscores/skill_icon_#{@name.downcase}1.gif"
end

Instance Attribute Details

#iconObject (readonly)

The link to the ‘.gif` of the related Skill



9
10
11
# File 'lib/stats/skill.rb', line 9

def icon
  @icon
end

#idObject (readonly)

The unique id of this Skill



11
12
13
# File 'lib/stats/skill.rb', line 11

def id
  @id
end

#nameObject (readonly)

The human readable name of this Skill



13
14
15
# File 'lib/stats/skill.rb', line 13

def name
  @name
end

#symbolObject (readonly)

The symbol of this Skill



17
18
19
# File 'lib/stats/skill.rb', line 17

def symbol
  @symbol
end

Instance Method Details

#combat?true, false

Determines if this Skill will affect a player’s combat

Examples:

Attack will affect one’s combat level

Elvarg::Stats::Skill.new(:attack).combat? #=> true

Woodcutting will not affect one’s combat level

Elvarg::Stats::Skill.new(:woodcutting).combat? #=> false

Returns:

  • (true)

    if this Skill affects a player’s combat

  • (false)

    if this Skill does not affect a player’s combat



76
77
78
# File 'lib/stats/skill.rb', line 76

def combat?
  COMBAT_SKILLS.include? @symbol
end

#free?Boolean

Note:

This is the inverse of #member?

Determines if this Skill is a free-to-play skill.

Returns:

  • (Boolean)

See Also:



62
63
64
# File 'lib/stats/skill.rb', line 62

def free?
  !member?
end

#member?true, false

Determines if this Skill is a member’s only skill.

Examples:

Slayer is a member’s only skill.

Elvarg::Stats::Skill.new(:hunter).member? #=> true

Runecraft is a free-to-play skill.

Elvarg::Stats::Skill.new(:runecraft).member? #=> false

Returns:

  • (true)

    if this Skill is a member’s only skill.

  • (false)

    if this Skill is free-to-play.



53
54
55
# File 'lib/stats/skill.rb', line 53

def member?
  MEMBER_SKILLS.include? @symbol
end

#skiller_friendly?Boolean

Note:

This is the inverse of ‘combat?`

Determines if this Skill does not affect a player’s combat

Returns:

  • (Boolean)

See Also:



85
86
87
# File 'lib/stats/skill.rb', line 85

def skiller_friendly?
  !combat?
end