From 2c421727e5a05f027a31e6935a6c7ec3e04e32d5 Mon Sep 17 00:00:00 2001 From: Brennen Raimer Date: Fri, 10 Apr 2020 16:23:34 -0400 Subject: [PATCH] add Hand and NullCollections --- BearOnline/cards/collections/__init__.py | 6 ++++- BearOnline/cards/collections/_hand.py | 6 +++++ .../cards/collections/_nullcollection.py | 26 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 BearOnline/cards/collections/_hand.py create mode 100644 BearOnline/cards/collections/_nullcollection.py diff --git a/BearOnline/cards/collections/__init__.py b/BearOnline/cards/collections/__init__.py index 8b13789..5b08f36 100644 --- a/BearOnline/cards/collections/__init__.py +++ b/BearOnline/cards/collections/__init__.py @@ -1 +1,5 @@ - +from ._cardcollection import CardCollection +from ._deck import Deck +from ._playingcarddeck import PlayingCardDeck +from ._nullcollection import NullDeck +from ._hand import Hand diff --git a/BearOnline/cards/collections/_hand.py b/BearOnline/cards/collections/_hand.py new file mode 100644 index 0000000..dfffbd2 --- /dev/null +++ b/BearOnline/cards/collections/_hand.py @@ -0,0 +1,6 @@ +from ._cardcollection import CardCollection + +class Hand(CardCollection): + def __init__(self, max_handsize=None): + super().__init__([], max_handsize) + \ No newline at end of file diff --git a/BearOnline/cards/collections/_nullcollection.py b/BearOnline/cards/collections/_nullcollection.py new file mode 100644 index 0000000..5523e0b --- /dev/null +++ b/BearOnline/cards/collections/_nullcollection.py @@ -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") \ No newline at end of file