Skip to content

Commit

Permalink
Fixes CardVisual and adds TODO.md
Browse files Browse the repository at this point in the history
  • Loading branch information
workonfire committed May 9, 2021
1 parent cc495e5 commit 29052da
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 55 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ It's best to look at the `#TODO` notes inside files.
No screenshots for now, because the current interface is just temporary.

To-do features:
- Easy to use API
- Multiplayer
- Interface (cards etc.) displayed as ASCII art
- Cheat system based on pure Python console
- Fully customizable rooms with custom game rules
[TODO.yml](TODO.md)

#### CLI switches
- `--debug` or `-D` - always shows the opponent's cards
Expand Down
20 changes: 20 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To-do list

Goals:
- Easy to use API
- Multiplayer
- Interface (cards etc.) displayed as ASCII art with ncurses
- Fully customizable rooms with custom game rules

What to implement:
- A serious queue system that supports more than two players
- Try to remember what functional cards were skipped due to lack of a queue system
- Tab-completion
- More verbose `--debug` option
- A plugin system? (like `plugins/something-trigger.py`)
- A custom rules system (`Dict[str, Any]`), this includes:
- bluffing
- option to pass when drawing cards
- A menu
- Auto-save system
- Aliases like `4B`, `*` and auto-correction like `4lbue` -> `4 BLUE`
81 changes: 36 additions & 45 deletions uno/enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from enum import Enum, auto
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from uno.game import Card


class Type(Enum):
Expand Down Expand Up @@ -32,31 +36,35 @@ class CardType(Type):


class CardVisual:
CARD_1: str = """________________
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░░░░██╗░░░░░▌
▌░░░░░███║░░░░░▌
▌░░░░░╚██║░░░░░▌
▌░░░░░░██║░░░░░▌
▌░░░░░░██║░░░░░▌
▌░░░░░░╚═╝░░░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯"""
CARD_2: str = """________________
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░██████╗░░░░▌
▌░░░╚════██╗░░░▌
▌░░░░█████╔╝░░░▌
▌░░░██╔═══╝░░░░▌
▌░░░███████╗░░░▌
▌░░░╚══════╝░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯"""
CARD_3: str = """""" # TODO
CARD_0: str = """"""
CARD_1: str = """
________________
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░░░░██╗░░░░░▌
▌░░░░░███║░░░░░▌
▌░░░░░╚██║░░░░░▌
▌░░░░░░██║░░░░░▌
▌░░░░░░██║░░░░░▌
▌░░░░░░╚═╝░░░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
"""
CARD_2: str = """
________________
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░██████╗░░░░▌
▌░░░╚════██╗░░░▌
▌░░░░█████╔╝░░░▌
▌░░░██╔═══╝░░░░▌
▌░░░███████╗░░░▌
▌░░░╚══════╝░░░▌
▌░░░░░░░░░░░░░░▌
▌░░░░░░░░░░░░░░▌
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯"""
CARD_3: str = """"""
CARD_4: str = """"""
CARD_5: str = """"""
CARD_6: str = """"""
Expand All @@ -69,23 +77,6 @@ class CardVisual:
CARD_WILDCARD: str = """"""
CARD_REVERSE: str = """"""

def __init__(self, card):
self.card = card

@property
def art(self) -> str: # TODO: get rid of the dictionary
types = {'1': self.CARD_1,
'2': self.CARD_2,
'3': self.CARD_3,
'4': self.CARD_4,
'5': self.CARD_5,
'6': self.CARD_6,
'7': self.CARD_7,
'8': self.CARD_8,
'9': self.CARD_9,
'+2': self.CARD_PLUS_2,
'+4': self.CARD_PLUS_4,
'SKIP': self.CARD_SKIP,
'WILDCARD': self.CARD_WILDCARD,
'REVERSE': self.CARD_REVERSE}
return types.get(self.card.card_type)
def __init__(self, card: 'Card'):
self.card: 'Card' = card
self.art: str = getattr(self, self.card.card_type.name)
7 changes: 3 additions & 4 deletions uno/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __eq__(self, other: object) -> bool:
@staticmethod
def from_str(value: str) -> 'Card':
card_type, card_color = value.upper().split(' ')
return Card(getattr(CardType, "CARD_" + card_type.replace('+ ', 'PLUS_')), getattr(CardColor, card_color))
return Card(getattr(CardType, "CARD_" + card_type.replace('+', 'PLUS_')), getattr(CardColor, card_color))

def playable(self, comparator: 'Card') -> bool:
"""
Expand All @@ -53,10 +53,9 @@ def display(self, centered: bool = False):
Creates a visual representation of the card.
:param centered: whether to center the card on the display, or not
"""
card_to_display: str = CardVisual(self).art
if centered:
card_to_display: str = '\n'.join(CardVisual(self).art).center(get_terminal_size().columns)
else:
card_to_display: str = '\n'.join(CardVisual(self).art)
card_to_display = card_to_display.center(get_terminal_size().columns)
print(getattr(Fore, self.color.name) + card_to_display + Fore.RESET)


Expand Down
3 changes: 2 additions & 1 deletion uno/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def main():
f"{len(game.opponent.hand)}")
else:
print(f"Your cards: {game.turn.hand}")
# game.last_played_card.display()
print(Fore.LIGHTMAGENTA_EX + f"Current card: {game.last_played_card}", Fore.RESET)
card = None
card_input: str = input("Card (e.g. 4 BLUE, Enter to draw): ")
Expand All @@ -76,7 +77,7 @@ def main():
print(Fore.RED + "Can't draw more cards." + Fore.RESET)
else:
if card_input in ('WILDCARD', '+4'):
card = Card(CardType["CARD_" + card_input.upper().replace('+', "PLUS_")], None) # TODO
card = Card(CardType["CARD_" + card_input.upper().replace('+', "PLUS_")], None)
else:
try:
card = Card.from_str(card_input)
Expand Down

0 comments on commit 29052da

Please sign in to comment.