kag-gather 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/kag/gather.rb +19 -3
- data/lib/kag/match.rb +23 -3
- data/lib/kag/server.rb +4 -0
- data/lib/kag/team.rb +20 -0
- data/lib/kag/version.rb +1 -1
- metadata +1 -1
data/lib/kag/gather.rb
CHANGED
@@ -34,7 +34,10 @@ module KAG
|
|
34
34
|
nick = nick.to_s
|
35
35
|
match = get_match_in(nick)
|
36
36
|
if match
|
37
|
-
match.remove_player(nick)
|
37
|
+
sub = match.remove_player(nick)
|
38
|
+
if sub
|
39
|
+
m.channel.msg sub[:msg]
|
40
|
+
end
|
38
41
|
elsif @queue.key?(nick)
|
39
42
|
remove_user_from_queue(nick)
|
40
43
|
end
|
@@ -51,6 +54,19 @@ module KAG
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
57
|
+
match "sub", :method => :evt_sub
|
58
|
+
def evt_sub(m)
|
59
|
+
@matches.each do |k,match|
|
60
|
+
if match.needs_sub?
|
61
|
+
placement = match.sub_in(m.user.nick)
|
62
|
+
if placement
|
63
|
+
reply m,placement[:channel_msg]
|
64
|
+
User(m.user.nick).send placement[:private_msg]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
54
70
|
match "add", :method => :evt_add
|
55
71
|
def evt_add(m)
|
56
72
|
add_user_to_queue(m,m.user.nick)
|
@@ -61,7 +77,7 @@ module KAG
|
|
61
77
|
match = get_match_in(m.user.nick)
|
62
78
|
if match
|
63
79
|
match.remove_player(m.user.nick)
|
64
|
-
send_channels_msg "#{nick} has left the match at #{match.server[:key]}!
|
80
|
+
send_channels_msg "#{m.user.nick} has left the match at #{match.server[:key]}! You can sub in by typing !sub"
|
65
81
|
elsif @queue.key?(m.user.nick)
|
66
82
|
unless remove_user_from_queue(m.user.nick)
|
67
83
|
debug "#{nick} is not in the queue."
|
@@ -279,7 +295,7 @@ module KAG
|
|
279
295
|
def evt_restart(m)
|
280
296
|
if is_admin(m.user)
|
281
297
|
cmd = (KAG::Config.instance[:restart_method] or "nohup sh gather.sh &")
|
282
|
-
|
298
|
+
debug cmd
|
283
299
|
pid = spawn cmd
|
284
300
|
debug "Restarting bot, new process ID is #{pid.to_s} ..."
|
285
301
|
exit
|
data/lib/kag/match.rb
CHANGED
@@ -42,6 +42,7 @@ module KAG
|
|
42
42
|
|
43
43
|
def start
|
44
44
|
self[:end_votes] = 0 unless self[:end_votes]
|
45
|
+
self[:subs_needed] = []
|
45
46
|
setup_teams
|
46
47
|
restart_map
|
47
48
|
end
|
@@ -115,10 +116,29 @@ module KAG
|
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
118
|
-
def remove_player
|
119
|
-
|
120
|
-
|
119
|
+
def remove_player(nick)
|
120
|
+
sub = false
|
121
|
+
self[:teams].each do |team|
|
122
|
+
if team.has_player?(nick)
|
123
|
+
sub = team.remove_player(nick)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
if sub
|
127
|
+
self[:subs_needed] << sub
|
128
|
+
end
|
129
|
+
sub
|
130
|
+
end
|
131
|
+
|
132
|
+
def needs_sub?
|
133
|
+
self[:subs_needed].length > 0
|
134
|
+
end
|
135
|
+
|
136
|
+
def sub_in(nick)
|
137
|
+
placement = false
|
138
|
+
if needs_sub?
|
139
|
+
placement = self[:subs_needed].shift
|
121
140
|
end
|
141
|
+
placement
|
122
142
|
end
|
123
143
|
|
124
144
|
def rename_player(last_nick,new_nick)
|
data/lib/kag/server.rb
CHANGED
@@ -27,6 +27,10 @@ module KAG
|
|
27
27
|
self[:_socket]
|
28
28
|
end
|
29
29
|
|
30
|
+
def text_join
|
31
|
+
"Join \x0305#{self[:key]} - #{self[:ip]}:#{self[:port]} \x0306password #{self[:password]}\x0301 | Visit kag://#{self[:ip]}/#{self[:password]}"
|
32
|
+
end
|
33
|
+
|
30
34
|
def connect
|
31
35
|
return true if self.connected?
|
32
36
|
puts "[RCON] Attempting to get socket"
|
data/lib/kag/team.rb
CHANGED
@@ -53,6 +53,26 @@ module KAG
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def remove_player(nick)
|
57
|
+
if has_player?(nick)
|
58
|
+
sub = {}
|
59
|
+
sub[:cls] = self[:players][nick]
|
60
|
+
sub[:team] = self.clone
|
61
|
+
sub[:msg] = "Sub needed at #{self.match.server[:ip]} for #{sub[:team]}, #{sub[:cls]} Class! Type !sub to claim it!"
|
62
|
+
sub[:channel_msg] = "#{nick} is now subbing in for #{self[:name]} at #{self.match.server[:key]}. Subs still needed: #{self.match[:subs_needed].length}"
|
63
|
+
sub[:private_msg] = "Please #{self.match.server.text_join} | #{sub[:cls]} on the #{self[:name]} Team"
|
64
|
+
self[:players].delete(nick)
|
65
|
+
|
66
|
+
if self.match and self.match.server
|
67
|
+
self.match.server.kick(nick)
|
68
|
+
end
|
69
|
+
|
70
|
+
sub
|
71
|
+
else
|
72
|
+
false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
56
76
|
def kick_all
|
57
77
|
self[:players].each do |nick,cls|
|
58
78
|
self.match.server.kick(nick.to_s)
|
data/lib/kag/version.rb
CHANGED