qwtf_discord_bot 6.2.0 → 6.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bfa9a0b1f5ad3c3206d216e1e266d2749e081c6dc3c58e77994ec997f64fe2f
4
- data.tar.gz: 215a86a21d79da634525e031ad7408ad0f1c2b3ee2eced49ec2dc9f7dfffd8f1
3
+ metadata.gz: ce51af5b4d0cad9d10f44446ef2191b99188a17a1f5f4c7a460a7b8e64c91a2e
4
+ data.tar.gz: cbffbf577b7a3f61ea59d6ec18fa2a4a8cecae8dab8e6c9409e0892907bb5aea
5
5
  SHA512:
6
- metadata.gz: b206b70ee1b67653022619909db86705c05f08006cc712179d00ec30b556fb64ea901f164395c7f8ad35649bf5c67a082f858d46b50fae4c4ee690be5b194ae6
7
- data.tar.gz: 8174cd63f0589c839a2a47509d8de220d7ef8b96c82fec9b38501a4bdac56000767c0425a8b55c10d858e8c5b0d919f8a7763a680775316ae1ef286818b6380a
6
+ metadata.gz: 8e0a30ef32c41f1c7514ff78c3ac025ad771cdcd56758e86fe88ab4211836a0a01477db6c28ceadd393f55e358e26e97f1efaa41f413226fce666f3679dbac0f
7
+ data.tar.gz: 335081f9a5318c1a3ad4fc3bd03e97c6f260497f188c55d2783c033c230bc26b74a1ac207300d99601f3560e4834ce614b213bd5bcce8aab728e4928b76b9a62
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qwtf_discord_bot (6.2.0)
4
+ qwtf_discord_bot (6.2.1)
5
5
  activesupport (~> 6.1)
6
6
  discordrb (= 3.4.0)
7
7
  redis (~> 4.2)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.2.0
1
+ 6.2.1
@@ -117,7 +117,6 @@ class QwtfDiscordBotPug # :nodoc:
117
117
  pug.maxplayers
118
118
  ].join("/")
119
119
 
120
-
121
120
  send_embedded_message(
122
121
  message: message,
123
122
  description: [errors, description.join(MSG_SNIPPET_DELIMITER)].join("\n"),
@@ -825,7 +824,23 @@ class QwtfDiscordBotPug # :nodoc:
825
824
  ) && nil
826
825
  end
827
826
  else
828
- teams = combinations.sample
827
+ weighted_combinations = combinations.map.with_index do |combination, index|
828
+ { weight: 1/(index+1.0), combination: combination }
829
+ end
830
+
831
+ total = weighted_combinations.inject(0) do |sum, wt|
832
+ sum + wt[:weight]
833
+ end
834
+
835
+ chosen_weighted_team_index = rand(0..total)
836
+ counter = 0.0
837
+
838
+ weighted_combination = weighted_combinations.find do |wt|
839
+ counter += wt[:weight]
840
+ chosen_weighted_team_index <= counter
841
+ end
842
+
843
+ teams = weighted_combination[:combination]
829
844
  end
830
845
 
831
846
  pug.destroy_teams
@@ -881,49 +896,17 @@ class QwtfDiscordBotPug # :nodoc:
881
896
  end
882
897
 
883
898
  def start_pug(pug, event)
884
- footer = [
885
- pug.game_map,
886
- "#{pug.player_slots} joined",
887
- ].compact.join(MSG_SNIPPET_DELIMITER)
888
-
889
899
  mentions = pug.players.map do |player_id|
890
900
  event.mention_for(player_id)
891
901
  end
892
902
 
893
- mention_line = "`!choose`, `!shuffle` or `!team` up. #{mentions.join(" ")}"
903
+ mention_line = mentions.join(" ")
894
904
 
895
905
  send_embedded_message(
896
906
  message: mention_line,
897
- channel: event.channel
898
- ) do |embed|
899
- embed.footer = Discordrb::Webhooks::EmbedFooter.new(
900
- text: footer
901
- )
902
-
903
- if pug.queued_players.any?
904
- queue_display_names = pug.queued_players.map do |player_id|
905
- event.display_name_for(player_id)
906
- end
907
-
908
- embed.add_field(
909
- inline: true,
910
- name: "Queue",
911
- value: queue_display_names.join("\n")
912
- )
913
- end
914
-
915
- pug.teams.each do |team_no, player_ids|
916
- team_mentions = player_ids.map do |player_id|
917
- event.display_name_for(player_id)
918
- end
919
-
920
- embed.add_field(
921
- inline: true,
922
- name: team_name(team_no),
923
- value: team_mentions.join("\n")
924
- )
925
- end
926
- end
907
+ channel: event.channel,
908
+ description: "Time to play. `!choose`, `!shuffle` or `!team` up."
909
+ )
927
910
  end
928
911
 
929
912
  def end_pug(pug, channel_id)
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: 6.2.0
4
+ version: 6.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Johnson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2021-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discordrb