Skip to content

Commit 220dfdf

Browse files
committed
basic compare_hands
1 parent 1d2bb6d commit 220dfdf

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/poker/compare_hands.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def compare_hands(hand1, hand2):
2+
"""
3+
Compare two poker hands and determine the winner.
4+
5+
Args:
6+
hand1 (list): The first poker hand.
7+
hand2 (list): The second poker hand.
8+
9+
Returns:
10+
str: A message indicating which hand wins or if it's a tie.
11+
"""
12+
# Placeholder for actual comparison logic
13+
# This should be replaced with the actual implementation that compares the hands
14+
if len(hand1) > len(hand2):
15+
return "Hand 1 wins"
16+
elif len(hand1) < len(hand2):
17+
return "Hand 2 wins"
18+
else:
19+
return "It's a tie"

tests/poker/test_compare_hands.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def test_compare_hands():
2+
from poker.compare_hands import compare_hands
3+
from poker.card import Card, Face, Suit
4+
5+
# GIVEN
6+
hand1 = [
7+
Card(face=Face.KING, suit=Suit.CLUBS),
8+
Card(face=Face.NINE, suit=Suit.SPADES),
9+
Card(face=Face.KING, suit=Suit.SPADES),
10+
Card(face=Face.KING, suit=Suit.DIAMONDS),
11+
Card(face=Face.NINE, suit=Suit.DIAMONDS),
12+
Card(face=Face.THREE, suit=Suit.CLUBS),
13+
Card(face=Face.SIX, suit=Suit.DIAMONDS)
14+
]
15+
16+
hand2 = [
17+
Card(face=Face.KING, suit=Suit.CLUBS),
18+
Card(face=Face.NINE, suit=Suit.SPADES),
19+
Card(face=Face.KING, suit=Suit.SPADES),
20+
Card(face=Face.THREE, suit=Suit.CLUBS),
21+
Card(face=Face.SIX, suit=Suit.DIAMONDS)
22+
]
23+
24+
# WHEN
25+
result = compare_hands(hand1, hand2)
26+
27+
# THEN
28+
assert result == "Hand 1 wins" # Adjust based on actual implementation logic

0 commit comments

Comments
 (0)