Module: Lich::Common::Authentication::LaunchData
- Defined in:
- documented/common/authentication/launch_data.rb
Overview
Handles formatting of launch data for different game frontends
Class Method Summary collapse
-
.create_entry(char_name:, game_code:, game_name:, user_id:, password:, frontend:, custom_launch: nil, custom_launch_dir: nil) ⇒ Hash
private
Creates a hash entry for saved login data This standardizes the format of saved login entries.
-
.prepare(auth_data, frontend, custom_launch = nil, custom_launch_dir = nil) ⇒ Array<String>
private
Prepares launch data from authentication result Formats the authentication data for use with different frontends.
Class Method Details
.create_entry(char_name:, game_code:, game_name:, user_id:, password:, frontend:, custom_launch: nil, custom_launch_dir: nil) ⇒ Hash
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.
Creates a hash entry for saved login data This standardizes the format of saved login entries
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'documented/common/authentication/launch_data.rb', line 68 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>
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.
Prepares launch data from authentication result Formats the authentication data for use with different frontends
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'documented/common/authentication/launch_data.rb', line 20 def self.prepare(auth_data, frontend, custom_launch = nil, custom_launch_dir = nil) launch_data = auth_data.map { |k, v| "#{k.upcase}=#{v}" } custom_launch = custom_launch.to_s.strip custom_launch = nil if custom_launch.empty? custom_launch_dir = custom_launch_dir.to_s.strip if custom_launch custom_launch_dir = nil if custom_launch_dir == '' # 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 'saga' launch_data.collect! { |line| line.sub(/GAME=.+/, 'GAME=SAGA') } 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 |