Module: Lich::Common::Account

Defined in:
lib/common/account.rb

Class Method Summary collapse

Class Method Details

.characterObject?

Returns the character associated with the account.

Returns:

  • (Object, nil)

    the character object or nil if not set.



30
31
32
# File 'lib/common/account.rb', line 30

def self.character
  @@character
end

.character=(value) ⇒ Object

Sets the character associated with the account.

Examples:

Lich::Common::Account.character = my_character

Parameters:

  • value (Object)

    the character to set for the account.

Returns:

  • (Object)

    the character that was set.



40
41
42
# File 'lib/common/account.rb', line 40

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

.charactersArray<String>

Returns the names of the characters associated with the account.

Returns:

  • (Array<String>)

    an array of character names.



107
108
109
# File 'lib/common/account.rb', line 107

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.



67
68
69
# File 'lib/common/account.rb', line 67

def self.game_code
  @@game_code
end

.game_code=(value) ⇒ String

Sets the game code associated with the account.

Examples:

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

Parameters:

  • value (String)

    the game code to set.

Returns:

  • (String)

    the game code that was set.



77
78
79
# File 'lib/common/account.rb', line 77

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.



84
85
86
# File 'lib/common/account.rb', line 84

def self.members
  @@members
end

.members=(value) ⇒ Hash

Note:

This method processes the input string to extract character codes and names.

Sets the members associated with the account.

Examples:

Lich::Common::Account.members = "C\t1\t2\t3\t4\t\nA\tCharacter1\nB\tCharacter2"

Parameters:

  • value (String)

    a string containing member character codes and names.

Returns:

  • (Hash)

    the members that were set.



95
96
97
98
99
100
101
102
# File 'lib/common/account.rb', line 95

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 of the account.

Returns:

  • (String, nil)

    the name of the account or nil if not set.



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

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 name that was set.



23
24
25
# File 'lib/common/account.rb', line 23

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.



47
48
49
# File 'lib/common/account.rb', line 47

def self.subscription
  @@subscription
end

.subscription=(value) ⇒ String

Sets the subscription type of the account.

Examples:

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

Parameters:

  • value (String)

    the subscription type to set.

Returns:

  • (String)

    the subscription type that was set.

Raises:

  • (ArgumentError)

    if the value does not match the expected types.



58
59
60
61
62
# File 'lib/common/account.rb', line 58

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