acpc_poker_types 7.2.5 → 7.3.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 +4 -4
- data/lib/acpc_poker_types/hand_player.rb +8 -0
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/hand_player_spec.rb +29 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 420a31712b46aefd6c8af8e3e3511bfde1376f7b
|
|
4
|
+
data.tar.gz: 4f27b80f00a3696a789a09564d63c3384b6efc2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b32c17d595b04f275e3cf0c61bc10ead3834148bd42f5bb60191835c1a6e5f7d615813a00d58b72edfdf6596875b274267e3eeffacc974544243b27dbaa11e0c
|
|
7
|
+
data.tar.gz: 5944fd75d1e3e351aa66c547789ed8528580f5af9d6f6af4424776e2f90621e4face4c771c3d36109cbae659a53ab29b16752b6cc76cb53fea3f2422e2d94e10
|
|
@@ -50,6 +50,14 @@ class HandPlayer
|
|
|
50
50
|
@winnings - total_contribution
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def contributions_before(cur_round = round)
|
|
54
|
+
if cur_round > 0
|
|
55
|
+
contributions[0..cur_round-1].inject(:+)
|
|
56
|
+
else
|
|
57
|
+
0
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
53
61
|
def contributions
|
|
54
62
|
contribution_list = @actions.map do |actions_per_round|
|
|
55
63
|
actions_per_round.inject(0) { |sum, action| sum += action.cost }
|
data/spec/hand_player_spec.rb
CHANGED
|
@@ -40,6 +40,35 @@ describe HandPlayer do
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
+
describe '#contributions_before' do
|
|
44
|
+
it 'works' do
|
|
45
|
+
x_actions = [
|
|
46
|
+
[
|
|
47
|
+
PokerAction.new('c', cost: 100),
|
|
48
|
+
PokerAction.new('r200', cost: 100)
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
PokerAction.new('r400', cost: 200),
|
|
52
|
+
PokerAction.new('c', cost: 0)
|
|
53
|
+
]
|
|
54
|
+
]
|
|
55
|
+
x_actions.each_with_index do |actions, in_round|
|
|
56
|
+
actions.each do |action|
|
|
57
|
+
patient.append_action!(action, in_round)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
x_contributions = x_actions.map do |actions|
|
|
62
|
+
actions.inject(0) { |sum, action| sum += action.cost }
|
|
63
|
+
end
|
|
64
|
+
x_contributions[0] += ANTE
|
|
65
|
+
|
|
66
|
+
patient.contributions_before.must_equal(x_contributions[0])
|
|
67
|
+
patient.contributions_before(0).must_equal(0)
|
|
68
|
+
patient.contributions_before(1).must_equal(x_contributions[0])
|
|
69
|
+
patient.contributions_before(2).must_equal(x_contributions.inject(:+))
|
|
70
|
+
end
|
|
71
|
+
end
|
|
43
72
|
describe '#append_action!' do
|
|
44
73
|
describe 'raises an exception if it is not active' do
|
|
45
74
|
it 'if it has folded' do
|