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

Defined in:
documented/main/argv_options.rb

Overview

Handle game connection configuration

Class Method Summary collapse

Class Method Details

.determine_frontendString

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.

Returns the frontend name based on ARGV flags.

Checks for -s/--stormfront, -w/--wizard, --avalon, --frostbite, and --saga in ARGV in that order of precedence.

Returns:

  • (String)

    the frontend name: "stormfront", "wizard", "avalon", "frostbite", "saga", or "unknown" if no flag matches



530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'documented/main/argv_options.rb', line 530

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'
  elsif ARGV.any? { |a| a == '--saga' }
    'saga'
  else
    'unknown'
  end
end

.execute(processed_options) ⇒ 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.

Routes game connection configuration based on ARGV flags.

Checks for explicit -g/--game, --shattered, --fallen, and game-specific flags (--gemstone, --dragonrealms) in ARGV and delegates to the corresponding handler. Sets :game_host and :game_port in processed_options. Falls through to set both to nil if no route matches.

Parameters:

  • processed_options (Hash)

    mutable option hash

Returns:

  • (Hash)

    the mutated processed_options hash



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'documented/main/argv_options.rb', line 357

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

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.

This method returns an undefined value.

Configures DragonRealms connection details based on ARGV flags.

Sets host to dr.simutronics.net, port based on --platinum, --test, and --stormfront/--genie flags, and determines frontend from ARGV. Sets $platinum global accordingly.

Parameters:

  • processed_options (Hash)

    mutable option hash; sets :game_host and :game_port



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'documented/main/argv_options.rb', line 488

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

.handle_explicit_game_connection(arg, processed_options) ⇒ void

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.

This method returns an undefined value.

Handles explicit -g/--game HOST:PORT connection configuration.

Extracts host and port from the argument following -g or --game in ARGV, determines the frontend from other ARGV flags, and initializes the frontend from the parent process unless --detachable-client is present.

Parameters:

  • arg (String)

    the -g or --game flag itself

  • processed_options (Hash)

    mutable option hash



386
387
388
389
390
391
392
393
394
# File 'documented/main/argv_options.rb', line 386

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/i }
    Lich::Common::Frontend.init_from_parent(Process.ppid)
  end
end

.handle_fallen_connection(processed_options) ⇒ void

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.

This method returns an undefined value.

Configures Fallen connection details.

Sets host to dr.simutronics.net and port to 11324. Determines frontend from ARGV (stormfront, genie, or wizard/avalon/frostbite/saga default). Sets $platinum to false.

Parameters:

  • processed_options (Hash)

    mutable option hash; sets :game_host and :game_port



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

def self.handle_fallen_connection(processed_options)
  $platinum = false
  if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
    processed_options[:game_host] = 'dr.simutronics.net'
    processed_options[:game_port] = 11324
    $frontend = 'stormfront'
  elsif ARGV.grep(/--genie/i).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$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
  end
end

.handle_gemstone_connection(processed_options) ⇒ void

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.

This method returns an undefined value.

Configures GemStone IV connection details based on ARGV flags.

Sets host to storm.gs4.game.play.net, port based on --platinum, --test, and --stormfront flags, and determines the frontend (stormfront, wizard, avalon, frostbite, saga) from ARGV. Sets $platinum global accordingly.

Parameters:

  • processed_options (Hash)

    mutable option hash; sets :game_host and :game_port



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'documented/main/argv_options.rb', line 405

def self.handle_gemstone_connection(processed_options)
  if ARGV.include?('--platinum')
    $platinum = true
    if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
      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$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
    end
  else
    $platinum = false
    if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
      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$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
    end
  end
end

.handle_shattered_connection(processed_options) ⇒ void

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.

This method returns an undefined value.

Configures Shattered connection details.

Sets host to storm.gs4.game.play.net and port to 10324. Determines frontend from ARGV (stormfront or wizard/avalon/frostbite/saga default). Sets $platinum to false.

Parameters:

  • processed_options (Hash)

    mutable option hash; sets :game_host and :game_port



440
441
442
443
444
445
446
447
448
449
450
451
# File 'documented/main/argv_options.rb', line 440

def self.handle_shattered_connection(processed_options)
  $platinum = false
  if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
    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$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
  end
end