Class: Elvarg::Hiscores::Player
- Inherits:
-
Object
- Object
- Elvarg::Hiscores::Player
- Includes:
- Stats
- Defined in:
- lib/hiscores/player.rb
Overview
Represents a Player on the Hiscores
Constant Summary
Constants included from Stats
Stats::COMBAT_SKILLS, Stats::MEMBER_SKILLS, Stats::SKILLS
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
The Hiscore’s mode.
-
#skills ⇒ Object
readonly
A Hash of all Stats available in OldSchool Runescape’s Hiscores.
-
#username ⇒ Object
readonly
The Player’s username.
Instance Method Summary collapse
-
#free? ⇒ true, false
Determines if this Player is a free-to-play player.
-
#initialize(username, mode = :default) ⇒ Player
constructor
Creates a Player object.
-
#member? ⇒ true, false
Determines if this Player is/was a member at one point in time.
-
#skiller? ⇒ true, false
Determines if this Player is a skiller (combat level 3).
Constructor Details
#initialize(username, mode = :default) ⇒ Player
Creates a Player object
34 35 36 37 38 39 40 |
# File 'lib/hiscores/player.rb', line 34 def initialize(username, mode = :default) @username = username @mode = mode @skills = {} parse_data(Hiscores.search_for(username, mode)) end |
Instance Attribute Details
#mode ⇒ Object (readonly)
The Hiscore’s mode. This can be :default, :ironman, :ultimate, etc.
16 17 18 |
# File 'lib/hiscores/player.rb', line 16 def mode @mode end |
#skills ⇒ Object (readonly)
A Hash of all Stats available in OldSchool Runescape’s Hiscores
18 19 20 |
# File 'lib/hiscores/player.rb', line 18 def skills @skills end |
#username ⇒ Object (readonly)
The Player’s username
12 13 14 |
# File 'lib/hiscores/player.rb', line 12 def username @username end |
Instance Method Details
#free? ⇒ true, false
This is the inverse of #member?
Determines if this Player is a free-to-play player.
70 71 72 |
# File 'lib/hiscores/player.rb', line 70 def free? !member? end |
#member? ⇒ true, false
This methods determines member status based on if the Player has trained any member skills.
Determines if this Player is/was a member at one point in time.
54 55 56 57 |
# File 'lib/hiscores/player.rb', line 54 def member? @skills.each { |_, skill| return true if skill.xp > 0 && skill.member? } false end |
#skiller? ⇒ true, false
Determines if this Player is a skiller (combat level 3).
If a Player has any combat level > 1 (with the exception of 10 hitpoints) that Player is classified as a Skiller.
86 87 88 89 90 91 92 |
# File 'lib/hiscores/player.rb', line 86 def skiller? @skills.each do |key, skill| next if key == :hitpoints && skill.level <= 10 return false if skill.level > 1 && skill.combat? end true end |