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

Defined in:
documented/main/argv_options.rb

Overview

Module for handling game connection options This module processes game connection parameters from command line arguments.

Class Method Summary collapse

Class Method Details

.determine_frontendString

Determines the frontend type based on command line arguments.

Returns:

  • (String)

    The determined frontend type (e.g., ‘wizard’, ‘stormfront’).



461
462
463
464
465
466
467
468
469
470
471
472
473
# File 'documented/main/argv_options.rb', line 461

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 handling based on parsed options.

Parameters:

  • processed_options (Hash)

    The processed command line options.

Returns:

  • (Hash)

    The modified options after handling game connections.



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'documented/main/argv_options.rb', line 335

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 ARGV.include?('--gemstone')
    handle_gemstone_connection(processed_options)
  elsif ARGV.include?('--dragonrealms')
    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



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'documented/main/argv_options.rb', line 425

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) ⇒ void

Note:

This method modifies the processed_options hash.

This method returns an undefined value.

Handles explicit game connection parameters from command line arguments.

Parameters:

  • arg (String)

    The game connection argument.

  • processed_options (Hash)

    The processed command line options.



359
360
361
362
363
364
365
366
367
# File 'documented/main/argv_options.rb', line 359

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



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'documented/main/argv_options.rb', line 408

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



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'documented/main/argv_options.rb', line 369

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



395
396
397
398
399
400
401
402
403
404
405
406
# File 'documented/main/argv_options.rb', line 395

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