mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-09-22 04:50:46 +02:00
Consolidated constants that are duplicated in various constant files. Implemented dataclass methodoligies for tagging counter-related cards tagging
This commit is contained in:
parent
27ee13fb54
commit
039b8fe89e
6 changed files with 228 additions and 125 deletions
103
code/settings.py
103
code/settings.py
|
@ -1,27 +1,94 @@
|
|||
from __future__ import annotations
|
||||
|
||||
# Standard library imports
|
||||
import os
|
||||
from sys import exit
|
||||
from typing import Dict, List, Optional, Final, Tuple, Pattern, Union, Callable
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
# Third-party imports
|
||||
# ----------------------------------------------------------------------------------
|
||||
# COLOR CONSTANTS
|
||||
# ----------------------------------------------------------------------------------
|
||||
# NOTE:
|
||||
# Existing code in setup uses an ordered list (green before red) to align indices
|
||||
# with the parallel COLOR_ABRV list. The previously defined COLORS list had a
|
||||
# different ordering (red before green) which made it unsuitable for index based
|
||||
# mapping. To avoid subtle bugs we expose two explicit constants:
|
||||
# SETUP_COLORS -> ordering required for setup / abbreviation mapping
|
||||
# COLORS -> legacy superset including 'commander' (kept for compatibility)
|
||||
|
||||
COLORS = ['colorless', 'white', 'blue', 'black', 'red', 'green',
|
||||
'azorius', 'orzhov', 'selesnya', 'boros', 'dimir',
|
||||
'simic', 'izzet', 'golgari', 'rakdos', 'gruul',
|
||||
'bant', 'esper', 'grixis', 'jund', 'naya',
|
||||
'abzan', 'jeskai', 'mardu', 'sultai', 'temur',
|
||||
'dune', 'glint', 'ink', 'witch', 'yore', 'wubrg',
|
||||
'commander']
|
||||
SETUP_COLORS: List[str] = [
|
||||
'colorless', 'white', 'blue', 'black', 'green', 'red',
|
||||
'azorius', 'orzhov', 'selesnya', 'boros', 'dimir',
|
||||
'simic', 'izzet', 'golgari', 'rakdos', 'gruul',
|
||||
'bant', 'esper', 'grixis', 'jund', 'naya',
|
||||
'abzan', 'jeskai', 'mardu', 'sultai', 'temur',
|
||||
'dune', 'glint', 'ink', 'witch', 'yore', 'wubrg'
|
||||
]
|
||||
|
||||
COLOR_ABRV: List[str] = ['Colorless', 'W', 'U', 'B', 'G', 'R',
|
||||
'U, W', 'B, W', 'G, W', 'R, W', 'B, U',
|
||||
'G, U', 'R, U', 'B, G', 'B, R', 'G, R',
|
||||
'G, U, W', 'B, U, W', 'B, R, U', 'B, G, R', 'G, R, W',
|
||||
'B, G, W', 'R, U, W', 'B, R, W', 'B, G, U', 'G, R, U',
|
||||
'B, G, R, W', 'B, G, R, U', 'G, R, U, W', 'B, G, U, W',
|
||||
'B, R, U, W', 'B, G, R, U, W']
|
||||
# Legacy constant (includes 'commander', preserves previous external usage)
|
||||
COLORS: List[str] = [
|
||||
*SETUP_COLORS,
|
||||
'commander'
|
||||
]
|
||||
|
||||
COLOR_ABRV: List[str] = [
|
||||
'Colorless', 'W', 'U', 'B', 'G', 'R',
|
||||
'U, W', 'B, W', 'G, W', 'R, W', 'B, U',
|
||||
'G, U', 'R, U', 'B, G', 'B, R', 'G, R',
|
||||
'G, U, W', 'B, U, W', 'B, R, U', 'B, G, R', 'G, R, W',
|
||||
'B, G, W', 'R, U, W', 'B, R, W', 'B, G, U', 'G, R, U',
|
||||
'B, G, R, W', 'B, G, R, U', 'G, R, U, W', 'B, G, U, W',
|
||||
'B, R, U, W', 'B, G, R, U, W'
|
||||
]
|
||||
|
||||
# Convenience mapping from long color name to primary abbreviation
|
||||
PRIMARY_COLOR_ABBR_MAP: Dict[str, str] = {
|
||||
'colorless': 'Colorless', 'white': 'W', 'blue': 'U', 'black': 'B', 'green': 'G', 'red': 'R'
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# CARD / DATAFRAME COLUMN CONSTANTS
|
||||
# ----------------------------------------------------------------------------------
|
||||
# Unified column definition used across setup, tagging, and deck building modules.
|
||||
# This consolidates previously duplicated lists: COLUMN_ORDER, TAGGED_COLUMN_ORDER,
|
||||
# REQUIRED_COLUMNS (tag_constants), and CSV_REQUIRED_COLUMNS (builder_constants).
|
||||
CARD_DATA_COLUMNS: List[str] = [
|
||||
'name', 'faceName', 'edhrecRank', 'colorIdentity', 'colors',
|
||||
'manaCost', 'manaValue', 'type', 'creatureTypes', 'text',
|
||||
'power', 'toughness', 'keywords', 'themeTags', 'layout', 'side'
|
||||
]
|
||||
|
||||
# Alias for semantic clarity in different contexts
|
||||
REQUIRED_CARD_COLUMNS = CARD_DATA_COLUMNS # Validation
|
||||
CARD_COLUMN_ORDER = CARD_DATA_COLUMNS # Output / ordering
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# MENU / UI CONSTANTS
|
||||
# ----------------------------------------------------------------------------------
|
||||
MAIN_MENU_ITEMS: List[str] = ['Build A Deck', 'Setup CSV Files', 'Tag CSV Files', 'Quit']
|
||||
SETUP_MENU_ITEMS: List[str] = ['Initial Setup', 'Regenerate CSV', 'Main Menu']
|
||||
|
||||
CSV_DIRECTORY: str = 'csv_files'
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# DATAFRAME NA HANDLING
|
||||
# ----------------------------------------------------------------------------------
|
||||
FILL_NA_COLUMNS: Dict[str, Optional[str]] = {
|
||||
'colorIdentity': 'Colorless', # Default color identity for cards without one
|
||||
'faceName': None # Use card's name column value when face name is not available
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# SPECIAL CARD EXCEPTIONS
|
||||
# ----------------------------------------------------------------------------------
|
||||
MULTIPLE_COPY_CARDS = [
|
||||
'Dragon\'s Approach', 'Hare Apparent', 'Nazgûl', 'Persistent Petitioners',
|
||||
'Rat Colony', 'Relentless Rats', 'Seven Dwarves', 'Shadowborn Apostle',
|
||||
'Slime Against Humanity', 'Templar Knight'
|
||||
]
|
||||
|
||||
# Backwards compatibility exports (older modules may still import these names)
|
||||
COLUMN_ORDER = CARD_COLUMN_ORDER
|
||||
TAGGED_COLUMN_ORDER = CARD_COLUMN_ORDER
|
||||
REQUIRED_COLUMNS = REQUIRED_CARD_COLUMNS
|
||||
|
||||
MAIN_MENU_ITEMS: List[str] = ['Build A Deck', 'Setup CSV Files', 'Tag CSV Files', 'Quit']
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue