console-poker 1.0.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.
- checksums.yaml +7 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +89 -0
- data/LICENSE +21 -0
- data/README.md +25 -0
- data/Rakefile +5 -0
- data/bin/console-poker +5 -0
- data/console-poker.gemspec +26 -0
- data/lib/poker/card.rb +34 -0
- data/lib/poker/deck.rb +75 -0
- data/lib/poker/format.rb +8 -0
- data/lib/poker/hand.rb +141 -0
- data/lib/poker/hand_ranker.rb +87 -0
- data/lib/poker/menus.rb +71 -0
- data/lib/poker/utils.rb +44 -0
- data/lib/poker.rb +98 -0
- data/poker.txt +1 -0
- data/spec/factories/card_factory.rb +79 -0
- data/spec/factories/deck_factory.rb +14 -0
- data/spec/factories/hand_factory.rb +131 -0
- data/spec/factories/poker_factory.rb +17 -0
- data/spec/lib/poker/card_spec.rb +44 -0
- data/spec/lib/poker/deck_spec.rb +114 -0
- data/spec/lib/poker/format_spec.rb +10 -0
- data/spec/lib/poker/hand_ranker_spec.rb +130 -0
- data/spec/lib/poker/hand_spec.rb +277 -0
- data/spec/lib/poker_spec.rb +536 -0
- data/spec/spec_helper.rb +35 -0
- data/ss1.png +0 -0
- data/ss2.png +0 -0
- data/tags +73 -0
- metadata +79 -0
@@ -0,0 +1,536 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Poker do
|
4
|
+
let(:hand) { build(:hand, poker:) }
|
5
|
+
let(:deck) { build(:deck, :new_regular) }
|
6
|
+
let(:poker) { build(:poker, deck:) }
|
7
|
+
let(:input) { StringIO.new }
|
8
|
+
|
9
|
+
describe '.new' do
|
10
|
+
it 'creates a poker' do
|
11
|
+
expect(poker).to be
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#save_game' do
|
16
|
+
let(:file) { instance_double(File) }
|
17
|
+
|
18
|
+
before do
|
19
|
+
allow(File).to receive(:open).with(SAVE_FILE, 'w').and_yield(file)
|
20
|
+
allow(file).to receive(:puts)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'opens and put save file data' do
|
24
|
+
poker.save_game
|
25
|
+
expected = %i[deck_type face_type money current_bet].map do |f|
|
26
|
+
poker.send(f)
|
27
|
+
end.join('|')
|
28
|
+
expect(file).to have_received(:puts).with(expected)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#load_game' do
|
33
|
+
context 'with a unreadable save file' do
|
34
|
+
it 'fails to load save file' do
|
35
|
+
allow(File).to receive(:read).with(SAVE_FILE)
|
36
|
+
allow(File).to receive(:readable?).with(SAVE_FILE).and_return(false)
|
37
|
+
|
38
|
+
poker.load_game
|
39
|
+
expect(File).to_not have_received(:read).with(SAVE_FILE)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with a readabale save file' do
|
44
|
+
before do
|
45
|
+
allow(File).to receive(:readable?).with(SAVE_FILE).and_return(true)
|
46
|
+
allow(File).to receive(:read).with(SAVE_FILE).and_return('8|1|2000|1000')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'loads deck_type from save file data' do
|
50
|
+
poker.load_game
|
51
|
+
expect(poker.deck_type).to eq(8)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'loads face_type from save file data' do
|
55
|
+
poker.load_game
|
56
|
+
expect(poker.face_type).to eq(1)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'loads money from save file data' do
|
60
|
+
poker.load_game
|
61
|
+
expect(poker.money).to eq(2000)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'loads current_bet from save file data' do
|
65
|
+
poker.load_game
|
66
|
+
expect(poker.current_bet).to eq(1000)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#getc' do
|
72
|
+
it 'get a single character from stdin' do
|
73
|
+
allow(input).to receive(:getc).and_return('q')
|
74
|
+
c = described_class.getc(input)
|
75
|
+
expect(c).to eq('q')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#normalize_current_bet' do
|
80
|
+
it 'reduces the current bet to money' do
|
81
|
+
poker.current_bet = poker.money + 1
|
82
|
+
poker.normalize_current_bet
|
83
|
+
expect(poker.current_bet).to eq(poker.money)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'reduces the current bet to MAX_BET' do
|
87
|
+
poker.money = MAX_BET + 1
|
88
|
+
poker.current_bet = MAX_BET + 1
|
89
|
+
poker.normalize_current_bet
|
90
|
+
expect(poker.current_bet).to eq(MAX_BET)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'increases the current bet to MIN_BET' do
|
94
|
+
poker.current_bet = MIN_BET - 1
|
95
|
+
poker.normalize_current_bet
|
96
|
+
expect(poker.current_bet).to eq(MIN_BET)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#clear' do
|
101
|
+
it 'calls system' do
|
102
|
+
ENV['CLEAR_TERM'] = '1'
|
103
|
+
allow(poker).to receive(:system)
|
104
|
+
poker.clear
|
105
|
+
expect(poker).to have_received(:system).with('export TERM=linux; clear')
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'does not call system' do
|
109
|
+
ENV['CLEAR_TERM'] = '0'
|
110
|
+
allow(poker).to receive(:system)
|
111
|
+
poker.clear
|
112
|
+
expect(poker).to_not have_received(:system)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#run' do
|
117
|
+
let(:hand) { build(:hand, poker:) }
|
118
|
+
|
119
|
+
before do
|
120
|
+
allow(poker).to receive(:hand).and_return(hand)
|
121
|
+
allow(poker).to receive(:load_game)
|
122
|
+
allow(Deck).to receive(:new)
|
123
|
+
allow(poker).to receive(:deal_new_hand)
|
124
|
+
allow(poker).to receive(:puts)
|
125
|
+
allow(described_class).to receive(:getc).and_return('q')
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'loads saved game' do
|
129
|
+
poker.run
|
130
|
+
expect(poker).to have_received(:load_game)
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'creates a new deck' do
|
134
|
+
poker.run
|
135
|
+
expect(Deck).to have_received(:new)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'deals a new hand' do
|
139
|
+
poker.run
|
140
|
+
expect(poker).to have_received(:deal_new_hand)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#build_new_hand' do
|
145
|
+
before do
|
146
|
+
poker.build_new_hand
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'player hand has two cards' do
|
150
|
+
expect(poker.hand.cards.size).to eq(5)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#deal_new_hand' do
|
155
|
+
let(:hand) { build(:hand, :unknown, poker:) }
|
156
|
+
|
157
|
+
before do
|
158
|
+
allow(poker).to receive(:hand).and_return(hand)
|
159
|
+
allow(poker).to receive(:draw_hand)
|
160
|
+
allow(hand).to receive(:puts)
|
161
|
+
allow(described_class).to receive(:getc).and_return('x')
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when shuffling may be required' do
|
165
|
+
before do
|
166
|
+
allow(poker).to receive(:build_new_hand)
|
167
|
+
allow(poker.deck).to receive(:new_regular)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'shuffles' do
|
171
|
+
poker.deal_new_hand
|
172
|
+
expect(poker.deck).to have_received(:new_regular)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'when the player hand is already payed' do
|
177
|
+
before do
|
178
|
+
allow(poker).to receive(:build_new_hand)
|
179
|
+
allow(hand).to receive(:ask_hand_action)
|
180
|
+
allow(poker).to receive(:save_game)
|
181
|
+
allow(hand).to receive(:result).and_return(true)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'hands are drawn' do
|
185
|
+
poker.deal_new_hand
|
186
|
+
expect(poker).to have_received(:draw_hand)
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'bet options are drawn' do
|
190
|
+
poker.deal_new_hand
|
191
|
+
expect(poker).to have_received(:save_game)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe '#new_bet' do
|
197
|
+
before do
|
198
|
+
allow(input).to receive(:gets).and_return('10')
|
199
|
+
allow(described_class).to receive(:getc).and_return('s', 'q')
|
200
|
+
allow(poker).to receive(:print)
|
201
|
+
allow(poker).to receive(:puts)
|
202
|
+
allow(poker).to receive(:deal_new_hand)
|
203
|
+
allow(poker).to receive(:clear)
|
204
|
+
allow(poker).to receive(:draw_hand)
|
205
|
+
allow(poker).to receive(:normalize_current_bet)
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'clears the screen' do
|
209
|
+
poker.new_bet(input)
|
210
|
+
expect(poker).to have_received(:clear)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'draws hands' do
|
214
|
+
poker.new_bet(input)
|
215
|
+
expect(poker).to have_received(:draw_hand)
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'draws the current bet' do
|
219
|
+
poker.new_bet(input)
|
220
|
+
expected = " Current Bet: $5.00\n"
|
221
|
+
expect(poker).to have_received(:puts).with(expected)
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'updates current bet' do
|
225
|
+
poker.new_bet(input)
|
226
|
+
expect(poker.current_bet).to eq(1000)
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'normalizes the bet' do
|
230
|
+
poker.new_bet(input)
|
231
|
+
expect(poker).to have_received(:normalize_current_bet)
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'deals a new hand' do
|
235
|
+
poker.new_bet(input)
|
236
|
+
expect(poker).to have_received(:deal_new_hand)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe '#draw_bet_options' do
|
241
|
+
before do
|
242
|
+
allow(poker).to receive(:puts)
|
243
|
+
end
|
244
|
+
|
245
|
+
context 'when dealing a new hand' do
|
246
|
+
it 'deals a new hand' do
|
247
|
+
allow(described_class).to receive(:getc).and_return('d')
|
248
|
+
allow(poker).to receive(:deal_new_hand)
|
249
|
+
poker.draw_bet_options
|
250
|
+
expect(poker).to have_received(:deal_new_hand)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'when updating current bet' do
|
255
|
+
it 'deals a new hand' do
|
256
|
+
allow(described_class).to receive(:getc).and_return('b')
|
257
|
+
allow(poker).to receive(:new_bet)
|
258
|
+
poker.draw_bet_options
|
259
|
+
expect(poker).to have_received(:new_bet)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
context 'when updating poker options' do
|
264
|
+
before do
|
265
|
+
poker.hand = hand
|
266
|
+
allow(described_class).to receive(:getc).and_return('o')
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'draws poker options' do
|
270
|
+
allow(poker).to receive(:draw_game_options)
|
271
|
+
poker.draw_bet_options
|
272
|
+
expect(poker).to have_received(:draw_game_options)
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'draws hands' do
|
276
|
+
allow(poker).to receive(:draw_game_options)
|
277
|
+
allow(poker).to receive(:draw_hand)
|
278
|
+
poker.draw_bet_options
|
279
|
+
expect(poker).to have_received(:draw_hand)
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'clears the screen' do
|
283
|
+
allow(poker).to receive(:draw_game_options)
|
284
|
+
allow(poker).to receive(:draw_hand)
|
285
|
+
allow(poker).to receive(:clear)
|
286
|
+
poker.draw_bet_options
|
287
|
+
expect(poker).to have_received(:clear)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
context 'when quitting' do
|
292
|
+
it 'clears the screen and exits' do
|
293
|
+
allow(described_class).to receive(:getc).and_return('q')
|
294
|
+
poker.draw_bet_options
|
295
|
+
expect(poker.quitting).to be_truthy
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
context 'when invalid input' do
|
300
|
+
it 'gets the action again' do
|
301
|
+
poker.hand = hand
|
302
|
+
allow(described_class).to receive(:getc).and_return('x', 'q')
|
303
|
+
poker.draw_bet_options
|
304
|
+
expect(poker.quitting).to be_truthy
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe '#new_face_type' do
|
310
|
+
before do
|
311
|
+
poker.hand = hand
|
312
|
+
allow(poker).to receive(:puts)
|
313
|
+
end
|
314
|
+
|
315
|
+
context 'when choosing a new face type' do
|
316
|
+
it 'draws options' do
|
317
|
+
allow(described_class).to receive(:getc).and_return('1')
|
318
|
+
poker.new_face_type
|
319
|
+
expected = ' (1) 🂡 (2) A♠'
|
320
|
+
expect(poker).to have_received(:puts).with(expected)
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'sets regular faces' do
|
324
|
+
allow(described_class).to receive(:getc).and_return('1')
|
325
|
+
allow(poker).to receive(:save_game)
|
326
|
+
allow(poker).to receive(:face_type=).with(1)
|
327
|
+
poker.new_face_type
|
328
|
+
expect(poker).to have_received(:face_type=).with(1)
|
329
|
+
expect(poker).to have_received(:save_game)
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'sets alternate faces' do
|
333
|
+
allow(described_class).to receive(:getc).and_return('2')
|
334
|
+
allow(poker).to receive(:save_game)
|
335
|
+
allow(poker).to receive(:face_type=).with(2)
|
336
|
+
poker.new_face_type
|
337
|
+
expect(poker).to have_received(:face_type=).with(2)
|
338
|
+
expect(poker).to have_received(:save_game)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
context 'when invalid input' do
|
343
|
+
it 'gets the action again' do
|
344
|
+
poker.hand = hand
|
345
|
+
allow(described_class).to receive(:getc).and_return('x', '1')
|
346
|
+
allow(poker).to receive(:face_type=).with(1)
|
347
|
+
poker.new_face_type
|
348
|
+
expect(poker.face_type).to eq(1)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
describe '#new_deck_type' do
|
354
|
+
before do
|
355
|
+
poker.hand = hand
|
356
|
+
allow(poker).to receive(:puts)
|
357
|
+
allow(poker).to receive(:save_game)
|
358
|
+
end
|
359
|
+
|
360
|
+
context 'when choosing a new deck type' do
|
361
|
+
it 'draws options' do
|
362
|
+
allow(described_class).to receive(:getc).and_return('1')
|
363
|
+
poker.new_deck_type
|
364
|
+
expected = ' (1) Regular (2) Aces (3) Jacks (4) Aces & Jacks (5) Sevens (6) Eights'
|
365
|
+
expect(poker).to have_received(:puts).with(expected)
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'builds a new regular' do
|
369
|
+
allow(described_class).to receive(:getc).and_return('1')
|
370
|
+
allow(poker.deck).to receive(:new_regular)
|
371
|
+
poker.new_deck_type
|
372
|
+
expect(poker.deck).to have_received(:new_regular)
|
373
|
+
expect(poker).to have_received(:save_game)
|
374
|
+
end
|
375
|
+
|
376
|
+
it 'builds a new aces' do
|
377
|
+
allow(described_class).to receive(:getc).and_return('2')
|
378
|
+
allow(poker.deck).to receive(:new_aces)
|
379
|
+
poker.new_deck_type
|
380
|
+
expect(poker.deck).to have_received(:new_aces)
|
381
|
+
expect(poker).to have_received(:save_game)
|
382
|
+
end
|
383
|
+
|
384
|
+
it 'builds a new jacks' do
|
385
|
+
allow(described_class).to receive(:getc).and_return('3')
|
386
|
+
allow(poker.deck).to receive(:new_jacks)
|
387
|
+
poker.new_deck_type
|
388
|
+
expect(poker.deck).to have_received(:new_jacks)
|
389
|
+
expect(poker).to have_received(:save_game)
|
390
|
+
end
|
391
|
+
|
392
|
+
it 'builds a new aces_jacks' do
|
393
|
+
allow(described_class).to receive(:getc).and_return('4')
|
394
|
+
allow(poker.deck).to receive(:new_aces_jacks)
|
395
|
+
poker.new_deck_type
|
396
|
+
expect(poker.deck).to have_received(:new_aces_jacks)
|
397
|
+
expect(poker).to have_received(:save_game)
|
398
|
+
end
|
399
|
+
|
400
|
+
it 'builds a new sevens' do
|
401
|
+
allow(described_class).to receive(:getc).and_return('5')
|
402
|
+
allow(poker.deck).to receive(:new_sevens)
|
403
|
+
poker.new_deck_type
|
404
|
+
expect(poker.deck).to have_received(:new_sevens)
|
405
|
+
expect(poker).to have_received(:save_game)
|
406
|
+
end
|
407
|
+
|
408
|
+
it 'builds a new eights' do
|
409
|
+
allow(described_class).to receive(:getc).and_return('6')
|
410
|
+
allow(poker.deck).to receive(:new_eights)
|
411
|
+
poker.new_deck_type
|
412
|
+
expect(poker.deck).to have_received(:new_eights)
|
413
|
+
expect(poker).to have_received(:save_game)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
context 'when invalid input' do
|
418
|
+
it 'gets the action again' do
|
419
|
+
poker.hand = hand
|
420
|
+
allow(described_class).to receive(:getc).and_return('x', '1')
|
421
|
+
allow(poker).to receive(:deck_type=).with(1)
|
422
|
+
poker.new_deck_type
|
423
|
+
expect(poker.deck_type).to eq(1)
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
describe '#draw_game_options' do
|
429
|
+
before do
|
430
|
+
poker.hand = hand
|
431
|
+
end
|
432
|
+
|
433
|
+
context 'when updating the deck type' do
|
434
|
+
before do
|
435
|
+
allow(described_class).to receive(:getc).and_return('t')
|
436
|
+
allow(poker).to receive(:clear)
|
437
|
+
allow(poker).to receive(:draw_hand)
|
438
|
+
allow(poker).to receive(:new_deck_type)
|
439
|
+
allow(poker).to receive(:draw_bet_options)
|
440
|
+
allow(poker).to receive(:puts)
|
441
|
+
end
|
442
|
+
|
443
|
+
it 'clears the screen' do
|
444
|
+
poker.draw_game_options
|
445
|
+
expect(poker).to have_received(:clear).twice
|
446
|
+
end
|
447
|
+
|
448
|
+
it 'draws the hands' do
|
449
|
+
poker.draw_game_options
|
450
|
+
expect(poker).to have_received(:draw_hand).twice
|
451
|
+
end
|
452
|
+
|
453
|
+
it 'updates deck type' do
|
454
|
+
poker.draw_game_options
|
455
|
+
expect(poker).to have_received(:new_deck_type)
|
456
|
+
end
|
457
|
+
|
458
|
+
it 'draws the bet options' do
|
459
|
+
poker.draw_game_options
|
460
|
+
expect(poker).to have_received(:draw_bet_options)
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
context 'when updating the face type' do
|
465
|
+
before do
|
466
|
+
allow(described_class).to receive(:getc).and_return('f')
|
467
|
+
allow(poker).to receive(:clear)
|
468
|
+
allow(poker).to receive(:draw_hand)
|
469
|
+
allow(poker).to receive(:new_face_type)
|
470
|
+
allow(poker).to receive(:draw_bet_options)
|
471
|
+
allow(poker).to receive(:puts)
|
472
|
+
end
|
473
|
+
|
474
|
+
it 'clears the screen' do
|
475
|
+
poker.draw_game_options
|
476
|
+
expect(poker).to have_received(:clear).twice
|
477
|
+
end
|
478
|
+
|
479
|
+
it 'draws the hands' do
|
480
|
+
poker.draw_game_options
|
481
|
+
expect(poker).to have_received(:draw_hand).twice
|
482
|
+
end
|
483
|
+
|
484
|
+
it 'updates face type' do
|
485
|
+
poker.draw_game_options
|
486
|
+
expect(poker).to have_received(:new_face_type)
|
487
|
+
end
|
488
|
+
|
489
|
+
it 'draws the bet options' do
|
490
|
+
poker.draw_game_options
|
491
|
+
expect(poker).to have_received(:draw_bet_options)
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
context 'when going back to previous menu' do
|
496
|
+
before do
|
497
|
+
allow(described_class).to receive(:getc).and_return('b')
|
498
|
+
allow(poker).to receive(:clear)
|
499
|
+
allow(poker).to receive(:draw_hand)
|
500
|
+
allow(poker).to receive(:draw_bet_options)
|
501
|
+
allow(poker).to receive(:puts)
|
502
|
+
end
|
503
|
+
|
504
|
+
it 'clears the screen' do
|
505
|
+
poker.draw_game_options
|
506
|
+
expect(poker).to have_received(:clear)
|
507
|
+
end
|
508
|
+
|
509
|
+
it 'draws the hands' do
|
510
|
+
poker.draw_game_options
|
511
|
+
expect(poker).to have_received(:draw_hand)
|
512
|
+
end
|
513
|
+
|
514
|
+
it 'draws the bet options' do
|
515
|
+
poker.draw_game_options
|
516
|
+
expect(poker).to have_received(:draw_bet_options)
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
context 'when invalid input' do
|
521
|
+
before do
|
522
|
+
allow(described_class).to receive(:getc).and_return('x', 'b')
|
523
|
+
allow(poker).to receive(:puts)
|
524
|
+
allow(poker).to receive(:new_bet)
|
525
|
+
allow(poker).to receive(:draw_bet_options)
|
526
|
+
allow(poker).to receive(:draw_hand)
|
527
|
+
end
|
528
|
+
|
529
|
+
it 'gets the action again' do
|
530
|
+
poker.draw_game_options
|
531
|
+
allow(poker).to receive(:draw_game_options)
|
532
|
+
expect(poker).to have_received(:draw_bet_options).twice
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
536
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter %r{/spec/}
|
6
|
+
enable_coverage :branch
|
7
|
+
primary_coverage :branch
|
8
|
+
end
|
9
|
+
|
10
|
+
Dir.glob(File.join(File.dirname(__FILE__),
|
11
|
+
"..#{File::SEPARATOR}lib", '**',
|
12
|
+
'*.rb')).each(&method(:require))
|
13
|
+
|
14
|
+
require 'factory_bot'
|
15
|
+
require 'pry'
|
16
|
+
|
17
|
+
ENV['CLEAR_TERM'] = '0'
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.include FactoryBot::Syntax::Methods
|
21
|
+
|
22
|
+
config.before(:suite) do
|
23
|
+
FactoryBot.find_definitions
|
24
|
+
end
|
25
|
+
|
26
|
+
config.expect_with :rspec do |expectations|
|
27
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
28
|
+
end
|
29
|
+
|
30
|
+
config.mock_with :rspec do |mocks|
|
31
|
+
mocks.verify_partial_doubles = true
|
32
|
+
end
|
33
|
+
|
34
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
35
|
+
end
|
data/ss1.png
ADDED
Binary file
|
data/ss2.png
ADDED
Binary file
|
data/tags
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
2
|
+
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
3
|
+
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
|
4
|
+
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
5
|
+
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
6
|
+
!_TAG_PROGRAM_VERSION 5.8 //
|
7
|
+
Card lib/poker/card.rb /^class Card$/;" c
|
8
|
+
Deck lib/poker/deck.rb /^class Deck$/;" c
|
9
|
+
Format lib/poker/format.rb /^module Format$/;" m
|
10
|
+
Hand lib/poker/hand.rb /^class Hand$/;" c
|
11
|
+
HandRanker lib/poker/hand_ranker.rb /^class HandRanker$/;" c
|
12
|
+
Menus lib/poker/menus.rb /^module Menus$/;" m
|
13
|
+
Poker lib/poker.rb /^class Poker$/;" c
|
14
|
+
Utils lib/poker/utils.rb /^module Utils$/;" m
|
15
|
+
ask_hand_action lib/poker/hand.rb /^ def ask_hand_action$/;" f class:Hand
|
16
|
+
build_new_hand lib/poker.rb /^ def build_new_hand$/;" f class:Poker
|
17
|
+
clear lib/poker.rb /^ def clear$/;" f class:Poker
|
18
|
+
clear_draw_hand lib/poker/utils.rb /^ def clear_draw_hand$/;" f class:Utils
|
19
|
+
clear_draw_hand_actions lib/poker/hand.rb /^ def clear_draw_hand_actions$/;" f class:Hand
|
20
|
+
clear_draw_hand_bet_options lib/poker/utils.rb /^ def clear_draw_hand_bet_options$/;" f class:Utils
|
21
|
+
clear_draw_hand_game_options lib/poker/utils.rb /^ def clear_draw_hand_game_options$/;" f class:Utils
|
22
|
+
clear_draw_hand_new_deck_type lib/poker/utils.rb /^ def clear_draw_hand_new_deck_type$/;" f class:Utils
|
23
|
+
clear_draw_hand_new_face_type lib/poker/utils.rb /^ def clear_draw_hand_new_face_type$/;" f class:Utils
|
24
|
+
deal_card lib/poker/hand.rb /^ def deal_card$/;" f class:Hand
|
25
|
+
deal_new_hand lib/poker.rb /^ def deal_new_hand$/;" f class:Poker
|
26
|
+
draw lib/poker/hand.rb /^ def draw$/;" f class:Hand
|
27
|
+
draw_bet_options lib/poker/menus.rb /^ def draw_bet_options$/;" f class:Menus
|
28
|
+
draw_card_selector lib/poker/hand.rb /^ def draw_card_selector$/;" f class:Hand
|
29
|
+
draw_cards lib/poker/hand.rb /^ def draw_cards$/;" f class:Hand
|
30
|
+
draw_game_options lib/poker/menus.rb /^ def draw_game_options$/;" f class:Menus
|
31
|
+
draw_hand lib/poker.rb /^ def draw_hand$/;" f class:Poker
|
32
|
+
draw_money lib/poker/hand.rb /^ def draw_money$/;" f class:Hand
|
33
|
+
faces lib/poker/card.rb /^ def self.faces$/;" F class:Card
|
34
|
+
faces2 lib/poker/card.rb /^ def self.faces2$/;" F class:Card
|
35
|
+
flush? lib/poker/hand_ranker.rb /^ def flush?$/;" f class:HandRanker
|
36
|
+
four_of_a_kind? lib/poker/hand_ranker.rb /^ def four_of_a_kind?$/;" f class:HandRanker
|
37
|
+
full_house? lib/poker/hand_ranker.rb /^ def full_house?$/;" f class:HandRanker
|
38
|
+
getc lib/poker.rb /^ def self.getc(input)$/;" F class:Poker
|
39
|
+
initialize lib/poker.rb /^ def initialize$/;" f class:Poker
|
40
|
+
initialize lib/poker/card.rb /^ def initialize(poker, value, suit)$/;" f class:Card
|
41
|
+
initialize lib/poker/deck.rb /^ def initialize(poker)$/;" f class:Deck
|
42
|
+
initialize lib/poker/hand.rb /^ def initialize(poker, bet)$/;" f class:Hand
|
43
|
+
initialize lib/poker/hand_ranker.rb /^ def initialize(hand)$/;" f class:HandRanker
|
44
|
+
load_game lib/poker/utils.rb /^ def load_game$/;" f class:Utils
|
45
|
+
money lib/poker/format.rb /^ def self.money(value)$/;" F class:Format
|
46
|
+
new_aces lib/poker/deck.rb /^ def new_aces$/;" f class:Deck
|
47
|
+
new_aces_jacks lib/poker/deck.rb /^ def new_aces_jacks$/;" f class:Deck
|
48
|
+
new_bet lib/poker.rb /^ def new_bet(input)$/;" f class:Poker
|
49
|
+
new_deck_type lib/poker/menus.rb /^ def new_deck_type$/;" f class:Menus
|
50
|
+
new_eights lib/poker/deck.rb /^ def new_eights$/;" f class:Deck
|
51
|
+
new_face_type lib/poker/menus.rb /^ def new_face_type$/;" f class:Menus
|
52
|
+
new_irregular lib/poker/deck.rb /^ def new_irregular(values = [])$/;" f class:Deck
|
53
|
+
new_jacks lib/poker/deck.rb /^ def new_jacks$/;" f class:Deck
|
54
|
+
new_regular lib/poker/deck.rb /^ def new_regular$/;" f class:Deck
|
55
|
+
new_sevens lib/poker/deck.rb /^ def new_sevens$/;" f class:Deck
|
56
|
+
next_card lib/poker/deck.rb /^ def next_card$/;" f class:Deck
|
57
|
+
normalize_current_bet lib/poker.rb /^ def normalize_current_bet$/;" f class:Poker
|
58
|
+
normalize_current_card lib/poker/hand.rb /^ def normalize_current_card$/;" f class:Hand
|
59
|
+
one_pair? lib/poker/hand_ranker.rb /^ def one_pair?$/;" f class:HandRanker
|
60
|
+
pay lib/poker/hand.rb /^ def pay$/;" f class:Hand
|
61
|
+
rank_display lib/poker/hand.rb /^ def rank_display$/;" f class:Hand
|
62
|
+
rank_hand lib/poker/hand_ranker.rb /^ def rank_hand$/;" f class:HandRanker
|
63
|
+
replace_discards lib/poker/hand.rb /^ def replace_discards$/;" f class:Hand
|
64
|
+
royal_flush? lib/poker/hand_ranker.rb /^ def royal_flush?$/;" f class:HandRanker
|
65
|
+
run lib/poker.rb /^ def run$/;" f class:Poker
|
66
|
+
save_game lib/poker/utils.rb /^ def save_game$/;" f class:Utils
|
67
|
+
shuffle lib/poker/deck.rb /^ def shuffle$/;" f class:Deck
|
68
|
+
straight? lib/poker/hand_ranker.rb /^ def straight?$/;" f class:HandRanker
|
69
|
+
straight_flush? lib/poker/hand_ranker.rb /^ def straight_flush?$/;" f class:HandRanker
|
70
|
+
three_of_a_kind? lib/poker/hand_ranker.rb /^ def three_of_a_kind?$/;" f class:HandRanker
|
71
|
+
to_s lib/poker/card.rb /^ def to_s$/;" f class:Card
|
72
|
+
two_pair? lib/poker/hand_ranker.rb /^ def two_pair?$/;" f class:HandRanker
|
73
|
+
uniq_count_one? lib/poker/hand_ranker.rb /^ def uniq_count_one?(array, *args)$/;" f class:HandRanker
|