fiftytwo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/fiftytwo/deck.rb +3 -3
- data/lib/fiftytwo/hand.rb +4 -0
- data/lib/fiftytwo/version.rb +1 -1
- data/spec/lib/fiftytwo/deck_spec.rb +1 -1
- data/spec/lib/fiftytwo/hand_spec.rb +31 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f841300403b3e5e84bd2094a711ee89c13333537e3cabd08f3dfff000d59f69c
|
4
|
+
data.tar.gz: be8c200b6207437b4cabe5c500df1ff80caccf17ca8845a048c124c6ac86d97d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 579cf55130a79d92779edf40dce3f99e232270845c4f8a48097d1f904b759317f3aa19cba206e62bf60917306ac05b008b02cc938e21a4d017b5a97e529662b9
|
7
|
+
data.tar.gz: '0643844dd685e0f5c44f629f5db3c70b5599c00cfe136ba914448c88cf2974b864f7e30c6a661cb69a90544da82e65eff527b2eef7618f8a37191cef0f581c23'
|
data/README.md
CHANGED
@@ -111,7 +111,7 @@ my_hand = FiftyTwo::Hand.new
|
|
111
111
|
your_hand = FiftyTwo::Hand.new
|
112
112
|
# => #<FiftyTwo::Hand:0x00007fb3d21c68c0 @cards=[]>
|
113
113
|
|
114
|
-
deck.deal([my_hand, your_hand],
|
114
|
+
deck.deal([my_hand, your_hand], 5)
|
115
115
|
"Deck has #{deck.count} cards, I have #{my_hand.count} cards, you have #{your_hand.count} cards"
|
116
116
|
# => "Deck has 42 cards, I have 5 cards, you have 5 cards"
|
117
117
|
|
@@ -146,6 +146,15 @@ deck.count
|
|
146
146
|
# => 43
|
147
147
|
```
|
148
148
|
|
149
|
+
And finally, release your hand back to the dealer:
|
150
|
+
```ruby
|
151
|
+
my_hand.release
|
152
|
+
your_hand.release
|
153
|
+
|
154
|
+
"Deck has #{deck.count} cards, I have #{my_hand.count} cards, you have #{your_hand.count} cards"
|
155
|
+
# => "Deck has 52 cards, I have 0 cards, you have 0 cards"
|
156
|
+
```
|
157
|
+
|
149
158
|
# Problems?
|
150
159
|
Please submit an [issue](https://github.com/kevinstuffandthings/fiftytwo/issues).
|
151
160
|
We'll figure out how to get you up and running with FiftyTwo as smoothly as possible.
|
data/lib/fiftytwo/deck.rb
CHANGED
@@ -22,9 +22,9 @@ module FiftyTwo
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def deal(hands,
|
26
|
-
|
27
|
-
hands.each { |h| h << draw }
|
25
|
+
def deal(hands, num_cards = 1)
|
26
|
+
num_cards.times.each do |card_idx|
|
27
|
+
Array(hands).each { |h| h << draw }
|
28
28
|
end
|
29
29
|
|
30
30
|
hands
|
data/lib/fiftytwo/hand.rb
CHANGED
data/lib/fiftytwo/version.rb
CHANGED
@@ -269,7 +269,7 @@ module FiftyTwo
|
|
269
269
|
card8 = subject[7]
|
270
270
|
card9 = subject[8]
|
271
271
|
|
272
|
-
subject.deal(hands,
|
272
|
+
subject.deal(hands, 3)
|
273
273
|
expect(subject.count).to eq 43
|
274
274
|
expect(hand1.cards).to match_array [card1, card4, card7]
|
275
275
|
expect(hand2.cards).to match_array [card2, card5, card8]
|
@@ -2,6 +2,36 @@
|
|
2
2
|
|
3
3
|
module FiftyTwo
|
4
4
|
describe Hand do
|
5
|
-
# covered by tests for FiftyTwo::Deck
|
5
|
+
# majority covered by tests for FiftyTwo::Deck
|
6
|
+
|
7
|
+
let(:deck) { FiftyTwo::Deck.standard }
|
8
|
+
let(:hand) { described_class.new }
|
9
|
+
before(:each) { deck.shuffle! }
|
10
|
+
|
11
|
+
describe "#release" do
|
12
|
+
it "does nothing with an empty hand" do
|
13
|
+
expect(deck.count).to eq 52
|
14
|
+
expect(hand.count).to eq 0
|
15
|
+
|
16
|
+
hand.release
|
17
|
+
|
18
|
+
expect(deck.count).to eq 52
|
19
|
+
expect(hand.count).to eq 0
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with cards" do
|
23
|
+
before(:each) { deck.deal(hand, 5) }
|
24
|
+
|
25
|
+
it "can return the entirety of the hand back to the deck from whence it came" do
|
26
|
+
expect(deck.count).to eq 47
|
27
|
+
expect(hand.count).to eq 5
|
28
|
+
|
29
|
+
hand.release
|
30
|
+
|
31
|
+
expect(deck.count).to eq 52
|
32
|
+
expect(hand.count).to eq 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
6
36
|
end
|
7
37
|
end
|