Module: Lich::Common::Account
- Defined in:
- documented/common/account.rb
Overview
Namespace for account and character information retrieved from the game server.
Stores the account name, current character, subscription type, game code, and the list of available characters on the account.
Class Method Summary collapse
-
.character ⇒ String?
Returns the name of the currently logged-in character.
-
.character=(value) ⇒ String
Sets the name of the currently logged-in character.
-
.characters ⇒ Array<String>
Returns the list of character names available on the account.
-
.game_code ⇒ String?
Returns the game code identifying the current game (GemStone IV or DragonRealms).
-
.game_code=(value) ⇒ String
Sets the game code.
-
.members ⇒ Hash
Returns a hash mapping character codes to character names for all characters on the account.
-
.members=(value) ⇒ Hash
Parses and stores the members list from a game server response string.
-
.name ⇒ String?
Returns the account name.
-
.name=(value) ⇒ String
Sets the account name.
-
.subscription ⇒ String?
Returns the subscription type for the account.
-
.subscription=(value) ⇒ String?
Sets the subscription type, extracting the recognized type from the input string.
-
.type ⇒ String?
private
Returns the account type from the game server, available only in GemStone IV.
Class Method Details
.character ⇒ String?
Returns the name of the currently logged-in character.
38 39 40 |
# File 'documented/common/account.rb', line 38 def self.character @@character end |
.character=(value) ⇒ String
Sets the name of the currently logged-in character.
46 47 48 |
# File 'documented/common/account.rb', line 46 def self.character=(value) @@character = value end |
.characters ⇒ Array<String>
Returns the list of character names available on the account.
136 137 138 |
# File 'documented/common/account.rb', line 136 def self.characters @@members.values end |
.game_code ⇒ String?
Returns the game code identifying the current game (GemStone IV or DragonRealms).
90 91 92 |
# File 'documented/common/account.rb', line 90 def self.game_code @@game_code end |
.game_code=(value) ⇒ String
Sets the game code.
98 99 100 |
# File 'documented/common/account.rb', line 98 def self.game_code=(value) @@game_code = value end |
.members ⇒ Hash
Returns a hash mapping character codes to character names for all characters on the account.
107 108 109 |
# File 'documented/common/account.rb', line 107 def self.members @@members end |
.members=(value) ⇒ Hash
Parses and stores the members list from a game server response string.
Expects a tab-delimited format: the first field is discarded (account data), followed by character records of "code\tname". Extracts all character code/name pairs into a hash.
122 123 124 125 126 127 128 129 |
# File 'documented/common/account.rb', line 122 def self.members=(value) potential_members = {} for code_name in value.sub(/^C\t[0-9]+\t[0-9]+\t[0-9]+\t[0-9]+[\t\n]/, '').scan(/[^\t]+\t[^\t\n]+/) char_code, char_name = code_name.split("\t") potential_members[char_code] = char_name end @@members = potential_members end |
.name ⇒ String?
Returns the account name.
21 22 23 |
# File 'documented/common/account.rb', line 21 def self.name @@name end |
.name=(value) ⇒ String
Sets the account name.
29 30 31 |
# File 'documented/common/account.rb', line 29 def self.name=(value) @@name = value end |
.subscription ⇒ String?
Returns the subscription type for the account.
55 56 57 |
# File 'documented/common/account.rb', line 55 def self.subscription @@subscription end |
.subscription=(value) ⇒ String?
Sets the subscription type, extracting the recognized type from the input string.
Only stores the subscription type if the value contains one of the recognized types: "NORMAL", "PREMIUM", "TRIAL", "INTERNAL", or "FREE". The entire matched word is extracted and stored; the rest of the input is ignored.
79 80 81 82 83 |
# File 'documented/common/account.rb', line 79 def self.subscription=(value) if value =~ /(NORMAL|PREMIUM|TRIAL|INTERNAL|FREE)/ @@subscription = Regexp.last_match(1) end end |
.type ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the account type from the game server, available only in GemStone IV.
Queries Infomon for the account type via the "account.type" key.
65 66 67 68 69 |
# File 'documented/common/account.rb', line 65 def self.type if XMLData.game.is_a?(String) && XMLData.game =~ /^GS/ Infomon.get("account.type") end end |