Skip to content

Commit

Permalink
Implement highest and full_of for full house
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebaldock committed Sep 8, 2014
1 parent d90e840 commit 8206f58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/hand.rb
Expand Up @@ -36,7 +36,7 @@ def rank
elsif has_four elsif has_four
has_four has_four
elsif full_house elsif full_house
{ :type => :full_house } full_house
elsif flush elsif flush
flush flush
elsif straight elsif straight
Expand Down Expand Up @@ -107,7 +107,13 @@ def has_two
end end


def full_house def full_house
pips_per_occurence[3] && pips_per_occurence[2] if pips_per_occurence[3] && pips_per_occurence[2]
{
:type => :full_house,
:highest => pips_per_occurence[3].first,
:full_of => pips_per_occurence[2].first
}
end
end end


def flush def flush
Expand Down
6 changes: 6 additions & 0 deletions spec/hand_spec.rb
Expand Up @@ -75,6 +75,12 @@
it "ranks the hand correctly" do it "ranks the hand correctly" do
expect(hand.rank.fetch(:type)).to eq :full_house expect(hand.rank.fetch(:type)).to eq :full_house
end end
it "returns the highest correctly" do
expect(hand.rank.fetch(:highest)).to eq 5
end
it "returns the full_of value correctly" do
expect(hand.rank.fetch(:full_of)).to eq 6
end
end end


context "flush hand" do context "flush hand" do
Expand Down

0 comments on commit 8206f58

Please sign in to comment.