# deck


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/deck.py#L13"
target="_blank" style="float:right; font-size:smaller">source</a>

### Deck

>  Deck ()

*A deck of 52 cards not including jockers*

When we initially create a deck, all cards will be present:

``` python
deck = Deck()
deck
```

    A, ♣; 2, ♣; 3, ♣; 4, ♣; 5, ♣; 6, ♣; 7, ♣; 8, ♣; 9, ♣; 10, ♣; J, ♣; Q, ♣; K, ♣; A, ♦; 2, ♦; 3, ♦; 4, ♦; 5, ♦; 6, ♦; 7, ♦; 8, ♦; 9, ♦; 10, ♦; J, ♦; Q, ♦; K, ♦; A, ♥; 2, ♥; 3, ♥; 4, ♥; 5, ♥; 6, ♥; 7, ♥; 8, ♥; 9, ♥; 10, ♥; J, ♥; Q, ♥; K, ♥; A, ♠; 2, ♠; 3, ♠; 4, ♠; 5, ♠; 6, ♠; 7, ♠; 8, ♠; 9, ♠; 10, ♠; J, ♠; Q, ♠; K, ♠

That should be 52 cards:

``` python
test_eq(len(deck), 52)
```

As a reminder, these are the suits that we defined for a
[`Card`](https://rdned.github.io/nbdev_cards3.14/card.html#card):

``` python
suits
```

    ['♣', '♦', '♥', '♠']

We can check, say, if the Ace of Clubs is in the deck:

``` python
Card(1,1) in deck
```

    True

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/deck.py#L26"
target="_blank" style="float:right; font-size:smaller">source</a>

### Deck.pop

>  Deck.pop (idx:int=-1)

*Remove one card from the deck*

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>idx</td>
<td>int</td>
<td>-1</td>
<td>The index of the card to remove, defaulting to the last one</td>
</tr>
</tbody>
</table>

``` python
deck = Deck()
test_eq(deck.pop(), Card(3,13))   # The K "\u2660"
```

``` python
test_eq(len(deck), 51)
```

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/deck.py#L35"
target="_blank" style="float:right; font-size:smaller">source</a>

### Deck.remove

>  Deck.remove (card:nbdev_cards.card.Card)

*Removes cards from the deck or raises exception if it is not there*

<table>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>card</td>
<td>Card</td>
<td>Card to remove</td>
</tr>
</tbody>
</table>

``` python
card23 = Card(2,3)
deck.remove(card23)

assert card23 not in deck
```

------------------------------------------------------------------------

<a
href="https://github.com/rdned/nbdev_cards3.14/blob/main/nbdev_cards/deck.py#L41"
target="_blank" style="float:right; font-size:smaller">source</a>

### draw_n

>  draw_n (n:int, replace:bool=True)

*Draw `n` cards, with replacement iif `replace`*

<table>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>n</td>
<td>int</td>
<td></td>
<td>number of cards to draw</td>
</tr>
<tr>
<td>replace</td>
<td>bool</td>
<td>True</td>
<td>whether or not draw with replacement</td>
</tr>
</tbody>
</table>

``` python
Card??
```

    Init signature: Card(suit: int, rank: int)
    Source:        
    class Card:
        "A playing card"
        def __init__(self, 
                     suit: int, # An index into suits
                     rank: int  # An index into ranks
                     ):
            self.suit = suit
            self.rank = rank

        def __str__(self):
            return f"{ranks[self.rank]}, {suits[self.suit]}"
        
        __repr__ = __str__
    File:           ~/Projects/GitHub/nbdev_cards/nbdev_cards/card.py
    Type:           type
    Subclasses:     
