Class: OldSchool::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/oldschool/player.rb

Overview

Represents a single player on OldSchool

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, mode = :default) ⇒ Player

Creates a new Player object

Creates a new player object with the specified username

Examples:

Create a new OldSchool Player

player = OldSchool::Player.new 'ruby'
player.mode #=> :default
player.username #=> "ruby"

Create a new Ironman Player

player = OldSchool::Player.new 'ruby', :ironman
player.mode #=> :ironman
player.username #=> "ruby"

Parameters:

  • username (String)

    the username of the Player

  • mode (Symbol) (defaults to: :default)

    the mode of the Player, such as :default, :ironman, :ultimate, :hardcore, :deadman etc.

See Also:



66
67
68
69
70
71
72
# File 'lib/oldschool/player.rb', line 66

def initialize(username, mode = :default)
  @username = username
  @mode = mode
  @csv = nil

  generate_hs_stats
end

Instance Attribute Details

#minigamesHash<Symbol, OldSchool::HiScores::Minigame> (readonly)

Returns a Hash containing all of the Player’s minigame information as it stands on the HiScores.

Examples:

Extract Minigame information from a Player

player = OldSchool::Player.new 'ruby'
player.minigames[:bh_hunter].score #=> 1_344
player.minigames[:bh_rogue].score #=> 900
player.minigames[:clue_all].rank #=> 10_333
player.minigames[:clue_elite].rank #=> 90_232
player.minigames #=> Hash of all Minigames

Returns:

See Also:



44
45
46
# File 'lib/oldschool/player.rb', line 44

def minigames
  @minigames
end

#modeSymbol (readonly)

Returns the mode of the Player.

Returns:

  • (Symbol)

    the mode of the Player



14
15
16
# File 'lib/oldschool/player.rb', line 14

def mode
  @mode
end

#skillsHash<Symbol, OldSchool::HiScores::Skill> (readonly)

Returns a Hash containing all of the Player’s skill information as it stands on the HiScores.

Examples:

Extract Skill information from a Player

player = OldSchool::Player.new 'ruby'
player.skills[:overall].level #=> 1232
player.skills[:hunter] #=> OldSchool::HiScores::Skill
player.skills[:hunter].level #=> 72
player.skills[:hunter].experience #=> 780_000
player.skills[:hunter].rank #=> 131_232
player.skills #=> Hash of all Skills

Returns:

  • (Hash<Symbol, OldSchool::HiScores::Skill>)

    a Hash containing all of the Player’s skill information as it stands on the HiScores

See Also:



31
32
33
# File 'lib/oldschool/player.rb', line 31

def skills
  @skills
end

#usernameString (readonly)

Returns the Player’s username.

Returns:

  • (String)

    the Player’s username



16
17
18
# File 'lib/oldschool/player.rb', line 16

def username
  @username
end

Instance Method Details

#free?true, false

Note:

This method is the inverse of #member?

Determines if this Player is a F2P Player

This method dermines that a Player is F2P if they do not have any experience in their member’s only skills.

Examples:

For a player with no experience in a member’s only skill

f2p = OldSchool::Player.new 'f2p'
f2p.free? #=> true

For a Player with experience in a member’s only skill

member = OldSchool::Player.new 'member'
member.free? #=> false

Returns:

  • (true)

    if this Player has no experience in any member only skill

  • (false)

    if this Player has experience in any member only skill

See Also:



120
121
122
# File 'lib/oldschool/player.rb', line 120

def free?
  !member?
end

#member?true, false

Note:

There is a certain level of inaccuracy using this method, since this method determines a Player is a member if they have experience in their member’s only skills.

Determines if this Player was/is a member

This method determines that a Player is a member if they have any experience in any of their member’s only skills. Some members, for example, do not have experience in any of their member’s only skills.

Examples:

For a Player with experience in a member’s only skill

member = OldSchool::Player.new 'member'
member.member? #=> true

For a Player with no experience in a member’s only skill

f2p_player = OldSchool::Player.new 'f2p guy'
f2p_player.member? #=> false

Returns:

  • (true)

    if this Player has experience in any member only skill

  • (false)

    if this Player has no experience in any member only skill



95
96
97
98
99
100
# File 'lib/oldschool/player.rb', line 95

def member?
  @skills.each do |_, skill|
    return true if skill.experience > 0 && skill.member?
  end
  false
end

#nonmember?Boolean

An alias for #free?

Returns:

  • (Boolean)

See Also:



127
128
129
# File 'lib/oldschool/player.rb', line 127

def nonmember?
  free?
end

#nonskiller?true, false

Note:

This is the inverse of #skiller?

Determines if this player is not a skiller

Examples:

For a level 3 skiller

skiller = OldSchool::Player.new 'skiller'
skiller.nonskiller? #=> false

For a Player who has > 1 in any combat skill

main = OldSchool::Player.new 'main'
main.nonskiller? #=> true

Returns:

  • (true)

    if the player is not classified as a skiller

  • (false)

    if the player is classified as a skiller

See Also:



172
173
174
# File 'lib/oldschool/player.rb', line 172

def nonskiller?
  !skiller?
end

#skiller?true, false

Determines if this Player is a skiller

This method determines that a Player is a skiller by ensuring that the player has no combat-oriented skills over the level of 1 (with the exception of 10 hitpoints).

Examples:

For a level 3 skiller

skiller = OldSchool::Player.new 'skiller'
skiller.skiller? #=> true

For a Player who has > 1 in any combat skill

main = OldSchool::Player.new 'main'
main.skiller? #=> false

Returns:

  • (true)

    if the player is classified as a skiller

  • (false)

    if the player is not classified as a skiller



147
148
149
150
151
152
153
154
155
# File 'lib/oldschool/player.rb', line 147

def skiller?
  skiller = true
  @skills.each do |_, skill|
    next if skill.symbol == :hitpoints && skill.level <= 10

    skiller = false if skill.combat? && skill.level > 1
  end
  skiller
end