Class: Lich::GameBase::GameInstance::Base
- Inherits:
-
Object
- Object
- Lich::GameBase::GameInstance::Base
- Includes:
- RoomFormatter
- Defined in:
- documented/games.rb
Overview
Base instance class that defines the interface
Direct Known Subclasses
Constant Summary
Constants included from RoomFormatter
RoomFormatter::OBVIOUS_EXIT_PATTERN
Instance Method Summary collapse
-
#atmospherics ⇒ Boolean
private
Returns whether an atmospheric stream is currently active.
-
#atmospherics=(value) ⇒ Boolean
private
Sets the atmospheric stream state.
-
#buffer_room_objs(server_string) ⇒ Object
Buffer split
or when server sends "...wait N seconds." on separate line Returns [should_skip, server_string]. - #clean_serverstring(server_string) ⇒ Object
-
#combat_count ⇒ Integer
private
Returns the current nesting depth of the combat stream.
- #get_documentation_url ⇒ Object
- #handle_atmospherics(server_string) ⇒ Object
- #handle_combat_tags(server_string) ⇒ Object
- #increment_combat_count(server_string) ⇒ Object protected
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #modify_room_display(alt_string) ⇒ Object
- #process_game_specific_data(server_string, stripped_server = nil) ⇒ Object
-
#process_room_display(alt_string) ⇒ String
private
Injects room information lines (exits, StringProcs, room numbers) into the display.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
185 186 187 188 189 190 |
# File 'documented/games.rb', line 185 def initialize @atmospherics = false @combat_count = 0 @end_combat_tags = ["<prompt", "<clearStream", "<component", "<pushStream id=\"percWindow"] @pending_room_objs = nil end |
Instance Method Details
#atmospherics ⇒ Boolean
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 whether an atmospheric stream is currently active.
241 242 243 |
# File 'documented/games.rb', line 241 def atmospherics @atmospherics end |
#atmospherics=(value) ⇒ Boolean
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.
Sets the atmospheric stream state.
250 251 252 |
# File 'documented/games.rb', line 250 def atmospherics=(value) @atmospherics = value end |
#buffer_room_objs(server_string) ⇒ Object
Buffer split
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'documented/games.rb', line 256 def buffer_room_objs(server_string) if @pending_room_objs if server_string.include?("</component>") combined = @pending_room_objs + server_string.sub(/\r\n$/, '') Lich.log "Combined split room component: #{combined.inspect}" @pending_room_objs = nil return [false, combined] else @pending_room_objs = @pending_room_objs + server_string.sub(/\r\n$/, '') return [true, nil] end end if server_string =~ /^(?:<\/?(?:pushStream|popStream)[^>]*>\s*)*<component id='room (?:objs|players)'>.*\.\.\.wait \d+ seconds?\.\r\n$/ && !server_string.include?("</component>") Lich.log "Open-ended room component tag, buffering: #{server_string.inspect}" # Strip the "...wait N seconds.\r\n" part, keep the opening tag and any content before it @pending_room_objs = server_string.sub(/\.\.\.wait \d+ seconds?\.\r\n$/, '') return [true, nil] end [false, server_string] end |
#clean_serverstring(server_string) ⇒ Object
192 193 194 |
# File 'documented/games.rb', line 192 def clean_serverstring(server_string) raise NotImplementedError, "#{self.class} must implement #clean_serverstring" end |
#combat_count ⇒ Integer
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 current nesting depth of the combat stream.
233 234 235 |
# File 'documented/games.rb', line 233 def combat_count @combat_count end |
#get_documentation_url ⇒ Object
204 205 206 |
# File 'documented/games.rb', line 204 def get_documentation_url raise NotImplementedError, "#{self.class} must implement #get_documentation_url" end |
#handle_atmospherics(server_string) ⇒ Object
200 201 202 |
# File 'documented/games.rb', line 200 def handle_atmospherics(server_string) raise NotImplementedError, "#{self.class} must implement #handle_atmospherics" end |
#handle_combat_tags(server_string) ⇒ Object
196 197 198 |
# File 'documented/games.rb', line 196 def (server_string) raise NotImplementedError, "#{self.class} must implement #handle_combat_tags" end |
#increment_combat_count(server_string) ⇒ Object (protected)
281 282 283 284 285 |
# File 'documented/games.rb', line 281 def increment_combat_count(server_string) @combat_count += server_string.scan("<pushStream id=\"combat\" />").length @combat_count -= server_string.scan("<popStream id=\"combat\" />").length @combat_count = 0 if @combat_count < 0 end |
#modify_room_display(alt_string) ⇒ Object
212 213 214 |
# File 'documented/games.rb', line 212 def modify_room_display(alt_string) raise NotImplementedError, "#{self.class} must implement #modify_room_display" end |
#process_game_specific_data(server_string, stripped_server = nil) ⇒ Object
208 209 210 |
# File 'documented/games.rb', line 208 def process_game_specific_data(server_string, stripped_server = nil) raise NotImplementedError, "#{self.class} must implement #process_game_specific_data" end |
#process_room_display(alt_string) ⇒ String
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.
Injects room information lines (exits, StringProcs, room numbers) into the display.
This method is overridden by game-specific implementations to format and place room annotations according to game and frontend conventions.
225 226 227 |
# File 'documented/games.rb', line 225 def process_room_display(alt_string) raise NotImplementedError, "#{self.class} must implement #process_room_display" end |