Class: Elvarg::Hiscores::Player
- Inherits:
-
Object
- Object
- Elvarg::Hiscores::Player
- Includes:
- Elvarg::Hiscores, Stats
- Defined in:
- lib/hiscores/player.rb
Overview
Represents a single player on OldSchool Runescape
Constant Summary
Constants included from Elvarg::Hiscores
Constants included from Stats
Stats::CLUES, Stats::COMBAT_SKILLS, Stats::MEMBER_SKILLS, Stats::MINIGAMES, Stats::SKILLS
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#skills ⇒ Object
readonly
Returns the value of attribute skills.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(username, mode = :default) ⇒ Player
constructor
Creates a new Player object.
-
#is_free? ⇒ Boolean
The inverse of
is_member?. -
#is_member? ⇒ Boolean
Determines if this player is a member.
-
#is_skiller? ⇒ Boolean
Determines if this player is a skiller A user is a skiller when they do not have any combat skill (other than 10 hitpoints) greater than 1.
Methods included from Elvarg::Hiscores
Constructor Details
#initialize(username, mode = :default) ⇒ Player
Creates a new Player object
Parameters
- String
-
username- The user’s username
- Symbol
-
mode- The mode to search in. seeHiscores::MODES, defaults to:default
Examples
# Search through the default overall hiscores
player = Elvarg::Hiscores::Player.new 'ruby'
# Search through the ultimate ironman hiscores
player = Elvarg::Hiscores::Player.new('ruby', :ultimate)
28 29 30 31 32 33 34 |
# File 'lib/hiscores/player.rb', line 28 def initialize(username, mode = :default) @username = username @mode = mode @skills = {} extract(Hiscores.search_for(username, mode)) end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
11 12 13 |
# File 'lib/hiscores/player.rb', line 11 def mode @mode end |
#skills ⇒ Object (readonly)
Returns the value of attribute skills.
12 13 14 |
# File 'lib/hiscores/player.rb', line 12 def skills @skills end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
10 11 12 |
# File 'lib/hiscores/player.rb', line 10 def username @username end |
Instance Method Details
#is_free? ⇒ Boolean
The inverse of is_member?
60 61 62 |
# File 'lib/hiscores/player.rb', line 60 def is_free? !is_member? end |
#is_member? ⇒ Boolean
Determines if this player is a member
Details
This detects membership if the user has greater than 0 experience in any member’s only skill.
Returns
- true
-
if the player has experience in a member’s only skill, false otherwise
Examples
player = Elvarg::Hiscores::Player.new 'ruby'
player.is_member?
#=> true
53 54 55 56 |
# File 'lib/hiscores/player.rb', line 53 def is_member? @skills.each { |key, skill| return true if skill.xp > 0 && skill.is_member? } false end |
#is_skiller? ⇒ Boolean
Determines if this player is a skiller A user is a skiller when they do not have any combat skill (other than 10 hitpoints) greater than 1.
Returns
- true
-
if the player has 1 in all combat skills (and 10 hitpoints) false otherwise
Examples
player = Elvarg::Hiscores::Player.new 'ruby'
player.is_skiller?
#=> false
78 79 80 81 82 83 84 |
# File 'lib/hiscores/player.rb', line 78 def is_skiller? @skills.each { |key, skill| next if key == :hitpoints && skill.level <= 10 return false if skill.level > 1 && skill.is_combat? } true end |