Module: Lich::Common::Authentication::LaunchData

Defined in:
documented/common/authentication/launch_data.rb

Class Method Summary collapse

Class Method Details

.create_entry(char_name:, game_code:, game_name:, user_id:, password:, frontend:, custom_launch: nil, custom_launch_dir: nil) ⇒ Hash

Creates a launch entry for a character in the game.

Examples:

Create a launch entry

entry = Lich::Common::Authentication::LaunchData.create_entry(
  char_name: "Hero",
  game_code: "HERO123",
  game_name: "The Great Adventure",
  user_id: "user123",
  password: "secret",
  frontend: "wizard"
)

Parameters:

  • char_name (String)

    the name of the character

  • game_code (String)

    the code of the game

  • game_name (String)

    the name of the game

  • user_id (String)

    the user ID

  • password (String)

    the password

  • frontend (String)

    the frontend type

  • custom_launch (String, nil) (defaults to: nil)

    optional custom launch command

  • custom_launch_dir (String, nil) (defaults to: nil)

    optional custom launch directory

Returns:

  • (Hash)

    a hash representing the launch entry



64
65
66
67
68
69
70
71
72
73
74
75
# File 'documented/common/authentication/launch_data.rb', line 64

def self.create_entry(char_name:, game_code:, game_name:, user_id:, password:, frontend:, custom_launch: nil, custom_launch_dir: nil)
  {
    char_name: char_name,
    game_code: game_code,
    game_name: game_name,
    user_id: user_id,
    password: password,
    frontend: frontend,
    custom_launch: custom_launch,
    custom_launch_dir: custom_launch_dir
  }
end

.prepare(auth_data, frontend, custom_launch = nil, custom_launch_dir = nil) ⇒ Array<String>

Prepares launch data based on authentication information and frontend type.

Examples:

Prepare launch data for wizard frontend

Lich::Common::Authentication::LaunchData.prepare(auth_data, "wizard")

Parameters:

  • auth_data (Hash)

    authentication data as key-value pairs

  • frontend (String)

    the frontend type (e.g., "wizard", "avalon")

  • custom_launch (String, nil) (defaults to: nil)

    optional custom launch command

  • custom_launch_dir (String, nil) (defaults to: nil)

    optional custom launch directory

Returns:

  • (Array<String>)

    formatted launch data strings



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'documented/common/authentication/launch_data.rb', line 15

def self.prepare(auth_data, frontend, custom_launch = nil, custom_launch_dir = nil)
  launch_data = auth_data.map { |k, v| "#{k.upcase}=#{v}" }

  # Modify launch data based on frontend
  case frontend.to_s.downcase
  when 'wizard'
    launch_data.collect! { |line|
      line.sub(/GAMEFILE=.+/, 'GAMEFILE=WIZARD.EXE')
          .sub(/GAME=.+/, 'GAME=WIZ')
          .sub(/FULLGAMENAME=.+/, 'FULLGAMENAME=Wizard Front End')
    }
  when 'avalon'
    launch_data.collect! { |line| line.sub(/GAME=.+/, 'GAME=AVALON') }
  when 'suks'
    launch_data.collect! { |line|
      line.sub(/GAMEFILE=.+/, 'GAMEFILE=WIZARD.EXE')
          .sub(/GAME=.+/, 'GAME=SUKS')
    }
  end

  # Add custom launch information if provided
  if custom_launch
    launch_data.push "CUSTOMLAUNCH=#{custom_launch}"
    launch_data.push "CUSTOMLAUNCHDIR=#{custom_launch_dir}" if custom_launch_dir
  end

  launch_data
end