Module: Lich::Main::ArgvOptions::GameConnection

Defined in:
documented/main/argv_options.rb

Overview

Module for handling game connection configurations.

This module manages the connection settings based on the command-line arguments.

Class Method Summary collapse

Class Method Details

.determine_frontendObject



374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'documented/main/argv_options.rb', line 374

def self.determine_frontend
  if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
    'stormfront'
  elsif ARGV.any? { |a| a == '-w' || a == '--wizard' }
    'wizard'
  elsif ARGV.any? { |a| a == '--avalon' }
    'avalon'
  elsif ARGV.any? { |a| a == '--frostbite' }
    'frostbite'
  else
    'unknown'
  end
end

.execute(processed_options) ⇒ Hash

Executes the game connection configuration based on command-line options.

This method determines the appropriate game connection settings based on the provided arguments.

Parameters:

  • processed_options (Hash)

    the processed command-line options

Returns:

  • (Hash)

    the updated processed options with game connection settings



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'documented/main/argv_options.rb', line 255

def self.execute(processed_options)
  if (arg = ARGV.find { |a| a == '-g' || a == '--game' })
    handle_explicit_game_connection(arg, processed_options)
  elsif ARGV.include?('--shattered')
    handle_shattered_connection(processed_options)
  elsif ARGV.include?('--fallen')
    handle_fallen_connection(processed_options)
  elsif Lich::Common::Authentication::LoginHelpers.gemstone_flag?(ARGV)
    handle_gemstone_connection(processed_options)
  elsif Lich::Common::Authentication::LoginHelpers.dragonrealms_flag?(ARGV)
    handle_dragonrealms_connection(processed_options)
  else
    processed_options[:game_host] = nil
    processed_options[:game_port] = nil
    Lich.log 'info: no force-mode info given'
  end
  processed_options
end

.handle_dragonrealms_connection(processed_options) ⇒ Object



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'documented/main/argv_options.rb', line 340

def self.handle_dragonrealms_connection(processed_options)
  if ARGV.include?('--platinum')
    $platinum = true
    if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = 11124
      $frontend = 'stormfront'
    elsif ARGV.grep(/--genie/).any?
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = 11124
      $frontend = 'genie'
    else
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = 11124
      $frontend = ARGV.any? { |a| a == '--avalon' } ? 'avalon' : ARGV.any? { |a| a == '--frostbite' } ? 'frostbite' : 'wizard'
    end
  else
    $platinum = false
    if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 11624 : 11024
      $frontend = 'stormfront'
    elsif ARGV.grep(/--genie/).any?
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 11624 : 11024
      $frontend = 'genie'
    else
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 11624 : 11024
      $frontend = ARGV.any? { |a| a == '--avalon' } ? 'avalon' : ARGV.any? { |a| a == '--frostbite' } ? 'frostbite' : 'wizard'
    end
  end
end

.handle_explicit_game_connection(arg, processed_options) ⇒ Object



274
275
276
277
278
279
280
281
282
# File 'documented/main/argv_options.rb', line 274

def self.handle_explicit_game_connection(arg, processed_options)
  processed_options[:game_host], processed_options[:game_port] = ARGV[ARGV.index(arg) + 1].split(':')
  processed_options[:game_port] = processed_options[:game_port].to_i
  $frontend = determine_frontend
  # Initialize frontend from parent process unless using detachable client
  unless ARGV.any? { |a| a =~ /^--detachable-client/ }
    Lich::Common::Frontend.init_from_parent(Process.ppid)
  end
end

.handle_fallen_connection(processed_options) ⇒ Object



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'documented/main/argv_options.rb', line 323

def self.handle_fallen_connection(processed_options)
  $platinum = false
  if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
    processed_options[:game_host] = 'dr.simutronics.net'
    processed_options[:game_port] = 11324
    $frontend = 'stormfront'
  elsif ARGV.grep(/--genie/).any?
    processed_options[:game_host] = 'dr.simutronics.net'
    processed_options[:game_port] = 11324
    $frontend = 'genie'
  else
    processed_options[:game_host] = 'dr.simutronics.net'
    processed_options[:game_port] = 11324
    $frontend = ARGV.any? { |a| a == '--avalon' } ? 'avalon' : ARGV.any? { |a| a == '--frostbite' } ? 'frostbite' : 'wizard'
  end
end

.handle_gemstone_connection(processed_options) ⇒ Object



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'documented/main/argv_options.rb', line 284

def self.handle_gemstone_connection(processed_options)
  if ARGV.include?('--platinum')
    $platinum = true
    if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = 10124
      $frontend = 'stormfront'
    else
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = 10124
      $frontend = ARGV.any? { |a| a == '--avalon' } ? 'avalon' : 'wizard'
    end
  else
    $platinum = false
    if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 10624 : 10024
      $frontend = 'stormfront'
    else
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 10624 : 10024
      $frontend = ARGV.any? { |a| a == '--avalon' } ? 'avalon' : 'wizard'
    end
  end
end

.handle_shattered_connection(processed_options) ⇒ Object



310
311
312
313
314
315
316
317
318
319
320
321
# File 'documented/main/argv_options.rb', line 310

def self.handle_shattered_connection(processed_options)
  $platinum = false
  if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
    processed_options[:game_host] = 'storm.gs4.game.play.net'
    processed_options[:game_port] = 10324
    $frontend = 'stormfront'
  else
    processed_options[:game_host] = 'storm.gs4.game.play.net'
    processed_options[:game_port] = 10324
    $frontend = ARGV.any? { |a| a == '--avalon' } ? 'avalon' : 'wizard'
  end
end