qwtf_discord_bot 5.5.10 → 5.5.15
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/pug.rb +9 -0
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +35 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b813d466ddbf8c36a783f042850df267dc0669497e109abd2216c32a39c6e41e
|
4
|
+
data.tar.gz: 2fc6dcf207ed665bc51a5a54d1173512236eca9842a7998e270d6f21f6cad70d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b856f195e9ec4e47c660d7463192a76ba669d58216edea8b7bc93e2a9e9ded6283de6183ebdf8bc526e88c092fd9d0637d39a6286dbd83d5264ab059aba18081
|
7
|
+
data.tar.gz: 15fb7c42819c3cff35a02b2971502225b8218b442277cbcf042fd20d31756638b1e073f374169c59b7e3c084311cc844a0f731efff98f89e68b6122a1009153a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.5.
|
1
|
+
5.5.15
|
data/lib/pug.rb
CHANGED
@@ -16,6 +16,7 @@ class Pug
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def join_team(team_no:, player_id:)
|
19
|
+
redis.setnx(pug_key, Time.now.to_i)
|
19
20
|
leave_teams(player_id)
|
20
21
|
redis.sadd(team_key(team_no), player_id)
|
21
22
|
end
|
@@ -146,6 +147,14 @@ class Pug
|
|
146
147
|
redis.get(last_result_time_key).to_i
|
147
148
|
end
|
148
149
|
|
150
|
+
def equal_number_of_players_on_each_team?
|
151
|
+
team_player_counts = actual_teams.map do |_name, players|
|
152
|
+
players.size
|
153
|
+
end
|
154
|
+
|
155
|
+
team_player_counts.uniq.size == 1
|
156
|
+
end
|
157
|
+
|
149
158
|
private
|
150
159
|
|
151
160
|
def leave_teams(player_id)
|
@@ -46,6 +46,13 @@ class QwtfDiscordBotPug # :nodoc:
|
|
46
46
|
|
47
47
|
bot.command :choose do |event, *args|
|
48
48
|
setup_pug(event) do |e, pug|
|
49
|
+
if pug.joined_players.count > pug.maxplayers
|
50
|
+
return send_embedded_message(
|
51
|
+
description: "Too many players, increase `!teamsize` or `!kick` extras",
|
52
|
+
channel: event.channel
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
49
56
|
if pug.joined_players.count.odd?
|
50
57
|
return send_embedded_message(
|
51
58
|
description: "Can't choose teams with odd number of players",
|
@@ -240,7 +247,13 @@ class QwtfDiscordBotPug # :nodoc:
|
|
240
247
|
)
|
241
248
|
end
|
242
249
|
|
243
|
-
|
250
|
+
if pug.team(team_no).size >= pug.teamsize
|
251
|
+
return send_embedded_message(
|
252
|
+
description: "Team is full",
|
253
|
+
channel: e.channel
|
254
|
+
)
|
255
|
+
end
|
256
|
+
|
244
257
|
pug.join_team(team_no: team_no, player_id: user_id)
|
245
258
|
|
246
259
|
send_embedded_message(
|
@@ -252,6 +265,13 @@ class QwtfDiscordBotPug # :nodoc:
|
|
252
265
|
)
|
253
266
|
else
|
254
267
|
args[1..-1].each do |mention|
|
268
|
+
if pug.team(team_no).size >= pug.teamsize
|
269
|
+
return send_embedded_message(
|
270
|
+
description: "Team is full",
|
271
|
+
channel: e.channel
|
272
|
+
)
|
273
|
+
end
|
274
|
+
|
255
275
|
unless mention.match(/<@!\d+>/)
|
256
276
|
send_embedded_message(
|
257
277
|
description: "#{arg} isn't a valid mention",
|
@@ -356,6 +376,13 @@ class QwtfDiscordBotPug # :nodoc:
|
|
356
376
|
)
|
357
377
|
end
|
358
378
|
|
379
|
+
if !pug.equal_number_of_players_on_each_team?
|
380
|
+
return send_embedded_message(
|
381
|
+
description: "Can't report unless teams have same number of players",
|
382
|
+
channel: event.channel
|
383
|
+
)
|
384
|
+
end
|
385
|
+
|
359
386
|
unless ["1", "2"].any?(args.first)
|
360
387
|
return send_embedded_message(
|
361
388
|
description: "Invalid team number",
|
@@ -429,6 +456,13 @@ class QwtfDiscordBotPug # :nodoc:
|
|
429
456
|
)
|
430
457
|
end
|
431
458
|
|
459
|
+
if !pug.equal_number_of_players_on_each_team?
|
460
|
+
return send_embedded_message(
|
461
|
+
description: "Can't report unless teams have same number of players",
|
462
|
+
channel: event.channel
|
463
|
+
)
|
464
|
+
end
|
465
|
+
|
432
466
|
if pug.actual_teams.count < 2
|
433
467
|
return send_embedded_message(
|
434
468
|
description: "There must be at least two teams with players to submit a result",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qwtf_discord_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.5.
|
4
|
+
version: 5.5.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheldon Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|