Class: Lich::GameBase::GameInstance::Base
- Inherits:
-
Object
- Object
- Lich::GameBase::GameInstance::Base
show all
- Defined in:
- documented/games.rb
Overview
Note:
This class is intended to be subclassed for specific game types.
Base class for game instances.
This class provides the core functionality for all game instances.
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
48
49
50
51
52
53
|
# File 'documented/games.rb', line 48
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 ⇒ Object
87
88
89
|
# File 'documented/games.rb', line 87
def atmospherics
@atmospherics
end
|
#atmospherics=(value) ⇒ Object
91
92
93
|
# File 'documented/games.rb', line 91
def atmospherics=(value)
@atmospherics = value
end
|
#buffer_room_objs(server_string) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'documented/games.rb', line 95
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}"
@pending_room_objs = server_string.sub(/\.\.\.wait \d+ seconds?\.\r\n$/, '')
return [true, nil]
end
[false, server_string]
end
|
#clean_serverstring(server_string) ⇒ Object
55
56
57
|
# File 'documented/games.rb', line 55
def clean_serverstring(server_string)
raise NotImplementedError, "#{self.class} must implement #clean_serverstring"
end
|
#combat_count ⇒ Object
83
84
85
|
# File 'documented/games.rb', line 83
def combat_count
@combat_count
end
|
#get_documentation_url ⇒ Object
67
68
69
|
# File 'documented/games.rb', line 67
def get_documentation_url
raise NotImplementedError, "#{self.class} must implement #get_documentation_url"
end
|
#handle_atmospherics(server_string) ⇒ Object
63
64
65
|
# File 'documented/games.rb', line 63
def handle_atmospherics(server_string)
raise NotImplementedError, "#{self.class} must implement #handle_atmospherics"
end
|
59
60
61
|
# File 'documented/games.rb', line 59
def handle_combat_tags(server_string)
raise NotImplementedError, "#{self.class} must implement #handle_combat_tags"
end
|
#increment_combat_count(server_string) ⇒ Object
120
121
122
123
124
|
# File 'documented/games.rb', line 120
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, uid_from_string, lichid_from_uid_string) ⇒ Object
75
76
77
|
# File 'documented/games.rb', line 75
def modify_room_display(alt_string, uid_from_string, lichid_from_uid_string)
raise NotImplementedError, "#{self.class} must implement #modify_room_display"
end
|
#process_game_specific_data(server_string) ⇒ Object
71
72
73
|
# File 'documented/games.rb', line 71
def process_game_specific_data(server_string)
raise NotImplementedError, "#{self.class} must implement #process_game_specific_data"
end
|
#process_room_display(alt_string) ⇒ Object
79
80
81
|
# File 'documented/games.rb', line 79
def process_room_display(alt_string)
raise NotImplementedError, "#{self.class} must implement #process_room_display"
end
|