Module: Lich::Common::Account

Defined in:
documented/common/account.rb

Class Method Summary collapse

Class Method Details

.characterString?

Returns the character associated with the account.

Returns:

  • (String, nil)

    the character name or nil if not set



27
28
29
# File 'documented/common/account.rb', line 27

def self.character
  @@character
end

.character=(value) ⇒ void

This method returns an undefined value.

Sets the character for the account.

Parameters:

  • value (String)

    the character name to set



34
35
36
# File 'documented/common/account.rb', line 34

def self.character=(value)
  @@character = value
end

.charactersArray<String>

Returns the character names of the members associated with the account.

Returns:

  • (Array<String>)

    an array of character names



99
100
101
# File 'documented/common/account.rb', line 99

def self.characters
  @@members.values
end

.game_codeString?

Returns the game code associated with the account.

Returns:

  • (String, nil)

    the game code or nil if not set



66
67
68
# File 'documented/common/account.rb', line 66

def self.game_code
  @@game_code
end

.game_code=(value) ⇒ void

This method returns an undefined value.

Sets the game code for the account.

Parameters:

  • value (String)

    the game code to set



73
74
75
# File 'documented/common/account.rb', line 73

def self.game_code=(value)
  @@game_code = value
end

.membersHash

Returns the members associated with the account.

Returns:

  • (Hash)

    a hash of member character codes and names



80
81
82
# File 'documented/common/account.rb', line 80

def self.members
  @@members
end

.members=(value) ⇒ void

This method returns an undefined value.

Sets the members for the account based on a formatted string.

Parameters:

  • value (String)

    the formatted string containing member character codes and names



87
88
89
90
91
92
93
94
# File 'documented/common/account.rb', line 87

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

.nameString?

Returns the name associated with the account.

Returns:

  • (String, nil)

    the account name or nil if not set



13
14
15
# File 'documented/common/account.rb', line 13

def self.name
  @@name
end

.name=(value) ⇒ void

This method returns an undefined value.

Sets the name for the account.

Parameters:

  • value (String)

    the name to set for the account



20
21
22
# File 'documented/common/account.rb', line 20

def self.name=(value)
  @@name = value
end

.subscriptionString?

Returns the subscription type of the account.

Returns:

  • (String, nil)

    the subscription type or nil if not set



41
42
43
# File 'documented/common/account.rb', line 41

def self.subscription
  @@subscription
end

.subscription=(value) ⇒ void

This method returns an undefined value.

Sets the subscription type for the account.

Parameters:

  • value (String)

    the subscription type to set (NORMAL, PREMIUM, TRIAL, INTERNAL, FREE)



57
58
59
60
61
# File 'documented/common/account.rb', line 57

def self.subscription=(value)
  if value =~ /(NORMAL|PREMIUM|TRIAL|INTERNAL|FREE)/
    @@subscription = Regexp.last_match(1)
  end
end

.typeString?

Returns the type of account based on the game code.

Returns:

  • (String, nil)

    the account type or nil if not applicable



48
49
50
51
52
# File 'documented/common/account.rb', line 48

def self.type
  if XMLData.game.is_a?(String) && XMLData.game =~ /^GS/
    Infomon.get("account.type")
  end
end