Class: Lich::Gemstone::GameInstance

Inherits:
Lich::GameBase::GameInstance::Base show all
Defined in:
documented/games.rb

Overview

Gemstone-specific game instance

Instance Method Summary collapse

Methods inherited from Lich::GameBase::GameInstance::Base

#atmospherics, #atmospherics=, #combat_count, #increment_combat_count, #initialize

Constructor Details

This class inherits a constructor from Lich::GameBase::GameInstance::Base

Instance Method Details

#clean_serverstring(server_string) ⇒ Object



734
735
736
737
738
739
740
741
742
743
744
745
# File 'documented/games.rb', line 734

def clean_serverstring(server_string)
  # The Rift, Scatter is broken...
  if server_string =~ /<compDef id='room text'><\/compDef>/
    server_string.sub!(/(.*)\s\s<compDef id='room text'><\/compDef>/) { "<compDef id='room desc'>#{$1}</compDef>" }
  end

  # Handle combat and atmospherics
  server_string = handle_combat_tags(server_string)
  server_string = handle_atmospherics(server_string)

  server_string
end

#get_documentation_urlObject



781
782
783
# File 'documented/games.rb', line 781

def get_documentation_url
  "https://gswiki.play.net/Lich:Software/Installation"
end

#handle_atmospherics(server_string) ⇒ Object



764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
# File 'documented/games.rb', line 764

def handle_atmospherics(server_string)
  if @atmospherics
    @atmospherics = false
    server_string.prepend('<popStream id="atmospherics" />') unless server_string =~ /<popStream id="atmospherics" \/>/
  end

  if server_string =~ /<pushStream id="familiar" \/><prompt time="[0-9]+">&gt;<\/prompt>/ # Cry For Help spell is broken...
    server_string.sub!('<pushStream id="familiar" />', '')
  elsif server_string =~ /<pushStream id="atmospherics" \/><prompt time="[0-9]+">&gt;<\/prompt>/ # pet pigs in DragonRealms are broken...
    server_string.sub!('<pushStream id="atmospherics" />', '')
  elsif (server_string =~ /<pushStream id="atmospherics" \/>/)
    @atmospherics = true
  end

  server_string
end

#handle_combat_tags(server_string) ⇒ Object



747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'documented/games.rb', line 747

def handle_combat_tags(server_string)
  if @combat_count > 0
    @end_combat_tags.each do |tag|
      if server_string.include?(tag)
        server_string = server_string.gsub(tag, "<popStream id=\"combat\" />" + tag) unless server_string.include?("<popStream id=\"combat\" />")
        @combat_count -= 1
      end
      if server_string.include?("<pushStream id=\"combat\" />")
        server_string = server_string.gsub("<pushStream id=\"combat\" />", "")
      end
    end
  end

  increment_combat_count(server_string)
  server_string
end

#modify_room_display(alt_string) ⇒ Object



794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'documented/games.rb', line 794

def modify_room_display(alt_string)
  uid_from_string = alt_string.match(/] \((?<uid>\d+)\)/)
  if uid_from_string.nil?
    lichid_from_uid_string = Room.current.id
  else
    lichid_from_uid_string = Room["u#{uid_from_string[:uid]}"].id.to_i
  end
  if Lich.display_lichid == true
    alt_string.sub!(']') { " - #{lichid_from_uid_string}]" }
  end

  if Lich.display_uid == true
    alt_string.sub!(/] \(\d+\)/) { "]" }
    alt_string.sub!(']') { "] (#{(uid_from_string.nil? || XMLData.room_id == uid_from_string[:uid].to_i) ? ((XMLData.room_id == 0 || XMLData.room_id > 4294967296) ? "unknown" : "u#{XMLData.room_id}") : uid_from_string[:uid].to_i})" }
  end

  alt_string
end

#process_game_specific_data(server_string) ⇒ Object



785
786
787
788
789
790
791
792
# File 'documented/games.rb', line 785

def process_game_specific_data(server_string)
  infomon_serverstring = server_string.dup
  Infomon::XMLParser.parse(infomon_serverstring)
  stripped_infomon_serverstring = strip_xml(infomon_serverstring, type: 'infomon')
  stripped_infomon_serverstring.split("\r\n").each do |line|
    Infomon::Parser.parse(line) unless line.empty?
  end
end

#process_room_display(alt_string) ⇒ Object



813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
# File 'documented/games.rb', line 813

def process_room_display(alt_string)
  if Lich.display_stringprocs == true
    room_exits = []
    Map.current.wayto.each do |key, value|
      # Don't include cardinals / up/down/out (usually just climb/go)
      if value.is_a?(StringProc)
        if Map.current.timeto[key].is_a?(Numeric) || (Map.current.timeto[key].is_a?(StringProc) && Map.current.timeto[key].call.is_a?(Numeric))
          room_exits << "<d cmd=';go2 #{key}'>#{Map[key].title.first.gsub(/\[|\]/, '')}#{Lich.display_lichid ? ('(' + Map[key].id.to_s + ')') : ''}</d>"
        end
      end
    end
    alt_string = "StringProcs: #{room_exits.join(', ')}\r\n#{alt_string}" unless room_exits.empty?
  end

  if Lich.display_exits == true
    room_exits = []
    Map.current.wayto.each do |_key, value|
      # Don't include cardinals / up/down/out (usually just climb/go)
      next if value.to_s =~ /^(?:o|d|u|n|ne|e|se|s|sw|w|nw|out|down|up|north|northeast|east|southeast|south|southwest|west|northwest)$/
      unless value.is_a?(StringProc)
        room_exits << "<d cmd='#{value.dump[1..-2]}'>#{value.dump[1..-2]}</d>"
      end
    end

    unless room_exits.empty?
      alt_string = "Room Exits: #{room_exits.join(', ')}\r\n#{alt_string}"
      if ['wrayth', 'stormfront'].include?($frontend) && Map.current.id != Game.instance_variable_get(:@last_id_shown_room_window)
        alt_string = "#{alt_string}<pushStream id='room' ifClosedStyle='watching'/>Room Exits: #{room_exits.join(', ')}\r\n<popStream/>\r\n"
        Game.instance_variable_set(:@last_id_shown_room_window, Map.current.id)
      end
    end
  end

  alt_string
end