-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mypy everything * run mypy over everything * add gin rummy [wip] ' * add more gin rummy logic * turns * fx mypy * OK * do it * gin rummy * OK * deadwood calculation * deadwood is done * types * OK
- Loading branch information
Showing
21 changed files
with
1,413 additions
and
792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
""" constants to build the deck of cards and score the game """ | ||
|
||
ranks = list('23456789TJQKA') | ||
suits = list('cdhs') | ||
from typing import List, Tuple | ||
|
||
cards = [f'{r}{s}' for r in ranks for s in suits] | ||
ranks: List[str] = list("23456789TJQKA") | ||
suits: List[str] = list("cdhs") | ||
|
||
card_choices = [(f'{rank}{suit}', f'{rank} of {suit}') | ||
for (rank, suit) in cards] | ||
cards: List[str] = [f"{r}{s}" for r in ranks for s in suits] | ||
_cards_rds: List[Tuple[str, str]] = [(r, s) for r in ranks for s in suits] | ||
|
||
suit_ids = {'c': 0, 'd': 1, 'h': 2, 's': 3} | ||
card_choices = [ | ||
(f"{rank}{suit}", f"{rank} of {suit}") for (rank, suit) in _cards_rds | ||
] | ||
|
||
suit_ids = {"c": 0, "d": 1, "h": 2, "s": 3} | ||
rank_ids = {rank: index for index, rank in enumerate(ranks)} | ||
|
||
card_id_map = {card: index for index, card in enumerate(cards)} | ||
reverse_card_id_map = {index: card for card, index in card_id_map.items()} | ||
|
||
digit_map = {d: int(d) for d in '23456789'} | ||
common_rank_to_value = {'T': 10, 'J': 11, 'Q': 12, 'K': 13} | ||
digit_map = {d: int(d) for d in "23456789"} | ||
common_rank_to_value = {"T": 10, "J": 11, "Q": 12, "K": 13} | ||
common_rank_to_value.update(digit_map) | ||
|
||
ace_high_rank_to_value = {'A': 14} | ||
ace_high_rank_to_value = {"A": 14} | ||
ace_high_rank_to_value.update(common_rank_to_value) | ||
|
||
ace_low_rank_to_value = {'A': 1} | ||
ace_low_rank_to_value = {"A": 1} | ||
ace_low_rank_to_value.update(common_rank_to_value) | ||
|
||
rank_to_value = ace_low_rank_to_value | ||
|
||
value_to_rank = {14: 'A', 1: 'A'} | ||
value_to_rank = {14: "A", 1: "A"} | ||
value_to_rank.update({v: r for r, v in common_rank_to_value.items()}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.