Class: Lich::Gemstone::GameInstance

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

Instance Method Summary collapse

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

#atmospherics, #atmospherics=, #buffer_room_objs, #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



761
762
763
764
765
766
767
768
769
770
771
772
# File 'documented/games.rb', line 761

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



808
809
810
# File 'documented/games.rb', line 808

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

#handle_atmospherics(server_string) ⇒ Object



791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
# File 'documented/games.rb', line 791

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



774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
# File 'documented/games.rb', line 774

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



821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
# File 'documented/games.rb', line 821

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



812
813
814
815
816
817
818
819
# File 'documented/games.rb', line 812

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



840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
# File 'documented/games.rb', line 840

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 %w[wrayth stormfront].include?(Frontend.client) && 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