console-blackjack 1.1.3 → 1.1.5
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/Gemfile +1 -1
- data/Gemfile.lock +46 -24
- data/README.md +1 -0
- data/bj.txt +1 -1
- data/console-blackjack-1.1.3.gem +0 -0
- data/console-blackjack-1.1.4.gem +0 -0
- data/console-blackjack.gemspec +2 -2
- data/lib/blackjack/player_hand.rb +6 -6
- data/lib/blackjack/shoe.rb +4 -4
- data/lib/blackjack.rb +1 -1
- data/spec/{lib/blackjack → blackjack}/player_hand_spec.rb +6 -6
- data/spec/{lib/blackjack_spec.rb → blackjack_spec.rb} +4 -6
- data/spec/factories/player_hand_factory.rb +1 -1
- metadata +13 -14
- data/console-blackjack-1.1.0.gem +0 -0
- data/console-blackjack-1.1.1.gem +0 -0
- data/console-blackjack-1.1.2.gem +0 -0
- /data/spec/{lib/blackjack → blackjack}/card_spec.rb +0 -0
- /data/spec/{lib/blackjack → blackjack}/dealer_hand_spec.rb +0 -0
- /data/spec/{lib/blackjack → blackjack}/format_spec.rb +0 -0
- /data/spec/{lib/blackjack → blackjack}/hand_spec.rb +0 -0
- /data/spec/{lib/blackjack → blackjack}/shoe_spec.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 980fc87d551f6423c15ec1c6f6396e23a0014130b925c74ba3218043f5e65842
|
4
|
+
data.tar.gz: 87452bf3571ee0468217cdd2d94e584ceb7318a0ee0ee10b9dd37e3fbab34948
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a36bcc5836b977fc57c6a1e3b6de846076f29f1cc83ddb74859df260baf3d9e24de65093371ba34f4006209d37e45f4c5cf42a09731d54625a4b765c2958e19b
|
7
|
+
data.tar.gz: 2719e57e76289aad38e891bd34dc3f34d17a106a212361d4cfaa8e8c36627f2dc8df4c5bb5acb2fcba748d604734f5e00f47bb0c061dd13bed195350ac6b2562
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,72 +1,94 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (7.
|
4
|
+
activesupport (7.1.2)
|
5
|
+
base64
|
6
|
+
bigdecimal
|
5
7
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
8
|
+
connection_pool (>= 2.2.5)
|
9
|
+
drb
|
6
10
|
i18n (>= 1.6, < 2)
|
7
11
|
minitest (>= 5.1)
|
12
|
+
mutex_m
|
8
13
|
tzinfo (~> 2.0)
|
9
14
|
ast (2.4.2)
|
15
|
+
base64 (0.2.0)
|
16
|
+
bigdecimal (3.1.4)
|
10
17
|
concurrent-ruby (1.2.2)
|
18
|
+
connection_pool (2.4.1)
|
11
19
|
diff-lcs (1.5.0)
|
12
20
|
docile (1.4.0)
|
13
|
-
|
21
|
+
drb (2.2.0)
|
22
|
+
ruby2_keywords
|
23
|
+
factory_bot (6.4.2)
|
14
24
|
activesupport (>= 5.0.0)
|
15
|
-
i18n (1.
|
25
|
+
i18n (1.14.1)
|
16
26
|
concurrent-ruby (~> 1.0)
|
17
|
-
json (2.
|
18
|
-
|
19
|
-
|
20
|
-
|
27
|
+
json (2.7.1)
|
28
|
+
language_server-protocol (3.17.0.3)
|
29
|
+
minitest (5.20.0)
|
30
|
+
mutex_m (0.2.0)
|
31
|
+
parallel (1.23.0)
|
32
|
+
parser (3.2.2.4)
|
21
33
|
ast (~> 2.4.1)
|
34
|
+
racc
|
35
|
+
racc (1.7.3)
|
22
36
|
rainbow (3.1.1)
|
23
|
-
rake (13.0
|
24
|
-
regexp_parser (2.
|
25
|
-
rexml (3.2.
|
37
|
+
rake (13.1.0)
|
38
|
+
regexp_parser (2.8.3)
|
39
|
+
rexml (3.2.8)
|
40
|
+
strscan (>= 3.0.9)
|
26
41
|
rspec (3.12.0)
|
27
42
|
rspec-core (~> 3.12.0)
|
28
43
|
rspec-expectations (~> 3.12.0)
|
29
44
|
rspec-mocks (~> 3.12.0)
|
30
|
-
rspec-core (3.12.
|
45
|
+
rspec-core (3.12.2)
|
31
46
|
rspec-support (~> 3.12.0)
|
32
|
-
rspec-expectations (3.12.
|
47
|
+
rspec-expectations (3.12.3)
|
33
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
49
|
rspec-support (~> 3.12.0)
|
35
|
-
rspec-mocks (3.12.
|
50
|
+
rspec-mocks (3.12.6)
|
36
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
52
|
rspec-support (~> 3.12.0)
|
38
|
-
rspec-support (3.12.
|
39
|
-
rubocop (1.
|
53
|
+
rspec-support (3.12.1)
|
54
|
+
rubocop (1.58.0)
|
40
55
|
json (~> 2.3)
|
56
|
+
language_server-protocol (>= 3.17.0)
|
41
57
|
parallel (~> 1.10)
|
42
|
-
parser (>= 3.2.
|
58
|
+
parser (>= 3.2.2.4)
|
43
59
|
rainbow (>= 2.2.2, < 4.0)
|
44
60
|
regexp_parser (>= 1.8, < 3.0)
|
45
61
|
rexml (>= 3.2.5, < 4.0)
|
46
|
-
rubocop-ast (>= 1.
|
62
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
47
63
|
ruby-progressbar (~> 1.7)
|
48
64
|
unicode-display_width (>= 2.4.0, < 3.0)
|
49
|
-
rubocop-ast (1.
|
65
|
+
rubocop-ast (1.30.0)
|
50
66
|
parser (>= 3.2.1.0)
|
51
|
-
rubocop-capybara (2.
|
67
|
+
rubocop-capybara (2.19.0)
|
52
68
|
rubocop (~> 1.41)
|
69
|
+
rubocop-factory_bot (2.24.0)
|
70
|
+
rubocop (~> 1.33)
|
53
71
|
rubocop-rake (0.6.0)
|
54
72
|
rubocop (~> 1.0)
|
55
|
-
rubocop-rspec (2.
|
56
|
-
rubocop (~> 1.
|
73
|
+
rubocop-rspec (2.25.0)
|
74
|
+
rubocop (~> 1.40)
|
57
75
|
rubocop-capybara (~> 2.17)
|
76
|
+
rubocop-factory_bot (~> 2.22)
|
58
77
|
ruby-progressbar (1.13.0)
|
78
|
+
ruby2_keywords (0.0.5)
|
59
79
|
simplecov (0.22.0)
|
60
80
|
docile (~> 1.1)
|
61
81
|
simplecov-html (~> 0.11)
|
62
82
|
simplecov_json_formatter (~> 0.1)
|
63
83
|
simplecov-html (0.12.3)
|
64
84
|
simplecov_json_formatter (0.1.4)
|
85
|
+
strscan (3.1.0)
|
65
86
|
tzinfo (2.0.6)
|
66
87
|
concurrent-ruby (~> 1.0)
|
67
|
-
unicode-display_width (2.
|
88
|
+
unicode-display_width (2.5.0)
|
68
89
|
|
69
90
|
PLATFORMS
|
91
|
+
arm64-darwin-22
|
70
92
|
ruby
|
71
93
|
|
72
94
|
DEPENDENCIES
|
@@ -79,7 +101,7 @@ DEPENDENCIES
|
|
79
101
|
simplecov
|
80
102
|
|
81
103
|
RUBY VERSION
|
82
|
-
ruby 3.
|
104
|
+
ruby 3.3.1p55
|
83
105
|
|
84
106
|
BUNDLED WITH
|
85
|
-
2.
|
107
|
+
2.4.22
|
data/README.md
CHANGED
@@ -38,3 +38,4 @@ I've written Blackjack in several other languages:
|
|
38
38
|
- [Elixir](https://github.com/gdonald/blackjack-ex)
|
39
39
|
- [Python](https://github.com/gdonald/blackjack-py)
|
40
40
|
- [C with SDL](https://github.com/gdonald/blackjack-c-sdl)
|
41
|
+
- [Emacs Lisp](https://github.com/gdonald/blackjack-el)
|
data/bj.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1|1|1|
|
1
|
+
1|1|1|9000|500
|
Binary file
|
Binary file
|
data/console-blackjack.gemspec
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
require 'rake'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.required_ruby_version = '>= 3.
|
6
|
+
spec.required_ruby_version = '>= 3.3'
|
7
7
|
spec.name = 'console-blackjack'
|
8
|
-
spec.version = '1.1.
|
8
|
+
spec.version = '1.1.5'
|
9
9
|
spec.summary = 'Console Blackjack'
|
10
10
|
spec.description = 'Blackjack for your console, full version.'
|
11
11
|
spec.author = 'Greg Donald'
|
@@ -10,20 +10,20 @@ class PlayerHand < Hand
|
|
10
10
|
|
11
11
|
MAX_PLAYER_HANDS = 7
|
12
12
|
|
13
|
-
attr_accessor :blackjack, :bet, :status, :
|
13
|
+
attr_accessor :blackjack, :bet, :status, :paid, :cards, :stood
|
14
14
|
|
15
15
|
def initialize(blackjack, bet)
|
16
16
|
super(blackjack)
|
17
17
|
@bet = bet
|
18
18
|
@status = :unknown
|
19
|
-
@
|
19
|
+
@paid = false
|
20
20
|
@stood = false
|
21
21
|
end
|
22
22
|
|
23
23
|
def pay(dealer_hand_value, dealer_busted)
|
24
|
-
return if
|
24
|
+
return if paid
|
25
25
|
|
26
|
-
self.
|
26
|
+
self.paid = true
|
27
27
|
player_hand_value = value(:soft)
|
28
28
|
|
29
29
|
if player_hand_won?(dealer_busted, dealer_hand_value, player_hand_value)
|
@@ -68,12 +68,12 @@ class PlayerHand < Hand
|
|
68
68
|
return false unless no_more_actions?
|
69
69
|
|
70
70
|
self.played = true
|
71
|
-
collect_busted_hand if !
|
71
|
+
collect_busted_hand if !paid && busted?
|
72
72
|
true
|
73
73
|
end
|
74
74
|
|
75
75
|
def collect_busted_hand
|
76
|
-
self.
|
76
|
+
self.paid = true
|
77
77
|
self.status = :lost
|
78
78
|
blackjack.money -= bet
|
79
79
|
end
|
data/lib/blackjack/shoe.rb
CHANGED
@@ -23,7 +23,7 @@ class Shoe
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def needs_to_shuffle?
|
26
|
-
return true if cards.
|
26
|
+
return true if cards.empty?
|
27
27
|
|
28
28
|
cards_dealt = total_cards - cards.size
|
29
29
|
used = cards_dealt / total_cards.to_f * 100.0
|
@@ -38,8 +38,8 @@ class Shoe
|
|
38
38
|
def new_regular
|
39
39
|
self.cards = []
|
40
40
|
num_decks.times do
|
41
|
-
|
42
|
-
|
41
|
+
4.times do |suit_value|
|
42
|
+
13.times do |value|
|
43
43
|
cards << Card.new(blackjack, value, suit_value)
|
44
44
|
end
|
45
45
|
end
|
@@ -50,7 +50,7 @@ class Shoe
|
|
50
50
|
def new_irregular(values = [])
|
51
51
|
self.cards = []
|
52
52
|
while cards.count < total_cards
|
53
|
-
|
53
|
+
4.times do |suit_value|
|
54
54
|
next if cards.count >= total_cards
|
55
55
|
|
56
56
|
values.each do |value|
|
data/lib/blackjack.rb
CHANGED
@@ -24,8 +24,8 @@ RSpec.describe PlayerHand do
|
|
24
24
|
expect(player_hand.status).to eq(:unknown)
|
25
25
|
end
|
26
26
|
|
27
|
-
it 'has not been
|
28
|
-
expect(player_hand.
|
27
|
+
it 'has not been paid' do
|
28
|
+
expect(player_hand.paid).to be_falsey
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -550,8 +550,8 @@ RSpec.describe PlayerHand do
|
|
550
550
|
end
|
551
551
|
|
552
552
|
describe '#pay' do
|
553
|
-
it 'returns if already
|
554
|
-
player_hand.
|
553
|
+
it 'returns if already paid' do
|
554
|
+
player_hand.paid = true
|
555
555
|
allow(player_hand).to receive(:value)
|
556
556
|
player_hand.pay(18, false)
|
557
557
|
expect(player_hand).to_not have_received(:value)
|
@@ -565,10 +565,10 @@ RSpec.describe PlayerHand do
|
|
565
565
|
end
|
566
566
|
|
567
567
|
context 'when dealer is not busted' do
|
568
|
-
it 'hand is set to
|
568
|
+
it 'hand is set to paid' do
|
569
569
|
player_hand.cards << ten << ten
|
570
570
|
player_hand.pay(18, false)
|
571
|
-
expect(player_hand.
|
571
|
+
expect(player_hand.paid).to be_truthy
|
572
572
|
end
|
573
573
|
|
574
574
|
it 'hand status is won' do
|
@@ -48,16 +48,14 @@ RSpec.describe Blackjack do
|
|
48
48
|
|
49
49
|
context 'when busted' do
|
50
50
|
it 'returns false' do
|
51
|
-
allow(player_hand).to
|
52
|
-
allow(player_hand).to receive(:busted?).and_return(true)
|
51
|
+
allow(player_hand).to receive_messages(blackjack?: false, busted?: true)
|
53
52
|
expect(blackjack).to_not be_need_to_play_dealer_hand
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
57
56
|
context 'when blackjack' do
|
58
57
|
it 'returns false' do
|
59
|
-
allow(player_hand).to
|
60
|
-
allow(player_hand).to receive(:blackjack?).and_return(true)
|
58
|
+
allow(player_hand).to receive_messages(busted?: false, blackjack?: true)
|
61
59
|
expect(blackjack).to_not be_need_to_play_dealer_hand
|
62
60
|
end
|
63
61
|
end
|
@@ -811,9 +809,9 @@ RSpec.describe Blackjack do
|
|
811
809
|
expect(player_hand.played).to be_truthy
|
812
810
|
end
|
813
811
|
|
814
|
-
it 'sets hand as
|
812
|
+
it 'sets hand as paid' do
|
815
813
|
blackjack.insure_hand
|
816
|
-
expect(player_hand.
|
814
|
+
expect(player_hand.paid).to be_truthy
|
817
815
|
end
|
818
816
|
|
819
817
|
it 'sets hand status as :lost' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: console-blackjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Donald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Blackjack for your console, full version.
|
14
14
|
email: gdonald@gmail.com
|
@@ -24,9 +24,8 @@ files:
|
|
24
24
|
- Rakefile
|
25
25
|
- bin/console-blackjack
|
26
26
|
- bj.txt
|
27
|
-
- console-blackjack-1.1.
|
28
|
-
- console-blackjack-1.1.
|
29
|
-
- console-blackjack-1.1.2.gem
|
27
|
+
- console-blackjack-1.1.3.gem
|
28
|
+
- console-blackjack-1.1.4.gem
|
30
29
|
- console-blackjack.gemspec
|
31
30
|
- lib/blackjack.rb
|
32
31
|
- lib/blackjack/card.rb
|
@@ -40,19 +39,19 @@ files:
|
|
40
39
|
- lib/blackjack/shoe.rb
|
41
40
|
- lib/blackjack/split_hand.rb
|
42
41
|
- lib/blackjack/utils.rb
|
42
|
+
- spec/blackjack/card_spec.rb
|
43
|
+
- spec/blackjack/dealer_hand_spec.rb
|
44
|
+
- spec/blackjack/format_spec.rb
|
45
|
+
- spec/blackjack/hand_spec.rb
|
46
|
+
- spec/blackjack/player_hand_spec.rb
|
47
|
+
- spec/blackjack/shoe_spec.rb
|
48
|
+
- spec/blackjack_spec.rb
|
43
49
|
- spec/factories/blackjack_factory.rb
|
44
50
|
- spec/factories/card_factory.rb
|
45
51
|
- spec/factories/dealer_hand_factory.rb
|
46
52
|
- spec/factories/hand_factory.rb
|
47
53
|
- spec/factories/player_hand_factory.rb
|
48
54
|
- spec/factories/shoe_factory.rb
|
49
|
-
- spec/lib/blackjack/card_spec.rb
|
50
|
-
- spec/lib/blackjack/dealer_hand_spec.rb
|
51
|
-
- spec/lib/blackjack/format_spec.rb
|
52
|
-
- spec/lib/blackjack/hand_spec.rb
|
53
|
-
- spec/lib/blackjack/player_hand_spec.rb
|
54
|
-
- spec/lib/blackjack/shoe_spec.rb
|
55
|
-
- spec/lib/blackjack_spec.rb
|
56
55
|
- spec/spec_helper.rb
|
57
56
|
- ss1.png
|
58
57
|
- ss2.png
|
@@ -73,14 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
72
|
requirements:
|
74
73
|
- - ">="
|
75
74
|
- !ruby/object:Gem::Version
|
76
|
-
version: '3.
|
75
|
+
version: '3.3'
|
77
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
77
|
requirements:
|
79
78
|
- - ">="
|
80
79
|
- !ruby/object:Gem::Version
|
81
80
|
version: '0'
|
82
81
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
82
|
+
rubygems_version: 3.5.10
|
84
83
|
signing_key:
|
85
84
|
specification_version: 4
|
86
85
|
summary: Console Blackjack
|
data/console-blackjack-1.1.0.gem
DELETED
Binary file
|
data/console-blackjack-1.1.1.gem
DELETED
Binary file
|
data/console-blackjack-1.1.2.gem
DELETED
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|