Class: OldSchool::Player
- Inherits:
-
Object
- Object
- OldSchool::Player
- Defined in:
- lib/oldschool/player.rb
Overview
Represents a single player on OldSchool
Instance Attribute Summary collapse
-
#minigames ⇒ Hash<Symbol, OldSchool::HiScores::Minigame>
readonly
A Hash containing all of the Player’s minigame information as it stands on the HiScores.
-
#mode ⇒ Symbol
readonly
The mode of the Player.
-
#skills ⇒ Hash<Symbol, OldSchool::HiScores::Skill>
readonly
A Hash containing all of the Player’s skill information as it stands on the HiScores.
-
#username ⇒ String
readonly
The Player’s username.
Instance Method Summary collapse
-
#free? ⇒ true, false
Determines if this Player is a F2P Player.
-
#initialize(username, mode = :default) ⇒ Player
constructor
Creates a new Player object.
-
#member? ⇒ true, false
Determines if this Player was/is a member.
-
#nonmember? ⇒ Boolean
An alias for #free?.
-
#nonskiller? ⇒ true, false
Determines if this player is not a skiller.
-
#skiller? ⇒ true, false
Determines if this Player is a skiller.
Constructor Details
#initialize(username, mode = :default) ⇒ Player
Creates a new Player object
Creates a new player object with the specified username
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
#minigames ⇒ Hash<Symbol, OldSchool::HiScores::Minigame> (readonly)
Returns a Hash containing all of the Player’s minigame information as it stands on the HiScores.
44 45 46 |
# File 'lib/oldschool/player.rb', line 44 def minigames @minigames end |
#mode ⇒ Symbol (readonly)
Returns the mode of the Player.
14 15 16 |
# File 'lib/oldschool/player.rb', line 14 def mode @mode end |
#skills ⇒ Hash<Symbol, OldSchool::HiScores::Skill> (readonly)
Returns a Hash containing all of the Player’s skill information as it stands on the HiScores.
31 32 33 |
# File 'lib/oldschool/player.rb', line 31 def skills @skills end |
#username ⇒ String (readonly)
Returns the Player’s username.
16 17 18 |
# File 'lib/oldschool/player.rb', line 16 def username @username end |
Instance Method Details
#free? ⇒ true, false
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.
120 121 122 |
# File 'lib/oldschool/player.rb', line 120 def free? !member? end |
#member? ⇒ true, false
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.
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?
127 128 129 |
# File 'lib/oldschool/player.rb', line 127 def nonmember? free? end |
#nonskiller? ⇒ true, false
This is the inverse of #skiller?
Determines if this player is not a skiller
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).
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 |