PyBaccarat
visit the ministry of silly walks
Public Member Functions | List of all members
pybaccarat.baccarat.Hand Class Reference

This class represents a hand in the game Baccarat. More...

Inheritance diagram for pybaccarat.baccarat.Hand:

Public Member Functions

def __init__ (self)
 Create a new hand in Baccarat. More...
 
def empty (self)
 Reset the hand, that is, clear all cards.
 
def add (self, new_card)
 Add a card to the hand. More...
 
def __add__ (self, right)
 Use the "+" operator to also add a Card to this Hand. More...
 
def value (self)
 Get the baccarat hand value. More...
 
def need_hit (self, other_hand)
 Does this hand need to hit a third card? Checking if the player needs a third card, other_hand should be None. More...
 
def get_card (self, index)
 Return the specified card. More...
 
def is_natural (self)
 Is this hand a natural? More...
 
def __str__ (self)
 Return the string representation for this hand. More...
 
def __cmp__ (self, other)
 Compare this hand to other hand. More...
 
def __init__ (self)
 Create a new hand in Baccarat. More...
 
def empty (self)
 Reset the hand, that is, clear all cards.
 
def add (self, new_card)
 Add a card to the hand. More...
 
def __add__ (self, right)
 Use the "+" operator to also add a Card to this Hand. More...
 
def value (self)
 Get the baccarat hand value. More...
 
def need_hit (self, other_hand)
 Does this hand need to hit a third card? Checking if the player needs a third card, other_hand should be None. More...
 
def get_card (self, index)
 Return the specified card. More...
 
def is_natural (self)
 Is this hand a natural? More...
 
def __str__ (self)
 Return the string representation for this hand. More...
 
def __cmp__ (self, other)
 Compare this hand to other hand. More...
 

Detailed Description

This class represents a hand in the game Baccarat.

See also
playingcards.Card
playingcards.Shoe

Constructor & Destructor Documentation

◆ __init__() [1/2]

def pybaccarat.baccarat.Hand.__init__ (   self)

Create a new hand in Baccarat.

Example usage:

player = Hand()
player.add(Card(5,'s')
player.add(shoe.deal())

◆ __init__() [2/2]

def pybaccarat.baccarat.Hand.__init__ (   self)

Create a new hand in Baccarat.

Example usage:

player = Hand()
player.add(Card(5,'s')
player.add(shoe.deal())

Member Function Documentation

◆ __add__() [1/2]

def pybaccarat.baccarat.Hand.__add__ (   self,
  right 
)

Use the "+" operator to also add a Card to this Hand.

Parameters
rightCard

◆ __add__() [2/2]

def pybaccarat.baccarat.Hand.__add__ (   self,
  right 
)

Use the "+" operator to also add a Card to this Hand.

Parameters
rightCard

◆ __cmp__() [1/2]

def pybaccarat.baccarat.Hand.__cmp__ (   self,
  other 
)

Compare this hand to other hand.

Returns
0 if the two hands are equal, >0 if other hand has a greater value, <0 if other hand has a lesser value. The difference in value between the hands is also reflected in the magnitude of the difference here. If this hand has a value of 3 and other hand has a value of 5, then this compare method will return +2.

◆ __cmp__() [2/2]

def pybaccarat.baccarat.Hand.__cmp__ (   self,
  other 
)

Compare this hand to other hand.

Returns
0 if the two hands are equal, >0 if other hand has a greater value, <0 if other hand has a lesser value. The difference in value between the hands is also reflected in the magnitude of the difference here. If this hand has a value of 3 and other hand has a value of 5, then this compare method will return +2.

◆ __str__() [1/2]

def pybaccarat.baccarat.Hand.__str__ (   self)

Return the string representation for this hand.

This method overrights the method of the same name in the object class.

Returns
string with cards contained inside "[...]", comma separated

◆ __str__() [2/2]

def pybaccarat.baccarat.Hand.__str__ (   self)

Return the string representation for this hand.

This method overrights the method of the same name in the object class.

Returns
string with cards contained inside "[...]", comma separated

◆ add() [1/2]

def pybaccarat.baccarat.Hand.add (   self,
  new_card 
)

Add a card to the hand.

Parameters
new_cardthe card to add to the hand
Exceptions
ValueErrorRaised by either a non-type compatible Card, or too many cards already in this Hand.

◆ add() [2/2]

def pybaccarat.baccarat.Hand.add (   self,
  new_card 
)

Add a card to the hand.

Parameters
new_cardthe card to add to the hand
Exceptions
ValueErrorRaised by either a non-type compatible Card, or too many cards already in this Hand.

◆ get_card() [1/2]

def pybaccarat.baccarat.Hand.get_card (   self,
  index 
)

Return the specified card.

Parameters
indexinteger 0 to 2 indicates which Card of this Hand to return. If no such Card exists, then None is returned.

◆ get_card() [2/2]

def pybaccarat.baccarat.Hand.get_card (   self,
  index 
)

Return the specified card.

Parameters
indexinteger 0 to 2 indicates which Card of this Hand to return. If no such Card exists, then None is returned.

◆ is_natural() [1/2]

def pybaccarat.baccarat.Hand.is_natural (   self)

Is this hand a natural?

Returns
True for yes, False for no.

◆ is_natural() [2/2]

def pybaccarat.baccarat.Hand.is_natural (   self)

Is this hand a natural?

Returns
True for yes, False for no.

◆ need_hit() [1/2]

def pybaccarat.baccarat.Hand.need_hit (   self,
  other_hand 
)

Does this hand need to hit a third card? Checking if the player needs a third card, other_hand should be None.

The player's hand does not depend on the banker's hand. Only on itself. Checking if the banker needs a third card, other_hand should be the player's hand. The banker's third card decision is depends on the player's hand and cards.

Parameters
other_handbaccarat.Hand or None.
Returns
True if yes, False if no.

◆ need_hit() [2/2]

def pybaccarat.baccarat.Hand.need_hit (   self,
  other_hand 
)

Does this hand need to hit a third card? Checking if the player needs a third card, other_hand should be None.

The player's hand does not depend on the banker's hand. Only on itself. Checking if the banker needs a third card, other_hand should be the player's hand. The banker's third card decision is depends on the player's hand and cards.

Parameters
other_handbaccarat.Hand or None.
Returns
True if yes, False if no.

◆ value() [1/2]

def pybaccarat.baccarat.Hand.value (   self)

Get the baccarat hand value.

Returns
value of the hand

◆ value() [2/2]

def pybaccarat.baccarat.Hand.value (   self)

Get the baccarat hand value.

Returns
value of the hand

The documentation for this class was generated from the following file: