Skip to content

Commit 2a666b4

Browse files
Merge pull request #7 from taylorfinnell/add-num-winners-words
Add num winners words
2 parents 7f5418e + 8452a99 commit 2a666b4

File tree

6 files changed

+84
-850
lines changed

6 files changed

+84
-850
lines changed

shard.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: hqtrivia
2-
version: 0.2.7
2+
version: 0.2.8
33

44
authors:
55
- Taylor Finnell <[email protected]>
66

7-
crystal: 0.27.0
7+
crystal: 0.27.1
88

99
license: MIT
1010

spec/data/words

+64-838
Large diffs are not rendered by default.

spec/hqtrivia/bot_spec.cr

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ class WordsBot
2424
getter round_starts
2525
getter round_ends
2626
getter reveals
27+
getter num_winners
2728

2829
def initialize(@show : HqTrivia::Model::Show, @coordinator : HqTrivia::Coordinator)
2930
super
3031
@round_starts = 0
3132
@round_ends = 0
3233
@reveals = 0
34+
@num_winners = 0
3335
end
3436

3537
def handle_message(message : HqTrivia::Model::StartRound)
@@ -43,6 +45,10 @@ class WordsBot
4345
def handle_message(message : HqTrivia::Model::LetterReveal)
4446
@reveals += 1
4547
end
48+
49+
def handle_message(message : HqTrivia::Model::WordsGameResult)
50+
@num_winners = message.num_winners
51+
end
4652
end
4753

4854
module HqTrivia
@@ -70,9 +76,10 @@ module HqTrivia
7076
bot = WordsBot.new(show, LocalCoordinator.new("us"))
7177
bot.play(connection)
7278

73-
bot.reveals.should eq(16)
74-
bot.round_starts.should eq(8)
75-
bot.round_ends.should eq(8)
79+
bot.reveals.should eq(20)
80+
bot.round_starts.should eq(10)
81+
bot.round_ends.should eq(10)
82+
bot.num_winners.should eq(5827)
7683
end
7784
end
7885
end

src/hqtrivia/auth.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module HqTrivia
2323

2424
private def header_others(country)
2525
HTTP::Headers{
26-
"Authorization" => "Bearer #{token(country)}",
26+
"Authorization" => "Bearer #{token(country)}",
2727
}
2828
end
2929

src/hqtrivia/model/words_game_result.cr

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ module HqTrivia
55
include WebSocketMessage
66

77
JSON.mapping({
8-
type: String,
9-
show_id: {key: "showId", type: Int32},
10-
winners: Array(Winner),
11-
c: Int32,
12-
sent: Time,
8+
type: String,
9+
show_id: {key: "showId", type: Int32},
10+
winners: Array(Winner),
11+
num_winners: {key: "numWinners", type: Int32},
12+
c: Int32,
13+
sent: Time,
1314
})
1415

1516
# Winner information

src/hqtrivia/version.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module HqTrivia
22
# Current HqTrivia version
3-
VERSION = "0.2.7"
3+
VERSION = "0.2.8"
44
end

0 commit comments

Comments
 (0)