bridge 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
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.11"
8
+ s.version = "0.0.12"
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"]
data/lib/bridge/trick.rb CHANGED
@@ -1,16 +1,14 @@
1
1
  module Bridge
2
2
  class Trick
3
- attr_reader :cards, :trump, :suit
3
+ attr_reader :cards, :suit
4
4
 
5
5
  def initialize(*args)
6
- options = args.pop if args.last.is_a?(Hash)
7
- @cards = args.flatten.map { |s| Bridge::Card.new(s.to_s) }
6
+ @cards = args.flatten.map { |c| Bridge::Card.new(c.to_s) }
8
7
  @suit = @cards.first.suit
9
- @trump = options && options[:trump]
10
8
  end
11
9
 
12
- def winner
13
- winner_in_suit(@trump) || winner_in_suit(@suit)
10
+ def winner(trump = nil)
11
+ winner_in_suit(trump) || winner_in_suit(@suit)
14
12
  end
15
13
 
16
14
  private
data/test/test_trick.rb CHANGED
@@ -12,27 +12,27 @@ class TestTrick < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  test "the highest H card is the winner in S game H trick and single suit" do
15
- trick = Bridge::Trick.new("H2", "H5", "H4", "H3", :trump => "S")
16
- assert_equal Bridge::Card.new("H5"), trick.winner
15
+ trick = Bridge::Trick.new("H2", "H5", "H4", "H3")
16
+ assert_equal Bridge::Card.new("H5"), trick.winner("S")
17
17
  end
18
18
 
19
19
  test "the highest H card is the winner in S game H trick and multiple suits" do
20
- trick = Bridge::Trick.new("H2", "D5", "C4", "H3", :trump => "S")
21
- assert_equal Bridge::Card.new("H3"), trick.winner
20
+ trick = Bridge::Trick.new("H2", "D5", "C4", "H3")
21
+ assert_equal Bridge::Card.new("H3"), trick.winner("S")
22
22
  end
23
23
 
24
24
  test "the only trump is the winner in S game H trick and multiple suits" do
25
- trick = Bridge::Trick.new("H2", "D5", "S2", "H3", :trump => "S")
26
- assert_equal Bridge::Card.new("S2"), trick.winner
25
+ trick = Bridge::Trick.new("H2", "D5", "S2", "H3")
26
+ assert_equal Bridge::Card.new("S2"), trick.winner("S")
27
27
  end
28
28
 
29
29
  test "the highest trump is the winner in S game H trick and multiple suits" do
30
- trick = Bridge::Trick.new("H2", "SA", "S2", "H3", :trump => "S")
31
- assert_equal Bridge::Card.new("SA"), trick.winner
30
+ trick = Bridge::Trick.new("H2", "SA", "S2", "H3")
31
+ assert_equal Bridge::Card.new("SA"), trick.winner("S")
32
32
  end
33
33
 
34
34
  test "the highest trump is the winner in S game S trick and multiple suits" do
35
- trick = Bridge::Trick.new("S2", "HA", "CA", "DA", :trump => "S")
36
- assert_equal Bridge::Card.new("S2"), trick.winner
35
+ trick = Bridge::Trick.new("S2", "HA", "CA", "DA")
36
+ assert_equal Bridge::Card.new("S2"), trick.winner("S")
37
37
  end
38
38
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 11
9
- version: 0.0.11
8
+ - 12
9
+ version: 0.0.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jakub Ku\xC5\xBAma"