bridge 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bridge.gemspec +6 -6
- data/lib/bridge/bid.rb +8 -0
- data/lib/bridge/score.rb +26 -27
- data/test/test_bid.rb +8 -0
- data/test/test_score.rb +82 -65
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
data/bridge.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bridge}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.15"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jakub Kuźma"]
|
@@ -44,13 +44,13 @@ Gem::Specification.new do |s|
|
|
44
44
|
s.rubygems_version = %q{1.3.6}
|
45
45
|
s.summary = %q{Contract bridge utilities}
|
46
46
|
s.test_files = [
|
47
|
-
"test/
|
47
|
+
"test/helper.rb",
|
48
|
+
"test/test_bid.rb",
|
49
|
+
"test/test_card.rb",
|
48
50
|
"test/test_trick.rb",
|
49
51
|
"test/test_deal.rb",
|
50
|
-
"test/
|
51
|
-
"test/test_score.rb"
|
52
|
-
"test/test_bid.rb",
|
53
|
-
"test/test_card.rb"
|
52
|
+
"test/test_bridge.rb",
|
53
|
+
"test/test_score.rb"
|
54
54
|
]
|
55
55
|
|
56
56
|
if s.respond_to? :specification_version then
|
data/lib/bridge/bid.rb
CHANGED
data/lib/bridge/score.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
module Bridge
|
2
2
|
class Score
|
3
|
-
attr_reader :tricks, :contract, :
|
3
|
+
attr_reader :tricks, :contract, :vulnerable
|
4
4
|
|
5
5
|
# Creates new score object
|
6
6
|
#
|
7
7
|
# ==== Example
|
8
|
-
# Bridge::Score.new(:contract => "7SXX", :
|
8
|
+
# Bridge::Score.new(:contract => "7SXX", :vulnerable => true, :tricks => "=")
|
9
9
|
def initialize(options = {})
|
10
|
-
options[:
|
11
|
-
options[:
|
12
|
-
@
|
13
|
-
@tricks = options[:tricks]
|
14
|
-
@contract = Bridge::Bid.new(options[:contract])
|
15
|
-
@vulnerable = options[:vulnerable] if Bridge::VULNERABILITIES.include?(options[:vulnerable].upcase)
|
16
|
-
@declarer = options[:declarer] if Bridge::DIRECTIONS.include?(options[:declarer].upcase)
|
10
|
+
@contract, @modifier = split_contract(options[:contract])
|
11
|
+
@tricks = calculate_tricks(options[:tricks].to_s) if (0..13).to_a.include?(calculate_tricks(options[:tricks].to_s))
|
12
|
+
@vulnerable = options[:vulnerable] || false
|
17
13
|
end
|
18
14
|
|
19
15
|
# Returns nr of overtricks or undertricks. 0 if contract was made without them
|
@@ -34,22 +30,7 @@ module Bridge
|
|
34
30
|
#private
|
35
31
|
|
36
32
|
def vulnerable?
|
37
|
-
|
38
|
-
when "BOTH"
|
39
|
-
true
|
40
|
-
when "NONE"
|
41
|
-
false
|
42
|
-
else
|
43
|
-
vulnerable.split('').include?(declarer)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def small_slam?
|
48
|
-
contract.level.to_i == 6
|
49
|
-
end
|
50
|
-
|
51
|
-
def grand_slam?
|
52
|
-
contract.level.to_i == 7
|
33
|
+
@vulnerable == true
|
53
34
|
end
|
54
35
|
|
55
36
|
def tricks_to_make_contract
|
@@ -79,7 +60,7 @@ module Bridge
|
|
79
60
|
end
|
80
61
|
|
81
62
|
def grand_slam_bonus
|
82
|
-
if made? and grand_slam?
|
63
|
+
if made? and contract.grand_slam?
|
83
64
|
vulnerable? ? 1500 : 1000
|
84
65
|
else
|
85
66
|
0
|
@@ -87,7 +68,7 @@ module Bridge
|
|
87
68
|
end
|
88
69
|
|
89
70
|
def small_slam_bonus
|
90
|
-
if made? and small_slam?
|
71
|
+
if made? and contract.small_slam?
|
91
72
|
vulnerable? ? 750 : 500
|
92
73
|
else
|
93
74
|
0
|
@@ -160,5 +141,23 @@ module Bridge
|
|
160
141
|
0
|
161
142
|
end
|
162
143
|
end
|
144
|
+
|
145
|
+
def calculate_tricks(tricks)
|
146
|
+
if tricks =~ /\A\+\d\Z/
|
147
|
+
tricks_to_make_contract + tricks[1..1].to_i
|
148
|
+
elsif tricks =~ /\A-\d\Z/
|
149
|
+
tricks_to_make_contract - tricks[1..1].to_i
|
150
|
+
elsif tricks =~ /\A=\Z/
|
151
|
+
tricks_to_make_contract.to_i
|
152
|
+
else
|
153
|
+
tricks.to_i
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def split_contract(contract)
|
158
|
+
contract = contract.gsub(/(X+)/, "")
|
159
|
+
modifier = $1.nil? ? 1 : $1.to_s.size * 2
|
160
|
+
[Bridge::Bid.new(contract), modifier]
|
161
|
+
end
|
163
162
|
end
|
164
163
|
end
|
data/test/test_bid.rb
CHANGED
@@ -124,4 +124,12 @@ class TestBid < Test::Unit::TestCase
|
|
124
124
|
test "1NT is a nt bid" do
|
125
125
|
assert Bridge::Bid.new("1NT").nt?
|
126
126
|
end
|
127
|
+
|
128
|
+
test "6NT is a small slam" do
|
129
|
+
assert Bridge::Bid.new("6NT").small_slam?
|
130
|
+
end
|
131
|
+
|
132
|
+
test "7NT is a grand slam" do
|
133
|
+
assert Bridge::Bid.new("7NT").grand_slam?
|
134
|
+
end
|
127
135
|
end
|
data/test/test_score.rb
CHANGED
@@ -3,223 +3,240 @@ require "helper"
|
|
3
3
|
class TestScore < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
@score = Bridge::Score.new(:contract => "1S", :
|
6
|
+
@score = Bridge::Score.new(:contract => "1S", :vulnerable => false, :tricks => 9)
|
7
7
|
end
|
8
8
|
|
9
9
|
test "valid score" do
|
10
10
|
assert_false @score.contract.nil?
|
11
|
-
assert_false @score.declarer.nil?
|
12
11
|
assert_false @score.vulnerable.nil?
|
13
12
|
assert_false @score.tricks.nil?
|
14
13
|
end
|
15
14
|
|
16
|
-
test "default vulnerable set to
|
17
|
-
score = Bridge::Score.new(:contract => "1S", :
|
18
|
-
assert_equal
|
15
|
+
test "default vulnerable set to false" do
|
16
|
+
score = Bridge::Score.new(:contract => "1S", :tricks => 9)
|
17
|
+
assert_equal false, score.vulnerable
|
19
18
|
end
|
20
19
|
|
21
20
|
test "return modifier and contract when doubled" do
|
22
|
-
score = Bridge::Score.new(:contract => "4SX", :
|
21
|
+
score = Bridge::Score.new(:contract => "4SX", :tricks => 9)
|
23
22
|
assert_equal 2, score.instance_variable_get(:@modifier)
|
24
23
|
assert_equal "4S", score.contract.to_s
|
25
24
|
end
|
26
25
|
|
27
26
|
test "return modifier and contract when redoubled" do
|
28
|
-
score = Bridge::Score.new(:contract => "4SXX", :
|
27
|
+
score = Bridge::Score.new(:contract => "4SXX", :tricks => 9)
|
29
28
|
assert_equal 4, score.instance_variable_get(:@modifier)
|
30
29
|
assert_equal "4S", score.contract.to_s
|
31
30
|
end
|
32
31
|
|
33
32
|
test "return tricks to make contract" do
|
34
33
|
assert_equal 7, @score.tricks_to_make_contract
|
35
|
-
score = Bridge::Score.new(:contract => "6S", :
|
34
|
+
score = Bridge::Score.new(:contract => "6S", :tricks => 9)
|
36
35
|
assert_equal 12, score.tricks_to_make_contract
|
37
36
|
end
|
38
37
|
|
39
38
|
test "return made contract?" do
|
40
|
-
score = Bridge::Score.new(:contract => "6S", :
|
39
|
+
score = Bridge::Score.new(:contract => "6S", :tricks => 9)
|
41
40
|
assert_false score.made?
|
42
|
-
score = Bridge::Score.new(:contract => "3NT", :
|
41
|
+
score = Bridge::Score.new(:contract => "3NT", :vulnerable => true, :tricks => 3)
|
43
42
|
assert_false score.made?
|
44
|
-
score = Bridge::Score.new(:contract => "7NT", :
|
43
|
+
score = Bridge::Score.new(:contract => "7NT", :vulnerable => true, :tricks => 13)
|
45
44
|
assert score.made?
|
46
|
-
score = Bridge::Score.new(:contract => "3NT", :
|
45
|
+
score = Bridge::Score.new(:contract => "3NT", :vulnerable => true, :tricks => 11)
|
47
46
|
assert score.made?
|
48
47
|
end
|
49
48
|
|
50
49
|
test "return result" do
|
51
50
|
assert_equal 2, @score.result
|
52
|
-
score = Bridge::Score.new(:contract => "6S", :
|
51
|
+
score = Bridge::Score.new(:contract => "6S", :tricks => 12)
|
53
52
|
assert_equal 0, score.result
|
54
|
-
score = Bridge::Score.new(:contract => "6S", :
|
53
|
+
score = Bridge::Score.new(:contract => "6S", :tricks => 10)
|
55
54
|
assert_equal -2, score.result
|
56
55
|
end
|
57
56
|
|
58
57
|
test "return vulnerable" do
|
59
58
|
assert_false @score.vulnerable?
|
60
|
-
score = Bridge::Score.new(:contract => "6S", :
|
59
|
+
score = Bridge::Score.new(:contract => "6S", :vulnerable => true, :tricks => 12)
|
61
60
|
assert score.vulnerable?
|
62
|
-
score = Bridge::Score.new(:contract => "6S", :
|
63
|
-
assert score.vulnerable?
|
64
|
-
score = Bridge::Score.new(:contract => "6S", :declarer => "E", :vulnerable => "NS", :tricks => 10)
|
61
|
+
score = Bridge::Score.new(:contract => "6S", :vulnerable => false, :tricks => 10)
|
65
62
|
assert_false score.vulnerable?
|
66
63
|
end
|
64
|
+
|
65
|
+
test "calculate tricks with plus" do
|
66
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => true, :tricks => "+1")
|
67
|
+
assert_equal 11, score.tricks
|
68
|
+
end
|
69
|
+
|
70
|
+
test "calculate tricks with minus" do
|
71
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => true, :tricks => "-4")
|
72
|
+
assert_equal 6, score.tricks
|
73
|
+
end
|
74
|
+
|
75
|
+
test "calculate tricks with equal sign" do
|
76
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => true, :tricks => "=")
|
77
|
+
assert_equal 10, score.tricks
|
78
|
+
end
|
79
|
+
|
80
|
+
test "not set tricks if value out of range" do
|
81
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => true, :tricks => 15)
|
82
|
+
assert_nil score.tricks
|
83
|
+
end
|
67
84
|
end
|
68
85
|
|
69
86
|
class TestScorePoints < Test::Unit::TestCase
|
70
87
|
|
71
88
|
test "game bonus" do
|
72
|
-
score = Bridge::Score.new(:contract => "3S", :
|
89
|
+
score = Bridge::Score.new(:contract => "3S", :vulnerable => false, :tricks => 9)
|
73
90
|
assert_equal 50, score.game_bonus
|
74
|
-
score = Bridge::Score.new(:contract => "4S", :
|
91
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => false, :tricks => 10)
|
75
92
|
assert_equal 300, score.game_bonus
|
76
|
-
score = Bridge::Score.new(:contract => "6S", :
|
93
|
+
score = Bridge::Score.new(:contract => "6S", :vulnerable => false, :tricks => 12)
|
77
94
|
assert_equal 300, score.game_bonus
|
78
|
-
score = Bridge::Score.new(:contract => "3NT", :
|
95
|
+
score = Bridge::Score.new(:contract => "3NT", :vulnerable => true, :tricks => 9)
|
79
96
|
assert_equal 500, score.game_bonus
|
80
|
-
score = Bridge::Score.new(:contract => "3NT", :
|
97
|
+
score = Bridge::Score.new(:contract => "3NT", :vulnerable => true, :tricks => 3)
|
81
98
|
assert_equal 0, score.game_bonus
|
82
|
-
score = Bridge::Score.new(:contract => "3SX", :
|
99
|
+
score = Bridge::Score.new(:contract => "3SX", :vulnerable => true, :tricks => 9)
|
83
100
|
assert_equal 500, score.game_bonus
|
84
101
|
end
|
85
102
|
|
86
103
|
test "small slam bonus" do
|
87
|
-
score = Bridge::Score.new(:contract => "6S", :
|
104
|
+
score = Bridge::Score.new(:contract => "6S", :vulnerable => false, :tricks => 12)
|
88
105
|
assert_equal 500, score.small_slam_bonus
|
89
|
-
score = Bridge::Score.new(:contract => "6S", :
|
106
|
+
score = Bridge::Score.new(:contract => "6S", :vulnerable => true, :tricks => 12)
|
90
107
|
assert_equal 750, score.small_slam_bonus
|
91
|
-
score = Bridge::Score.new(:contract => "6S", :
|
108
|
+
score = Bridge::Score.new(:contract => "6S", :vulnerable => true, :tricks => 10)
|
92
109
|
assert_equal 0, score.small_slam_bonus
|
93
110
|
end
|
94
111
|
|
95
112
|
test "grand slam bonus" do
|
96
|
-
score = Bridge::Score.new(:contract => "7S", :
|
113
|
+
score = Bridge::Score.new(:contract => "7S", :vulnerable => false, :tricks => 13)
|
97
114
|
assert_equal 1000, score.grand_slam_bonus
|
98
|
-
score = Bridge::Score.new(:contract => "7S", :
|
115
|
+
score = Bridge::Score.new(:contract => "7S", :vulnerable => true, :tricks => 13)
|
99
116
|
assert_equal 1500, score.grand_slam_bonus
|
100
|
-
score = Bridge::Score.new(:contract => "7S", :
|
117
|
+
score = Bridge::Score.new(:contract => "7S", :vulnerable => true, :tricks => 11)
|
101
118
|
assert_equal 0, score.grand_slam_bonus
|
102
|
-
score = Bridge::Score.new(:contract => "6S", :
|
119
|
+
score = Bridge::Score.new(:contract => "6S", :vulnerable => true, :tricks => 13)
|
103
120
|
assert_equal 0, score.grand_slam_bonus
|
104
121
|
end
|
105
122
|
|
106
123
|
test "doubled and redoubled cotract made bonus" do
|
107
|
-
score = Bridge::Score.new(:contract => "4SX", :
|
124
|
+
score = Bridge::Score.new(:contract => "4SX", :tricks => 10)
|
108
125
|
assert_equal 50, score.doubled_bonus
|
109
|
-
score = Bridge::Score.new(:contract => "4SXX", :
|
126
|
+
score = Bridge::Score.new(:contract => "4SXX", :tricks => 10)
|
110
127
|
assert_equal 100, score.redoubled_bonus
|
111
128
|
assert_equal 0, score.doubled_bonus
|
112
129
|
end
|
113
130
|
|
114
131
|
test "vulnerable undertrick points" do
|
115
|
-
score = Bridge::Score.new(:contract => "4S", :
|
132
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => true, :tricks => 9)
|
116
133
|
assert_equal -100, score.vulnerable_undertrick_points
|
117
|
-
score = Bridge::Score.new(:contract => "4SX", :
|
134
|
+
score = Bridge::Score.new(:contract => "4SX", :vulnerable => true, :tricks => 9)
|
118
135
|
assert_equal -200, score.vulnerable_undertrick_points
|
119
|
-
score = Bridge::Score.new(:contract => "4SX", :
|
136
|
+
score = Bridge::Score.new(:contract => "4SX", :vulnerable => true, :tricks => 7)
|
120
137
|
assert_equal -800, score.vulnerable_undertrick_points
|
121
|
-
score = Bridge::Score.new(:contract => "4SXX", :
|
138
|
+
score = Bridge::Score.new(:contract => "4SXX", :vulnerable => true, :tricks => 9)
|
122
139
|
assert_equal -400, score.vulnerable_undertrick_points
|
123
|
-
score = Bridge::Score.new(:contract => "4SXX", :
|
140
|
+
score = Bridge::Score.new(:contract => "4SXX", :vulnerable => true, :tricks => 7)
|
124
141
|
assert_equal -1600, score.vulnerable_undertrick_points
|
125
142
|
end
|
126
143
|
|
127
144
|
test "not vulnerable undertrick points" do
|
128
|
-
score = Bridge::Score.new(:contract => "4S", :
|
145
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => false, :tricks => 9)
|
129
146
|
assert_equal -50, score.not_vulnerable_undertrick_points
|
130
|
-
score = Bridge::Score.new(:contract => "4SX", :
|
147
|
+
score = Bridge::Score.new(:contract => "4SX", :vulnerable => false, :tricks => 9)
|
131
148
|
assert_equal -100, score.not_vulnerable_undertrick_points
|
132
|
-
score = Bridge::Score.new(:contract => "4SX", :
|
149
|
+
score = Bridge::Score.new(:contract => "4SX", :vulnerable => false, :tricks => 7)
|
133
150
|
assert_equal -500, score.not_vulnerable_undertrick_points
|
134
|
-
score = Bridge::Score.new(:contract => "4SXX", :
|
151
|
+
score = Bridge::Score.new(:contract => "4SXX", :vulnerable => false, :tricks => 9)
|
135
152
|
assert_equal -200, score.not_vulnerable_undertrick_points
|
136
|
-
score = Bridge::Score.new(:contract => "4SXX", :
|
153
|
+
score = Bridge::Score.new(:contract => "4SXX", :vulnerable => false, :tricks => 7)
|
137
154
|
assert_equal -1000, score.not_vulnerable_undertrick_points
|
138
|
-
score = Bridge::Score.new(:contract => "4SX", :
|
155
|
+
score = Bridge::Score.new(:contract => "4SX", :vulnerable => false, :tricks => 6)
|
139
156
|
assert_equal -800, score.not_vulnerable_undertrick_points
|
140
|
-
score = Bridge::Score.new(:contract => "4SXX", :
|
157
|
+
score = Bridge::Score.new(:contract => "4SXX", :vulnerable => false, :tricks => 6)
|
141
158
|
assert_equal -1600, score.not_vulnerable_undertrick_points
|
142
|
-
score = Bridge::Score.new(:contract => "4S", :
|
159
|
+
score = Bridge::Score.new(:contract => "4S", :vulnerable => false, :tricks => 6)
|
143
160
|
assert_equal -200, score.not_vulnerable_undertrick_points
|
144
161
|
end
|
145
162
|
|
146
163
|
test "overtrick points" do
|
147
|
-
score = Bridge::Score.new(:contract => "2S", :
|
164
|
+
score = Bridge::Score.new(:contract => "2S", :vulnerable => false, :tricks => 10)
|
148
165
|
assert_equal 60, score.overtrick_points
|
149
|
-
score = Bridge::Score.new(:contract => "2SX", :
|
166
|
+
score = Bridge::Score.new(:contract => "2SX", :vulnerable => false, :tricks => 9)
|
150
167
|
assert_equal 100, score.overtrick_points
|
151
|
-
score = Bridge::Score.new(:contract => "2SXX", :
|
168
|
+
score = Bridge::Score.new(:contract => "2SXX", :vulnerable => false, :tricks => 9)
|
152
169
|
assert_equal 200, score.overtrick_points
|
153
|
-
score = Bridge::Score.new(:contract => "2S", :
|
170
|
+
score = Bridge::Score.new(:contract => "2S", :vulnerable => true, :tricks => 9)
|
154
171
|
assert_equal 30, score.overtrick_points
|
155
|
-
score = Bridge::Score.new(:contract => "2SX", :
|
172
|
+
score = Bridge::Score.new(:contract => "2SX", :vulnerable => true, :tricks => 9)
|
156
173
|
assert_equal 200, score.overtrick_points
|
157
|
-
score = Bridge::Score.new(:contract => "2SXX", :
|
174
|
+
score = Bridge::Score.new(:contract => "2SXX", :vulnerable => true, :tricks => 9)
|
158
175
|
assert_equal 400, score.overtrick_points
|
159
176
|
end
|
160
177
|
|
161
178
|
test "return 90 points for 1S=" do
|
162
|
-
score = Bridge::Score.new(:contract => "3S", :
|
179
|
+
score = Bridge::Score.new(:contract => "3S", :vulnerable => false, :tricks => 9)
|
163
180
|
assert_equal 140, score.points
|
164
181
|
end
|
165
182
|
|
166
183
|
test "return 70 points for 2S=" do
|
167
|
-
score = Bridge::Score.new(:contract => "2NT", :
|
184
|
+
score = Bridge::Score.new(:contract => "2NT", :vulnerable => false, :tricks => 8)
|
168
185
|
assert_equal 120, score.points
|
169
186
|
end
|
170
187
|
|
171
188
|
test "return 80 points for 2D+2" do
|
172
|
-
score = Bridge::Score.new(:contract => "2D", :
|
189
|
+
score = Bridge::Score.new(:contract => "2D", :vulnerable => false, :tricks => 10)
|
173
190
|
assert_equal 130, score.points
|
174
191
|
end
|
175
192
|
|
176
193
|
test "return 1400 points for 5CXX+1" do
|
177
|
-
score = Bridge::Score.new(:contract => "5CXX", :
|
194
|
+
score = Bridge::Score.new(:contract => "5CXX", :vulnerable => true, :tricks => 12)
|
178
195
|
assert_equal 1400, score.points
|
179
196
|
end
|
180
197
|
|
181
198
|
test "return 1700 points for 3NTX-7" do
|
182
|
-
score = Bridge::Score.new(:contract => "3NTX", :
|
199
|
+
score = Bridge::Score.new(:contract => "3NTX", :vulnerable => false, :tricks => 2)
|
183
200
|
assert_equal -1700, score.points
|
184
201
|
end
|
185
202
|
|
186
203
|
test "return -7600 points for 7NTXX-13" do
|
187
|
-
score = Bridge::Score.new(:contract => "7NTXX", :
|
204
|
+
score = Bridge::Score.new(:contract => "7NTXX", :vulnerable => true, :tricks => 0)
|
188
205
|
assert_equal -7600, score.points
|
189
206
|
end
|
190
207
|
|
191
208
|
test "return -7600 points for 7NT-13" do
|
192
|
-
score = Bridge::Score.new(:contract => "7NT", :
|
209
|
+
score = Bridge::Score.new(:contract => "7NT", :vulnerable => false, :tricks => 0)
|
193
210
|
assert_equal -650, score.points
|
194
211
|
end
|
195
212
|
|
196
213
|
test "return -1300 points for 7NT-13" do
|
197
|
-
score = Bridge::Score.new(:contract => "7NT", :
|
214
|
+
score = Bridge::Score.new(:contract => "7NT", :vulnerable => true, :tricks => 0)
|
198
215
|
assert_equal -1300, score.points
|
199
216
|
end
|
200
217
|
|
201
218
|
test "return -3500 points for 7NTX-13" do
|
202
|
-
score = Bridge::Score.new(:contract => "7NTX", :
|
219
|
+
score = Bridge::Score.new(:contract => "7NTX", :vulnerable => false, :tricks => 0)
|
203
220
|
assert_equal -3500, score.points
|
204
221
|
end
|
205
222
|
|
206
223
|
test "return -3800 points for 7NTX-13" do
|
207
|
-
score = Bridge::Score.new(:contract => "7NTX", :
|
224
|
+
score = Bridge::Score.new(:contract => "7NTX", :vulnerable => true, :tricks => 0)
|
208
225
|
assert_equal -3800, score.points
|
209
226
|
end
|
210
227
|
|
211
228
|
test "return -7000 points for 7NTXX-13" do
|
212
|
-
score = Bridge::Score.new(:contract => "7NTXX", :
|
229
|
+
score = Bridge::Score.new(:contract => "7NTXX", :vulnerable => false, :tricks => 0)
|
213
230
|
assert_equal -7000, score.points
|
214
231
|
end
|
215
232
|
|
216
233
|
test "return 1340 points for 1CX+6" do
|
217
|
-
score = Bridge::Score.new(:contract => "1CX", :
|
234
|
+
score = Bridge::Score.new(:contract => "1CX", :vulnerable => true, :tricks => 13)
|
218
235
|
assert_equal 1340, score.points
|
219
236
|
end
|
220
237
|
|
221
238
|
test "return 740 points for 1CX+6" do
|
222
|
-
score = Bridge::Score.new(:contract => "1CX", :
|
239
|
+
score = Bridge::Score.new(:contract => "1CX", :vulnerable => false, :tricks => 13)
|
223
240
|
assert_equal 740, score.points
|
224
241
|
end
|
225
242
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 15
|
9
|
+
version: 0.0.15
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Jakub Ku\xC5\xBAma"
|
@@ -90,10 +90,10 @@ signing_key:
|
|
90
90
|
specification_version: 3
|
91
91
|
summary: Contract bridge utilities
|
92
92
|
test_files:
|
93
|
-
- test/test_bridge.rb
|
94
|
-
- test/test_trick.rb
|
95
|
-
- test/test_deal.rb
|
96
93
|
- test/helper.rb
|
97
|
-
- test/test_score.rb
|
98
94
|
- test/test_bid.rb
|
99
95
|
- test/test_card.rb
|
96
|
+
- test/test_trick.rb
|
97
|
+
- test/test_deal.rb
|
98
|
+
- test/test_bridge.rb
|
99
|
+
- test/test_score.rb
|