add Hand and NullCollections
This commit is contained in:
@@ -1 +1,5 @@
|
|||||||
|
from ._cardcollection import CardCollection
|
||||||
|
from ._deck import Deck
|
||||||
|
from ._playingcarddeck import PlayingCardDeck
|
||||||
|
from ._nullcollection import NullDeck
|
||||||
|
from ._hand import Hand
|
||||||
|
|||||||
6
BearOnline/cards/collections/_hand.py
Normal file
6
BearOnline/cards/collections/_hand.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from ._cardcollection import CardCollection
|
||||||
|
|
||||||
|
class Hand(CardCollection):
|
||||||
|
def __init__(self, max_handsize=None):
|
||||||
|
super().__init__([], max_handsize)
|
||||||
|
|
||||||
26
BearOnline/cards/collections/_nullcollection.py
Normal file
26
BearOnline/cards/collections/_nullcollection.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from ._deck import Deck
|
||||||
|
|
||||||
|
|
||||||
|
class NullDeck(Deck):
|
||||||
|
def __init__(self):
|
||||||
|
"""Initializes an empty deck that can never contain cards. Useful as a placeholder to prevent cards from being played to a space.
|
||||||
|
"""
|
||||||
|
super().__init__([], 0)
|
||||||
|
|
||||||
|
def __add__(self, *args, **kwargs):
|
||||||
|
raise NotImplementedError("Cards can not be added to a NullDeck")
|
||||||
|
|
||||||
|
def __iadd__(self, *args, **kwargs):
|
||||||
|
raise NotImplementedError("Cards can not be added to a NullDeck")
|
||||||
|
|
||||||
|
def append(self, *args, **kwargs):
|
||||||
|
raise NotImplementedError("Cards can not be added to a NullDeck")
|
||||||
|
|
||||||
|
def appendleft(self, *args, **kwargs):
|
||||||
|
raise NotImplementedError("Cards can not be added to a NullDeck")
|
||||||
|
|
||||||
|
def extend(self, *args, **kwargs):
|
||||||
|
raise NotImplementedError("Cards can not be added to a NullDeck")
|
||||||
|
|
||||||
|
def extendleft(self, *args, **kwargs):
|
||||||
|
raise NotImplementedError("Cards can not be added to a NullDeck")
|
||||||
Reference in New Issue
Block a user