Class: Lich::DragonRealms::GameInstance
- Inherits:
-
GameBase::GameInstance::Base
- Object
- GameBase::GameInstance::Base
- Lich::DragonRealms::GameInstance
- Defined in:
- documented/games.rb
Overview
DragonRealms-specific game instance DragonRealms-specific game instance Inherits from GameBase::GameInstance::Base and implements game-specific logic
Instance Method Summary collapse
-
#clean_serverstring(server_string) ⇒ String
Cleans the server string for DragonRealms.
-
#get_documentation_url ⇒ String
Retrieves the documentation URL for the DragonRealms game instance.
-
#handle_atmospherics(server_string) ⇒ String
Handles atmospherics specific to DragonRealms.
-
#handle_combat_tags(server_string) ⇒ String
Handles combat tags specific to DragonRealms.
-
#modify_room_display(alt_string) ⇒ String
Modifies the room display string for DragonRealms.
-
#process_game_specific_data(server_string) ⇒ void
Processes game-specific data for DragonRealms.
-
#process_room_display(alt_string) ⇒ String
Processes the room display string for DragonRealms.
Methods inherited from 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) ⇒ String
Cleans the server string for DragonRealms
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
# File 'documented/games.rb', line 883 def clean_serverstring(server_string) # Clear out superfluous tags server_string = server_string.gsub("<pushStream id=\"combat\" /><popStream id=\"combat\" />", "") server_string = server_string.gsub("<popStream id=\"combat\" /><pushStream id=\"combat\" />", "") # Fix encoding issues server_string = GameBase::XMLCleaner.fix_invalid_characters(server_string) # Fix combat wrapping components server_string = server_string.gsub("<pushStream id=\"combat\" /><component id=", "<component id=") # Fix XML tags server_string = GameBase::XMLCleaner.(server_string) # Fix duplicate pushStrings while server_string.include?("<pushStream id=\"combat\" /><pushStream id=\"combat\" />") server_string = server_string.gsub("<pushStream id=\"combat\" /><pushStream id=\"combat\" />", "<pushStream id=\"combat\" />") end # Handle combat and atmospherics server_string = (server_string) server_string = handle_atmospherics(server_string) server_string end |
#get_documentation_url ⇒ String
Retrieves the documentation URL for the DragonRealms game instance
957 958 959 |
# File 'documented/games.rb', line 957 def get_documentation_url "https://github.com/elanthia-online/lich-5/wiki/Documentation-for-Installing-and-Upgrading-Lich" end |
#handle_atmospherics(server_string) ⇒ String
Handles atmospherics specific to DragonRealms
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 |
# File 'documented/games.rb', line 936 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]+">><\/prompt>/ # Cry For Help spell is broken... server_string.sub!('<pushStream id="familiar" />', '') elsif server_string =~ /<pushStream id="atmospherics" \/><prompt time="[0-9]+">><\/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) ⇒ String
Handles combat tags specific to DragonRealms
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 |
# File 'documented/games.rb', line 914 def (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) ⇒ String
Modifies the room display string for DragonRealms
976 977 978 979 980 981 982 983 984 |
# File 'documented/games.rb', line 976 def modify_room_display(alt_string) if Lich.display_uid == true alt_string.sub!(/] \((?:\d+|\*\*)\)/) { "]" } elsif Lich.hide_uid_flag == true alt_string.sub!(/] \((?:\d+|\*\*)\)/) { "]" } end alt_string end |
#process_game_specific_data(server_string) ⇒ void
This method returns an undefined value.
Processes game-specific data for DragonRealms
966 967 968 969 |
# File 'documented/games.rb', line 966 def process_game_specific_data(server_string) infomon_serverstring = server_string.dup DRParser.parse(infomon_serverstring) end |
#process_room_display(alt_string) ⇒ String
Processes the room display string for DragonRealms
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
# File 'documented/games.rb', line 991 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}" end end # DR-specific room number display room_number = "" room_number += "#{Map.current.id}" if Lich.display_lichid room_number += " - " if Lich.display_lichid && Lich.display_uid room_number += "(#{XMLData.room_id == 0 ? "**" : "u#{XMLData.room_id}"})" if Lich.display_uid unless room_number.empty? alt_string = "Room Number: #{room_number}\r\n#{alt_string}" if ['wrayth', 'stormfront'].include?($frontend) alt_string = "<streamWindow id='main' title='Story' subtitle=\" - [#{XMLData.room_title[2..-3]} - #{room_number}]\" location='center' target='drop'/>\r\n#{alt_string}" alt_string = "<streamWindow id='room' title='Room' subtitle=\" - [#{XMLData.room_title[2..-3]} - #{room_number}]\" location='center' target='drop' ifClosed='' resident='true'/>#{alt_string}" end end alt_string end |