Module: Lich::Common::Account

Defined in:
documented/common/account.rb

Class Method Summary collapse

Class Method Details

.characterObject

Retrieves the character associated with the account

Examples:

character = Lich::Common::Account.character

Returns:

  • (Object)

    the character object



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

def self.character
  @@character
end

.character=(value) ⇒ Object

Sets the character for the account

Examples:

Lich::Common::Account.character = my_character

Parameters:

  • value (Object)

    The character object to associate with the account

Returns:

  • (Object)

    the set character object



43
44
45
# File 'documented/common/account.rb', line 43

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

.charactersArray

Retrieves the character names associated with the account

Examples:

character_names = Lich::Common::Account.characters

Returns:

  • (Array)

    an array of character names



119
120
121
# File 'documented/common/account.rb', line 119

def self.characters
  @@members.values
end

.game_codeString

Retrieves the game code associated with the account

Examples:

game_code = Lich::Common::Account.game_code

Returns:



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

def self.game_code
  @@game_code
end

.game_code=(value) ⇒ String

Sets the game code for the account

Examples:

Lich::Common::Account.game_code = "GS123"

Parameters:

  • value (String)

    The game code to set

Returns:

  • (String)

    the set game code



89
90
91
# File 'documented/common/account.rb', line 89

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

.membersHash

Retrieves the members associated with the account

Examples:

members = Lich::Common::Account.members

Returns:

  • (Hash)

    a hash of member codes and names



97
98
99
# File 'documented/common/account.rb', line 97

def self.members
  @@members
end

.members=(value) ⇒ Hash

Sets the members for the account

Examples:

Lich::Common::Account.members = "C\t123\t456\t789\t012\tJohn\tDoe"

Parameters:

  • value (String)

    A formatted string containing member codes and names

Returns:

  • (Hash)

    the set members



106
107
108
109
110
111
112
113
# File 'documented/common/account.rb', line 106

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

Retrieves the name of the account

Examples:

 = Lich::Common::Account.name

Returns:

  • (String)

    the account name



17
18
19
# File 'documented/common/account.rb', line 17

def self.name
  @@name
end

.name=(value) ⇒ String

Sets the name of the account

Examples:

Lich::Common::Account.name = "Player1"

Parameters:

  • value (String)

    The name to set for the account

Returns:

  • (String)

    the set account name



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

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

.subscriptionString

Retrieves the subscription type of the account

Examples:

subscription_type = Lich::Common::Account.subscription

Returns:

  • (String)

    the subscription type



51
52
53
# File 'documented/common/account.rb', line 51

def self.subscription
  @@subscription
end

.subscription=(value) ⇒ String

Sets the subscription type for the account

Examples:

Lich::Common::Account.subscription = "PREMIUM"

Parameters:

  • value (String)

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

Returns:

  • (String)

    the set subscription type



70
71
72
73
74
# File 'documented/common/account.rb', line 70

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

.typeString?

Retrieves the type of account based on game data

Examples:

 = Lich::Common::Account.type

Returns:

  • (String, nil)

    the account type or nil if not applicable



59
60
61
62
63
# File 'documented/common/account.rb', line 59

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