bridge 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bridge.gemspec +1 -1
- data/lib/bridge/bid.rb +0 -4
- data/lib/bridge/card.rb +0 -4
- data/lib/bridge/deal.rb +5 -4
- data/test/test_deal.rb +16 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
data/bridge.gemspec
CHANGED
data/lib/bridge/bid.rb
CHANGED
data/lib/bridge/card.rb
CHANGED
data/lib/bridge/deal.rb
CHANGED
@@ -81,6 +81,11 @@ module Bridge
|
|
81
81
|
id
|
82
82
|
end
|
83
83
|
|
84
|
+
# Returns the direction that owns the card
|
85
|
+
def owner(card)
|
86
|
+
DIRECTIONS.find { |direction| self[direction].include?(card) }
|
87
|
+
end
|
88
|
+
|
84
89
|
# Returns a random deal id
|
85
90
|
def self.random_id
|
86
91
|
rand(DEALS)
|
@@ -120,8 +125,4 @@ module Bridge
|
|
120
125
|
instance_variable_set("@#{direction.to_s.downcase}", cards)
|
121
126
|
end
|
122
127
|
end
|
123
|
-
|
124
|
-
def self.Deal(deal)
|
125
|
-
Deal.new(deal)
|
126
|
-
end
|
127
128
|
end
|
data/test/test_deal.rb
CHANGED
@@ -84,4 +84,20 @@ class TestDeal < Test::Unit::TestCase
|
|
84
84
|
Bridge::Deal.from_id(-1)
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
test "owner returns correct direction" do
|
89
|
+
deal = Bridge::Deal.new({ "N" => ["SK", "S9", "S7", "S6", "S4", "S2", "HA", "HJ", "H2", "D7", "D2", "C6", "C3"],
|
90
|
+
"E" => ["SA", "SJ", "ST", "H3", "DA", "DK", "DT", "D9", "D8", "D5", "D4", "CK", "CJ"],
|
91
|
+
"S" => ["S8", "S5", "S3", "HK", "HQ", "HT", "H8", "H4", "DQ", "D3", "CQ", "C4", "C2"],
|
92
|
+
"W" => ["SQ", "H9", "H7", "H6", "H5", "DJ", "D6", "CA", "CT", "C9", "C8", "C7", "C5"] })
|
93
|
+
|
94
|
+
assert_equal "N", deal.owner("SK")
|
95
|
+
assert_equal "N", deal.owner("C3")
|
96
|
+
assert_equal "E", deal.owner("SJ")
|
97
|
+
assert_equal "E", deal.owner("CK")
|
98
|
+
assert_equal "S", deal.owner("S3")
|
99
|
+
assert_equal "S", deal.owner("CQ")
|
100
|
+
assert_equal "W", deal.owner("H6")
|
101
|
+
assert_equal "W", deal.owner("C9")
|
102
|
+
end
|
87
103
|
end
|