Class: Elvarg::Skill

Inherits:
Object
  • Object
show all
Includes:
Stats
Defined in:
lib/skills/skill.rb

Constant Summary

Constants included from Stats

Elvarg::Stats::CLUES, Elvarg::Stats::COMBAT_SKILLS, Elvarg::Stats::MEMBER_SKILLS, Elvarg::Stats::MINIGAMES, Elvarg::Stats::SKILLS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, rank = -1,, level = 1, xp = 0, id = -1)) ⇒ Skill

Creates a new Skill object

Paramters:

[Symbol] symbol - The symbol of the skill, like :attack, :magic, :ranged
[Integer] rank - The user's rank. Default is -1
[Integer] level - The user's level in this skill. Default is 1
[Integer] xp - The user's experience in this skill. Default is 0
[Integer] id - The id of this skill, default is -1


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/skills/skill.rb', line 22

def initialize(symbol, rank = -1, level = 1, xp = 0, id = -1)
  @id = id
  @symbol = symbol
  @name = symbol.to_s.capitalize
  @rank = rank
  @level = level
  @level = 10 if level == 1 && symbol == :hitpoints
  @xp = xp
  @xp = 1154 if xp == 0 && symbol == :hitpoints
  @icon = "https://www.runescape.com/img/rsp777/hiscores/skill_icon_#{@name.downcase}1.gif"
end

Instance Attribute Details

#iconObject (readonly)

Returns the value of attribute icon.



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

def icon
  @icon
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/skills/skill.rb', line 5

def id
  @id
end

#levelObject (readonly)

Returns the value of attribute level.



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

def level
  @level
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/skills/skill.rb', line 7

def name
  @name
end

#rankObject (readonly)

Returns the value of attribute rank.



8
9
10
# File 'lib/skills/skill.rb', line 8

def rank
  @rank
end

#symbolObject (readonly)

Returns the value of attribute symbol.



6
7
8
# File 'lib/skills/skill.rb', line 6

def symbol
  @symbol
end

#xpObject (readonly)

Returns the value of attribute xp.



10
11
12
# File 'lib/skills/skill.rb', line 10

def xp
  @xp
end

Instance Method Details

#is_combat?Boolean

Determines if this Skill will affect a user’s combat level

Returns:

true - if this skill will affect combat level, false otherwise

Returns:

  • (Boolean)


55
56
57
# File 'lib/skills/skill.rb', line 55

def is_combat?
  Stats::COMBAT_SKILLS.include? @symbol
end

#is_free?Boolean

Determines if this Skill is a free to play skill The inverse of ‘is_member?`

Returns:

  • (Boolean)


46
47
48
# File 'lib/skills/skill.rb', line 46

def is_free?
  !is_member?
end

#is_member?Boolean

Determines if this Skill is a member’s only skill

Returns:

true - if this skill is member's only, false otherwise

Returns:

  • (Boolean)


39
40
41
# File 'lib/skills/skill.rb', line 39

def is_member?
  Stats::MEMBER_SKILLS.include? @symbol
end

#is_skiller_friendly?Boolean

Determines if this Skill is skiller friendly The inverse of ‘is_combat?`

Returns:

  • (Boolean)


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

def is_skiller_friendly?
  !combat?
end