mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-17 08:00:13 +01:00
Redid setup logic, started adding more logic to deckbuilding
This commit is contained in:
parent
0ecf34210b
commit
d19c3c6db6
4 changed files with 270 additions and 611 deletions
162
deck_builder.py
162
deck_builder.py
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import inflect
|
||||
import inquirer.prompt # type: ignore
|
||||
import pandas as pd # type: ignore
|
||||
import pprint # type: ignore
|
||||
|
|
@ -16,6 +17,16 @@ pd.set_option('display.max_columns', None)
|
|||
pd.set_option('display.max_rows', None)
|
||||
pd.set_option('display.max_colwidth', 5)
|
||||
|
||||
"""def pluralize_list(singular_list):
|
||||
engine = inflect.engine()
|
||||
plural_list = [engine.plural(creature_type) for creature_type in singular_list]
|
||||
return plural_list
|
||||
|
||||
singular_words = settings.creature_types
|
||||
plural_words = pluralize_list(singular_words)
|
||||
creature_type_list = settings.creature_types + plural_words"""
|
||||
#print(plural_words)
|
||||
|
||||
# Basic deck builder, initial plan will just be for kindred support.
|
||||
# Would like to add logic for other themes, as well as automatically go
|
||||
# through the commander and find suitable themes.
|
||||
|
|
@ -35,7 +46,7 @@ class DeckBuilder:
|
|||
self.color_identity = ''
|
||||
self.colors = []
|
||||
self.creature_types = []
|
||||
self.info_tags = []
|
||||
self.commander_tags = []
|
||||
self.commander_df = pd.DataFrame()
|
||||
|
||||
# Library (99 cards total)
|
||||
|
|
@ -62,37 +73,37 @@ class DeckBuilder:
|
|||
# Cards that are what type
|
||||
# Lands
|
||||
self.land_cards = []
|
||||
self.lands = len(self.land_cards)
|
||||
|
||||
# Creatures
|
||||
self.creature_cards = []
|
||||
self.creatures = len(self.creature_cards)
|
||||
|
||||
# Instants
|
||||
self.instant_cards = []
|
||||
self.instants = len(self.creature_cards)
|
||||
|
||||
# Sorceries
|
||||
self.sorcery_cards = []
|
||||
self.sorceries = len(self.sorcery_cards)
|
||||
|
||||
# Artifacts
|
||||
self.artifact_cards = []
|
||||
self.artifacts = len(self.artifact_cards)
|
||||
|
||||
# Enchantments
|
||||
self.enchantment_cards = []
|
||||
self.enchantments = len(self.enchantment_cards)
|
||||
|
||||
# Planeswalkers
|
||||
self.planeswalker_cards = []
|
||||
self.planeswalkers = len(self.planeswalker_cards)
|
||||
|
||||
# Battles
|
||||
self.battle_cards = []
|
||||
self.battles = len(self.battle_cards)
|
||||
|
||||
def determine_commander(self):
|
||||
# Setup dataframe
|
||||
try:
|
||||
df = pd.read_csv('csv_files/legendary_cards.csv')
|
||||
except FileNotFoundError:
|
||||
determine_legendary()
|
||||
df = pd.read_csv('csv_files/legendary_cards.csv')
|
||||
# Determine the commander of the deck
|
||||
|
||||
commander_chosen = False
|
||||
while not commander_chosen:
|
||||
print('Enter a card name to be your commander, note that at this time only cards that have the \'Creature\' type may be chosen')
|
||||
|
|
@ -106,37 +117,63 @@ class DeckBuilder:
|
|||
card_choice = answer['card_prompt']
|
||||
|
||||
# Logic to find the card in the legendary_cards csv, then display it's information
|
||||
try:
|
||||
df = pd.read_csv('csv_files/legendary_cards.csv')
|
||||
except FileNotFoundError:
|
||||
determine_legendary()
|
||||
df = pd.read_csv('csv_files/legendary_cards.csv')
|
||||
fuzzy_card_choice = process.extractOne(card_choice, df['name'], scorer=fuzz.ratio)
|
||||
fuzzy_card_choice = fuzzy_card_choice[0]
|
||||
filtered_df = df[df['name'] == fuzzy_card_choice]
|
||||
columns_to_keep = ['name', 'colorIdentity', 'colors', 'manaCost', 'manaValue', 'type', 'keywords', 'power', 'toughness', 'text']
|
||||
filtered_df = filtered_df[columns_to_keep]
|
||||
df_dict = filtered_df.to_dict('list')
|
||||
print('Is this the card you chose?')
|
||||
pprint.pprint(df_dict, sort_dicts=False)
|
||||
self.commander_df = pd.DataFrame(df_dict)
|
||||
# If the card can't be found, or doesn't have enough of a match score, display a
|
||||
# list to choose from
|
||||
print(card_choice)
|
||||
fuzzy_chosen = False
|
||||
while not fuzzy_chosen:
|
||||
match, score, something = process.extractOne(card_choice, df['name'])
|
||||
if score >= 90:
|
||||
fuzzy_card_choice = match
|
||||
print(fuzzy_card_choice)
|
||||
fuzzy_chosen = True
|
||||
else:
|
||||
print('Multiple options found, which is correct?')
|
||||
fuzzy_card_choices = process.extract(card_choice, df['name'], limit=5)
|
||||
fuzzy_card_choices.append('Neither')
|
||||
print(fuzzy_card_choices)
|
||||
question = [
|
||||
inquirer.List('choices',
|
||||
choices=fuzzy_card_choices,
|
||||
carousel=True)
|
||||
]
|
||||
answer = inquirer.prompt(question)
|
||||
fuzzy_card_choice = answer['choices']
|
||||
if fuzzy_card_choice != 'Neither':
|
||||
fuzzy_card_choice = fuzzy_card_choice[0]
|
||||
print(fuzzy_card_choice)
|
||||
fuzzy_chosen = True
|
||||
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
filtered_df = df[df['name'] == fuzzy_card_choice]
|
||||
columns_to_keep = ['name', 'colorIdentity', 'colors', 'manaCost', 'manaValue', 'type', 'keywords', 'power', 'toughness', 'text']
|
||||
filtered_df = filtered_df[columns_to_keep]
|
||||
df_dict = filtered_df.to_dict('list')
|
||||
print('Is this the card you chose?')
|
||||
pprint.pprint(df_dict, sort_dicts=False)
|
||||
self.commander_df = pd.DataFrame(df_dict)
|
||||
|
||||
# Confirm if card entered was correct
|
||||
correct_commander = [
|
||||
inquirer.Confirm(
|
||||
'commander',
|
||||
)
|
||||
]
|
||||
confirm_commander = inquirer.prompt(correct_commander)
|
||||
commander_confirmed = confirm_commander['commander']
|
||||
# If correct, set it as the commander
|
||||
if commander_confirmed:
|
||||
commander_chosen = True
|
||||
self.commander_info = df_dict
|
||||
self.commander = self.commander_df.at[0, 'name']
|
||||
break
|
||||
#print(self.commander)
|
||||
else:
|
||||
commander_chosen = False
|
||||
|
||||
# Confirm if card entered was correct
|
||||
correct_commander = [
|
||||
inquirer.Confirm(
|
||||
'commander',
|
||||
)
|
||||
]
|
||||
confirm_commander = inquirer.prompt(correct_commander)
|
||||
commander_confirmed = confirm_commander['commander']
|
||||
# If correct, set it as the commander
|
||||
if commander_confirmed:
|
||||
commander_chosen = True
|
||||
self.commander_info = df_dict
|
||||
self.commander = self.commander_df.at[0, 'name']
|
||||
#print(self.commander)
|
||||
else:
|
||||
commander_chosen = False
|
||||
|
||||
# Send commander info to setup commander, including extracting info on colors, color identity,
|
||||
# creature types, and other information, like keywords, abilities, etc...
|
||||
|
|
@ -167,34 +204,41 @@ class DeckBuilder:
|
|||
|
||||
def set_creature_types(self, df):
|
||||
# Set creature types
|
||||
types = df.at[0, 'type']
|
||||
print(types)
|
||||
split_types = types.split()
|
||||
for type in split_types:
|
||||
if type not in settings.non_creature_types:
|
||||
self.creature_types.append(type)
|
||||
creature_types = df.at[0, 'type']
|
||||
#print(creature_types)
|
||||
split_types = creature_types.split()
|
||||
for creature_type in split_types:
|
||||
if creature_type not in settings.non_creature_types:
|
||||
self.creature_types.append(creature_type)
|
||||
for creature_type in self.creature_types:
|
||||
self.commander_tags.append(creature_type)
|
||||
|
||||
def setup_deck_tags(self, df):
|
||||
# Determine card tags, such as counters theme
|
||||
"""keywords = df.at[0, 'keywords'].split()
|
||||
for keyword in keywords:
|
||||
settings.theme_tags.append(keyword.lower())
|
||||
print(settings.theme_tags)"""
|
||||
self.check_tags(df.at[0, 'text'].lower(), settings.theme_tags, threshold=80)
|
||||
|
||||
self.check_tags(df.at[0, 'text'], settings.theme_tags)
|
||||
#print(card_tags)
|
||||
# Determine any additional kindred tags that aren't in the main creature types
|
||||
self.check_tags(df.at[0, 'text'].lower(), settings.creature_types, threshold=100)
|
||||
|
||||
def check_tags(self, string, word_list, threshold=80):
|
||||
def check_tags(self, string, word_list, threshold):
|
||||
card_tags = []
|
||||
print(string)
|
||||
#print(word_list)
|
||||
for word in word_list:
|
||||
#print(word)
|
||||
if word == '+1/+1 counter' or word == '-1/-1 counter':
|
||||
#print(word)
|
||||
threshold += 20
|
||||
if fuzz.partial_ratio(string.lower(), word.lower()) >= threshold:
|
||||
if fuzz.partial_ratio(string, word.lower()) >= threshold:
|
||||
print(word, threshold)
|
||||
card_tags.append(word)
|
||||
#print(word)
|
||||
#return True
|
||||
#return False
|
||||
self.commander_tags = card_tags
|
||||
for tag in card_tags:
|
||||
if tag not in self.commander_tags:
|
||||
self.commander_tags.append(tag)
|
||||
|
||||
|
||||
def determine_ideals(self):
|
||||
# "Free" slots that can be used for anything that isn't the ideals
|
||||
|
|
@ -380,12 +424,12 @@ class DeckBuilder:
|
|||
print(f'Adding the creatures to deck, a baseline based on the ideal creature count of {self.ideal_creature_count} will be used.')
|
||||
|
||||
build_deck = DeckBuilder()
|
||||
"""build_deck.determine_commander()
|
||||
build_deck.determine_commander()
|
||||
print(f'Commander: {build_deck.commander}')
|
||||
print(f'Color Identity: {build_deck.color_identity}')
|
||||
print(f'Commander Colors: {build_deck.colors}')
|
||||
print(f'Commander Creature Types: {build_deck.creature_types}')
|
||||
print(f'Commander tags: {build_deck.commander_tags}')"""
|
||||
build_deck.determine_commander()
|
||||
build_deck.ideal_land_count = 35
|
||||
build_deck.add_lands()
|
||||
print(f'Commander tags: {build_deck.commander_tags}')
|
||||
#build_deck.determine_commander()
|
||||
#build_deck.ideal_land_count = 35
|
||||
#build_deck.add_lands()
|
||||
21
main.py
21
main.py
|
|
@ -16,32 +16,20 @@ Path('csv_files').mkdir(parents=True, exist_ok=True)
|
|||
Path('staples').mkdir(parents=True, exist_ok=True)
|
||||
|
||||
while True:
|
||||
print('What would you like to do?')
|
||||
choice = 'Menu'
|
||||
while choice == 'Menu':
|
||||
question = [
|
||||
inquirer.List('menu',
|
||||
message='What would you like to do?',
|
||||
choices=['Initial Setup', 'Regenerate Card CSVs', 'Setup Staples', 'Build a Deck', 'Get Card Info', 'Quit'],
|
||||
choices=['Setup', 'Build a Deck', 'Get Card Info', 'Quit'],
|
||||
carousel=True)
|
||||
]
|
||||
answer = inquirer.prompt(question)
|
||||
choice = answer['menu']
|
||||
|
||||
# Run through initial setup
|
||||
while choice == 'Initial Setup':
|
||||
setup.initial_setup()
|
||||
choice = 'Menu'
|
||||
break
|
||||
|
||||
# Run through csv regeneration
|
||||
while choice == 'Regenerate Card CSVs':
|
||||
setup.regenerate_csvs()
|
||||
choice = 'Menu'
|
||||
break
|
||||
|
||||
# Setup staples
|
||||
while choice == 'Setup Staples':
|
||||
setup.generate_staple_lists()
|
||||
while choice == 'Setup':
|
||||
setup.setup()
|
||||
choice = 'Menu'
|
||||
break
|
||||
|
||||
|
|
@ -70,3 +58,4 @@ while True:
|
|||
# Quit
|
||||
while choice == 'Quit':
|
||||
sys.exit()
|
||||
break
|
||||
71
settings.py
71
settings.py
|
|
@ -28,17 +28,82 @@ non_creature_types = ['Legendary', 'Creature', 'Enchantment', 'Artifact',
|
|||
'Cave', 'Desert', 'Gate', 'Lair', 'Locus', 'Mine',
|
||||
'Power-Plant', 'Sphere', 'Tower', 'Urza\'s']
|
||||
|
||||
theme_tags = ['+1/+1 counter', 'one or more counters', 'tokens', 'gain life', 'one or more creature tokens',
|
||||
creature_types = ['Advisor', 'Aetherborn', 'Alien', 'Ally', 'Angel', 'Antelope', 'Ape', 'Archer', 'Archon', 'Armadillo',
|
||||
'Army', 'Artificer', 'Assassin', 'Assembly-Worker', 'Astartes', 'Atog', 'Aurochs', 'Automaton',
|
||||
'Avatar', 'Azra', 'Badger', 'Balloon', 'Barbarian', 'Bard', 'Basilisk', 'Bat', 'Bear', 'Beast', 'Beaver',
|
||||
'Beeble', 'Beholder', 'Berserker', 'Bird', 'Blinkmoth', 'Boar', 'Brainiac', 'Bringer', 'Brushwagg',
|
||||
'C\'tan', 'Camarid', 'Camel', 'Capybara', 'Caribou', 'Carrier', 'Cat', 'Centaur', 'Chicken', 'Child',
|
||||
'Chimera', 'Citizen', 'Cleric', 'Clown', 'Cockatrice', 'Construct', 'Coward', 'Coyote', 'Crab', 'Crocodile',
|
||||
'Custodes', 'Cyberman', 'Cyclops', 'Dalek', 'Dauthi', 'Demigod', 'Demon', 'Deserter', 'Detective', 'Devil',
|
||||
'Dinosaur', 'Djinn', 'Doctor', 'Dog', 'Dragon', 'Drake', 'Dreadnought', 'Drone', 'Druid', 'Dryad', 'Dwarf',
|
||||
'Efreet', 'Egg', 'Elder', 'Eldrazi', 'Elemental', 'Elephant', 'Elf', 'Elk', 'Employee', 'Eye', 'Faerie',
|
||||
'Ferret', 'Fish', 'Flagbearer', 'Fox', 'Fractal', 'Frog', 'Fungus', 'Gamer', 'Gargoyle', 'Germ', 'Giant',
|
||||
'Gith', 'Glimmer', 'Gnoll', 'Gnome', 'Goat', 'Goblin', 'God', 'Golem', 'Gorgon', 'Graveborn', 'Gremlin',
|
||||
'Griffin', 'Guest', 'Hag', 'Halfling', 'Hamster', 'Harpy', 'Head', 'Hellion', 'Hero', 'Hippo', 'Hippogriff',
|
||||
'Homarid', 'Homunculus', 'Hornet', 'Horror', 'Horse', 'Human', 'Hydra', 'Hyena', 'Illusion', 'Imp',
|
||||
'Incarnation', 'Inkling', 'Inquisitor', 'Insect', 'Jackal', 'Jellyfish', 'Juggernaut', 'Kavu', 'Kirin',
|
||||
'Kithkin', 'Knight', 'Kobold', 'Kor', 'Kraken', 'Lamia', 'Lammasu', 'Leech', 'Leviathan', 'Lhurgoyf',
|
||||
'Licid', 'Lizard', 'Manticore', 'Masticore', 'Mercenary', 'Merfolk', 'Metathran', 'Minion', 'Minotaur',
|
||||
'Mite', 'Mole', 'Monger', 'Mongoose', 'Monk', 'Monkey', 'Moonfolk', 'Mount', 'Mouse', 'Mutant', 'Myr',
|
||||
'Mystic', 'Naga', 'Nautilus', 'Necron', 'Nephilim', 'Nightmare', 'Nightstalker', 'Ninja', 'Noble', 'Noggle',
|
||||
'Nomad', 'Nymph', 'Octopus', 'Ogre', 'Ooze', 'Orb', 'Orc', 'Orgg', 'Otter', 'Ouphe', 'Ox', 'Oyster', 'Pangolin',
|
||||
'Peasant', 'Pegasus', 'Pentavite', 'Performer', 'Pest', 'Phelddagrif', 'Phoenix', 'Phyrexian', 'Pilot',
|
||||
'Pincher', 'Pirate', 'Plant', 'Porcupine', 'Possum', 'Praetor', 'Primarch', 'Prism', 'Processor', 'Rabbit',
|
||||
'Raccoon', 'Ranger', 'Rat', 'Rebel', 'Reflection', 'Reveler', 'Rhino', 'Rigger', 'Robot', 'Rogue', 'Rukh',
|
||||
'Sable', 'Salamander', 'Samurai', 'Sand', 'Saproling', 'Satyr', 'Scarecrow', 'Scientist', 'Scion', 'Scorpion',
|
||||
'Scout', 'Sculpture', 'Serf', 'Serpent', 'Servo', 'Shade', 'Shaman', 'Shapeshifter', 'Shark', 'Sheep', 'Siren',
|
||||
'Skeleton', 'Skunk', 'Slith', 'Sliver', 'Sloth', 'Slug', 'Snail', 'Snake', 'Soldier', 'Soltari', 'Spawn',
|
||||
'Specter', 'Spellshaper', 'Sphinx', 'Spider', 'Spike', 'Spirit', 'Splinter', 'Sponge', 'Spy', 'Squid',
|
||||
'Squirrel', 'Starfish', 'Surrakar', 'Survivor', 'Synth', 'Teddy', 'Tentacle', 'Tetravite', 'Thalakos',
|
||||
'Thopter', 'Thrull', 'Tiefling', 'Time Lord', 'Toy', 'Treefolk', 'Trilobite', 'Triskelavite', 'Troll',
|
||||
'Turtle', 'Tyranid', 'Unicorn', 'Urzan', 'Vampire', 'Varmint', 'Vedalken', 'Volver', 'Wall', 'Walrus',
|
||||
'Warlock', 'Warrior', 'Wasp', 'Weasel', 'Weird', 'Werewolf', 'Whale', 'Wizard', 'Wolf', 'Wolverine', 'Wombat',
|
||||
'Worm', 'Wraith', 'Wurm', 'Yeti', 'Zombie', 'Zubera', 'Advisors', 'Aetherborns', 'Aliens', 'Allys', 'Angels',
|
||||
'Antelopes', 'Apes', 'Archers', 'Archons', 'Armadillos', 'Armys', 'Artificers', 'Assassins', 'Assembly-Workers',
|
||||
'Astarteses', 'Atogs', 'Aurochss', 'Automatons', 'Avatars', 'Azras', 'Badgers', 'Balloons', 'Barbarians',
|
||||
'Bards', 'Basilisks', 'Bats', 'Bears', 'Beasts', 'Beavers', 'Beebles', 'Beholders', 'Berserkers', 'Birds',
|
||||
'Blinkmoths', 'Boars', 'Brainiacs', 'Bringers', 'Brushwaggs', "C'tans", 'Camarids', 'Camels', 'Capybaras',
|
||||
'Caribous', 'Carriers', 'Cats', 'Centaurs', 'Chickens', 'Children', 'Chimeras', 'Citizens', 'Clerics', 'Clowns',
|
||||
'Cockatrices', 'Constructs', 'Cowards', 'Coyotes', 'Crabs', 'Crocodiles', 'Custodeses', 'Cybermen', 'Cyclopss',
|
||||
'Daleks', 'Dauthis', 'Demigods', 'Demons', 'Deserters', 'Detectives', 'Devils', 'Dinosaurs', 'Djinn', 'Doctors',
|
||||
'Dogs', 'Dragons', 'Drakes', 'Dreadnoughts', 'Drones', 'Druids', 'Dryads', 'Dwarves', 'Efreets', 'Eggs',
|
||||
'Elders', 'Eldrazis', 'Elementals', 'Elephants', 'Elves', 'Elks', 'Employees', 'Eyes', 'Faeries', 'Ferrets',
|
||||
'Fish', 'Flagbearers', 'Foxes', 'Fractals', 'Frogs', 'Funguses', 'Gamers', 'Gargoyles', 'Germs', 'Giants',
|
||||
'Giths', 'Glimmers', 'Gnolls', 'Gnomes', 'Goats', 'Goblins', 'Gods', 'Golems', 'Gorgons', 'Graveborns',
|
||||
'Gremlins', 'Griffins', 'Guests', 'Hags', 'Halflings', 'Hamsters', 'Harpys', 'Heads', 'Hellions', 'Heroes',
|
||||
'Hippos', 'Hippogriffs', 'Homarids', 'Homunculuses', 'Hornets', 'Horrors', 'Horses', 'Humans', 'Hydras',
|
||||
'Hyenas', 'Illusions', 'Imps', 'Incarnations', 'Inklings', 'Inquisitors', 'Insects', 'Jackals', 'Jellyfish',
|
||||
'Juggernauts', 'Kavus', 'Kirins', 'Kithkins', 'Knights', 'Kobolds', 'Kors', 'Krakens', 'Lamias', 'Lammasus',
|
||||
'Leeches', 'Leviathans', 'Lhurgoyfs', 'Licids', 'Lizards', 'Manticores', 'Masticores', 'Mercenarys', 'Merfolks',
|
||||
'Metathrans', 'Minions', 'Minotaurs', 'Mites', 'Moles', 'Mongers', 'Mongooses', 'Monks', 'Monkeys', 'Moonfolks',
|
||||
'Mounts', 'Mice', 'Mutants', 'Myrs', 'Mystics', 'Nagas', 'Nautiluses', 'Necrons', 'Nephilims', 'Nightmares',
|
||||
'Nightstalkers', 'Ninjas', 'Nobles', 'Noggles', 'Nomads', 'Nymphs', 'Octopuses', 'Ogres', 'Oozes', 'Orbs', 'Orcs',
|
||||
'Orggs', 'Otters', 'Ouphes', 'Oxen', 'Oysters', 'Pangolins', 'Peasants', 'Pegasuses', 'Pentavites', 'Performers',
|
||||
'Pests', 'Phelddagrifs', 'Phoenixes', 'Phyrexians', 'Pilots', 'Pinchers', 'Pirates', 'Plants', 'Porcupines',
|
||||
'Possums', 'Praetors', 'Primarches', 'Prisms', 'Processors', 'Rabbits', 'Raccoons', 'Rangers', 'Rats', 'Rebels',
|
||||
'Reflections', 'Revelers', 'Rhinos', 'Riggers', 'Robots', 'Rogues', 'Rukhs', 'Sables', 'Salamanders', 'Samurais',
|
||||
'Sands', 'Saprolings', 'Satyrs', 'Scarecrows', 'Scientists', 'Scions', 'Scorpions', 'Scouts', 'Sculptures',
|
||||
'Serfs', 'Serpents', 'Servoes', 'Shades', 'Shamans', 'Shapeshifters', 'Sharks', 'Sheep', 'Sirens', 'Skeletons',
|
||||
'Skunks', 'Sliths', 'Slivers', 'Sloths', 'Slugs', 'Snails', 'Snakes', 'Soldiers', 'Soltaris', 'Spawns', 'Specters',
|
||||
'Spellshapers', 'Sphinxes', 'Spiders', 'Spikes', 'Spirits', 'Splinters', 'Sponges', 'Spys', 'Squids', 'Squirrels',
|
||||
'Starfish', 'Surrakars', 'Survivors', 'Synths', 'Teddys', 'Tentacles', 'Tetravites', 'Thalakoss', 'Thopters',
|
||||
'Thrulls', 'Tieflings', 'Time Lords', 'Toys', 'Treefolks', 'Trilobites', 'Triskelavites', 'Trolls', 'Turtles',
|
||||
'Tyranids', 'Unicorns', 'Urzans', 'Vampires', 'Varmints', 'Vedalkens', 'Volvers', 'Walls', 'Walruses', 'Warlocks',
|
||||
'Warriors', 'Wasps', 'Weasels', 'Weirds', 'Werewolves', 'Whales', 'Wizards', 'Wolves', 'Wolverines', 'Wombats',
|
||||
'Worms', 'Wraiths', 'Wurms', 'Yetis', 'Zombies', 'Zuberas' ]
|
||||
|
||||
theme_tags = ['+1/+1 counter', 'one or more counters', 'token', 'gain life', 'one or more creature tokens',
|
||||
'creature token', 'treasure', 'create token', 'draw a card', 'flash', 'choose a creature type',
|
||||
'play land', 'artifact you control enters', 'enchantment you control enters', 'poison counter',
|
||||
'from graveyard', 'mana value', 'from exile', 'mana of any color', 'attacks', 'total power',
|
||||
'greater than starting life', 'lose life', 'whenever you sacrifice', 'creature dying',
|
||||
'creature enters', 'creature leaves', 'creature dies', 'put into graveyard', 'sacrifice',
|
||||
'sacricifice creature', 'sacrifice artifact', 'sacrifice another creature', '-1/-1 counter',
|
||||
'control get +1/+1', 'control dies', 'experience counter', 'triggered ability', 'token']
|
||||
'control get +1/+1', 'control dies', 'experience counter', 'triggered ability', 'token',
|
||||
'commit a crime']
|
||||
|
||||
board_wipe_tags = ['destroy all', 'destroy each', 'return all', 'return each', 'deals damage to each',
|
||||
'exile all', 'exile each', 'creatures get -X/-X', 'sacrifices all', 'sacrifices each',
|
||||
'sacrifices the rest']
|
||||
targetted_removal_tags = ['exile target', 'destroy target', 'return target', 'shuffles target', 'you control',
|
||||
'deals damage to target','loses all abilities']
|
||||
'deals damage to target', 'loses all abilities']
|
||||
615
setup.py
615
setup.py
|
|
@ -2,14 +2,23 @@ from __future__ import annotations
|
|||
|
||||
import pandas as pd # type: ignore
|
||||
import requests # type: ignore
|
||||
import inquirer.prompt # type: ignore
|
||||
|
||||
from settings import banned_cards
|
||||
|
||||
staple_lists = ['Colorless', 'White', 'Blue', 'Black']
|
||||
colorless_staples = [] # type: ignore
|
||||
white_staples = [] # type: ignore
|
||||
blue_staples = [] # type: ignore
|
||||
black_staples = [] # type: ignore
|
||||
colors = ['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 = ['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, U', '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']
|
||||
|
||||
def filter_by_color(df, column_name, value, new_csv_name):
|
||||
# Filter dataframe
|
||||
|
|
@ -21,8 +30,8 @@ def filter_by_color(df, column_name, value, new_csv_name):
|
|||
as well as taking out Arena-only cards.
|
||||
"""
|
||||
filtered_df.sort_values('name')
|
||||
filtered_df = filtered_df[filtered_df['layout'].str.contains('reversible_card') == False]
|
||||
filtered_df = filtered_df[filtered_df['availability'].str.contains('arena') == False]
|
||||
filtered_df = filtered_df.loc[filtered_df['layout'] != 'reversible_card']
|
||||
filtered_df = filtered_df.loc[filtered_df['availability'] != 'arena']
|
||||
filtered_df.drop_duplicates(subset='name', keep='first', inplace=True)
|
||||
columns_to_keep = ['name', 'edhrecRank','colorIdentity', 'colors', 'manaCost', 'manaValue', 'type', 'keywords', 'text', 'power', 'toughness']
|
||||
filtered_df = filtered_df[columns_to_keep]
|
||||
|
|
@ -31,6 +40,13 @@ def filter_by_color(df, column_name, value, new_csv_name):
|
|||
|
||||
def determine_legendary():
|
||||
# Filter dataframe
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/cards.csv', 'r', encoding='utf-8'):
|
||||
break
|
||||
except FileNotFoundError:
|
||||
initial_setup()
|
||||
|
||||
df = pd.read_csv('csv_files/cards.csv', low_memory=False)
|
||||
legendary_options = ['Legendary Creature', 'Legendary Artifact Creature', 'Legendary Enchantment Creature']
|
||||
filtered_df = df[df['type'].str.contains('|'.join(legendary_options))]
|
||||
|
|
@ -41,8 +57,8 @@ def determine_legendary():
|
|||
as well as taking out Arena-only cards.
|
||||
"""
|
||||
filtered_df.sort_values('name')
|
||||
filtered_df = filtered_df[filtered_df['layout'].str.contains('reversible_card') == False]
|
||||
filtered_df = filtered_df[filtered_df['availability'].str.contains('arena') == False]
|
||||
filtered_df = filtered_df.loc[filtered_df['layout'] != 'reversible_card']
|
||||
filtered_df = filtered_df.loc[filtered_df['availability'] != 'arena']
|
||||
filtered_df.drop_duplicates(subset='name', keep='first', inplace=True)
|
||||
columns_to_keep = ['name', 'edhrecRank','colorIdentity', 'colors', 'manaCost', 'manaValue', 'type', 'keywords', 'text', 'power', 'toughness']
|
||||
filtered_df = filtered_df[columns_to_keep]
|
||||
|
|
@ -50,7 +66,6 @@ def determine_legendary():
|
|||
filtered_df.to_csv('csv_files/legendary_cards.csv', index=False)
|
||||
|
||||
def initial_setup():
|
||||
# Check if the overall cards.csv file exists
|
||||
print('Checking for cards.csv file.\n')
|
||||
while True:
|
||||
try:
|
||||
|
|
@ -64,313 +79,31 @@ def initial_setup():
|
|||
r = requests.get(url)
|
||||
with open('csv_files/cards.csv', 'wb') as outputfile:
|
||||
outputfile.write(r.content)
|
||||
df = pd.read_csv('csv_files/cards.csv', low_memory=False)
|
||||
df['colorIdentity'] = df['colorIdentity'].fillna('None')
|
||||
|
||||
# Checking for and creating individual color identity sorted csvs
|
||||
# Load cards.csv file into pandas dataframe so it can be further broken down
|
||||
df = pd.read_csv('csv_files/cards.csv', low_memory=False)
|
||||
|
||||
# Set frames that have nothing for color identity to be 'Colorless' instead
|
||||
df['colorIdentity'] = df['colorIdentity'].fillna('Colorless')
|
||||
|
||||
# Check for and create missing, individual color identity sorted CSVs
|
||||
print('Checking for color identity sorted files.\n')
|
||||
|
||||
# Colorless
|
||||
print('Checking for colorless_cards.csv.\n')
|
||||
while True:
|
||||
# For loop to iterate through the colors
|
||||
for i in range(len(colors), len(color_abrv)):
|
||||
print(f'Checking for {colors[i]}_cards.csv.')
|
||||
try:
|
||||
with open('csv_files/colorless_cards.csv', 'r', encoding='utf-8'):
|
||||
print('colorless_cards.csv exists.\n')
|
||||
break
|
||||
with open(f'csv_files/{colors[i]}_cards.csv', 'r', encoding='utf-8'):
|
||||
print(f'{colors[i]}_cards.csv exists.\n')
|
||||
except FileNotFoundError:
|
||||
print('colorless_cards.csv not found, creating it.\n')
|
||||
filter_by_color(df, 'colorIdentity', 'None', 'csv_files/colorless_cards.csv')
|
||||
print('Checking for mono-color card lists.\n')
|
||||
while True:
|
||||
print('Checking for white_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/white_cards.csv', 'r', encoding='utf-8'):
|
||||
print('white_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('white_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'W', 'csv_files/white_cards.csv')
|
||||
print('Checking for blue_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/blue_cards.csv', 'r', encoding='utf-8'):
|
||||
print('blue_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('blue_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'U', 'csv_files/blue_cards.csv')
|
||||
print('Checking for black_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/black_cards.csv', 'r', encoding='utf-8'):
|
||||
print('black_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('black_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B', 'csv_files/black_cards.csv')
|
||||
print('Checking for red_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/red_cards.csv', 'r', encoding='utf-8'):
|
||||
print('red_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('red_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'R', 'csv_files/red_cards.csv')
|
||||
print('Checking for green_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/green_cards.csv', 'r', encoding='utf-8'):
|
||||
print('green_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('green_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G', 'csv_files/green_cards.csv')
|
||||
break
|
||||
print('Checking for color-pair lists.\n')
|
||||
while True:
|
||||
print('Checking for azorius_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/azorius_cards.csv', 'r', encoding='utf-8'):
|
||||
print('azorius_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('azorius_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'U, W', 'csv_files/azorius_cards.csv')
|
||||
print('Checking for orzhov_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/orzhov_cards.csv', 'r', encoding='utf-8'):
|
||||
print('orzhov_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('orzhov_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, W', 'csv_files/orzhov_cards.csv')
|
||||
print('Checking for boros_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/boros_cards.csv', 'r', encoding='utf-8'):
|
||||
print('boros_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('boros_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'R, W', 'csv_files/boros_cards.csv')
|
||||
print('Checking for selesnya_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/selesnya_cards.csv', 'r', encoding='utf-8'):
|
||||
print('selesnya_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('selesnya_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, W', 'csv_files/selesnya_cards.csv')
|
||||
print('Checking for dimir_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/dimir_cards.csv', 'r', encoding='utf-8'):
|
||||
print('dimir_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('dimir_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, U', 'csv_files/dimir_cards.csv')
|
||||
print('Checking for izzet_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/izzet_cards.csv', 'r', encoding='utf-8'):
|
||||
print('izzet_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('izzet_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'R, U', 'csv_files/izzet_cards.csv')
|
||||
print('Checking for simic_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/simic_cards.csv', 'r', encoding='utf-8'):
|
||||
print('simic_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('simic_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, U', 'csv_files/simic_cards.csv')
|
||||
print('Checking for rakdos_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/rakdos_cards.csv', 'r', encoding='utf-8'):
|
||||
print('rakdos_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('rakdos_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R', 'csv_files/rakdos_cards.csv')
|
||||
print('Checking for golgari_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/golgari_cards.csv', 'r', encoding='utf-8'):
|
||||
print('golgari_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('golgari_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G', 'csv_files/golgari_cards.csv')
|
||||
print('Checking for gruul_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/gruul_cards.csv', 'r', encoding='utf-8'):
|
||||
print('gruul_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('gruul_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R', 'csv_files/gruul_cards.csv')
|
||||
break
|
||||
print('Checking for three-color sets.\n')
|
||||
while True:
|
||||
print('Checking for bant_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/bant_cards.csv', 'r', encoding='utf-8'):
|
||||
print('bant_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('bant_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, U, W', 'csv_files/bant_cards.csv')
|
||||
print('Checking for esper_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/esper_cards.csv', 'r', encoding='utf-8'):
|
||||
print('esper_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('esper_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, U, W', 'csv_files/esper_cards.csv')
|
||||
print('Checking for grixis_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/grixis_cards.csv', 'r', encoding='utf-8'):
|
||||
print('grixis_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('grixis_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R, U', 'csv_files/grixis_cards.csv')
|
||||
print('Checking for jund_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/jund_cards.csv', 'r', encoding='utf-8'):
|
||||
print('jund_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('jund_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R', 'csv_files/jund_cards.csv')
|
||||
print('Checking for naya_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/naya_cards.csv', 'r', encoding='utf-8'):
|
||||
print('naya_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('naya_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R, W', 'csv_files/naya_cards.csv')
|
||||
print('Checking for abzan_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/abzan_cards.csv', 'r', encoding='utf-8'):
|
||||
print('abzan_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('abzan_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, W', 'csv_files/abzan_cards.csv')
|
||||
print('Checking for jeskai_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/jeskai_cards.csv', 'r', encoding='utf-8'):
|
||||
print('jeskai_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('jeskai_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'R, U, W', 'csv_files/jeskai_cards.csv')
|
||||
print('Checking for mardu_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/mardu_cards.csv', 'r', encoding='utf-8'):
|
||||
print('mardu_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('mardu_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R, W', 'csv_files/mardu_cards.csv')
|
||||
print('Checking for sultai_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/sultai_cards.csv', 'r', encoding='utf-8'):
|
||||
print('sultai_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('sultai_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, U', 'csv_files/sultai_cards.csv')
|
||||
print('Checking for temur_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/temur_cards.csv', 'r', encoding='utf-8'):
|
||||
print('temur_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('temur_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R, U', 'csv_files/temur_cards.csv')
|
||||
break
|
||||
print('Checking for four color sets.\n')
|
||||
while True:
|
||||
print('Checking for dune_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/dune_cards.csv', 'r', encoding='utf-8'):
|
||||
print('dune_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('dune_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R, W', 'csv_files/dune_cards.csv')
|
||||
print('Checking for glint_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/glint_cards.csv', 'r', encoding='utf-8'):
|
||||
print('glint_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('glint_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R, U', 'csv_files/glint_cards.csv')
|
||||
print('Checking for ink_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/ink_cards.csv', 'r', encoding='utf-8'):
|
||||
print('ink_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('ink_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R, U, W', 'csv_files/ink_cards.csv')
|
||||
print('Checking for witch_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/witch_cards.csv', 'r', encoding='utf-8'):
|
||||
print('witch_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('witch_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, U, W', 'csv_files/witch_cards.csv')
|
||||
print('Checking for yore_cards.csv.')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/yore_cards.csv', 'r', encoding='utf-8'):
|
||||
print('yore_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('yore_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R, U, W', 'csv_files/yore_cards.csv')
|
||||
break
|
||||
print('Checking for wubrg_cards.csv.\n')
|
||||
while True:
|
||||
try:
|
||||
with open('csv_files/wubrg_cards.csv', 'r', encoding='utf-8'):
|
||||
print('wubrg_cards.csv exists.\n')
|
||||
break
|
||||
except FileNotFoundError:
|
||||
print('wubrg_cards.csv not found, creating it.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R, U, W', 'csv_files/wubrg_cards.csv')
|
||||
print(f'{colors[i]}_cards.csv not found, creating one.\n')
|
||||
filter_by_color(df, 'colorIdentity', color_abrv[i], f'csv_files/{colors[i]}_cards.csv')
|
||||
|
||||
# Once by-color lists have been made, Determine legendary creatures
|
||||
determine_legendary()
|
||||
|
||||
# Once Legendary creatures are determined, generate staple lists
|
||||
# generate_staple_lists()
|
||||
|
||||
def regenerate_csvs():
|
||||
"""
|
||||
|
|
@ -382,229 +115,25 @@ def regenerate_csvs():
|
|||
r = requests.get(url)
|
||||
with open('csv_files/cards.csv', 'wb') as outputfile:
|
||||
outputfile.write(r.content)
|
||||
# Load cards.csv file into pandas dataframe so it can be further broken down
|
||||
df = pd.read_csv('csv_files/cards.csv', low_memory=False)
|
||||
df['colorIdentity'] = df['colorIdentity'].fillna('None')
|
||||
|
||||
# Set frames that have nothing for color identity to be 'Colorless' instead
|
||||
df['colorIdentity'] = df['colorIdentity'].fillna('Colorless')
|
||||
|
||||
# Color identity sorted cards
|
||||
print('Regenerating color identity sorted files.\n')
|
||||
print('Regenerating colorless_cards.csv.')
|
||||
|
||||
# Colorless
|
||||
cards = 'colorless'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'None', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
# For loop to iterate through the colors
|
||||
for i in range(min(len(colors), len(color_abrv))):
|
||||
print(f'Regenerating {colors[i]}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', color_abrv[i], f'csv_files/{colors[i]}_cards.csv')
|
||||
print(f'A new {colors[i]}_cards.csv file has been made.\n')
|
||||
|
||||
# Mono color
|
||||
print('Regenerating mono-color card lists.\n')
|
||||
while True:
|
||||
# White cards
|
||||
cards = 'white'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Blue cards
|
||||
cards = 'blue'
|
||||
print('Regenerating blue_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Black cards
|
||||
cards = 'black'
|
||||
print('Regenerating black_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Red cards
|
||||
cards = 'red'
|
||||
print('Regenerating red_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'R', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Green cards
|
||||
cards = 'green'
|
||||
print('Regenerating green_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
break
|
||||
|
||||
# Color pairs
|
||||
print('Regenerating color-pair lists.\n')
|
||||
while True:
|
||||
# Azorius cards
|
||||
cards = 'azorius'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Orzhov cards
|
||||
cards = 'orzhov'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Boros cards
|
||||
cards = 'boros'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'R, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Selesnya
|
||||
cards = 'selesnya'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Dimir
|
||||
cards = 'dimir'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Izzet
|
||||
cards = 'izzet'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'R, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Simic
|
||||
cards = 'Simic'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Rakdos
|
||||
cards = 'rakdos'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Golgari
|
||||
cards = 'golgari'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Gruul
|
||||
cards = 'gruul'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
break
|
||||
|
||||
# Color trios
|
||||
print('Regenerating three-color sets.\n')
|
||||
while True:
|
||||
# Bant
|
||||
cards = 'Bant'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Esper
|
||||
cards = 'esper'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Grixis
|
||||
cards = 'grixis'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Jund
|
||||
cards = 'jund'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Naya
|
||||
cards = 'naya'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Abzan
|
||||
cards = 'abzan'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Jeskai
|
||||
cards = 'jeskai'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'R, U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Mardu
|
||||
cards = 'mardu'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Sultai
|
||||
cards = 'sultai'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Temur
|
||||
cards = 'temur'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
break
|
||||
|
||||
# Four color
|
||||
print('Regenerating four color sets.\n')
|
||||
while True:
|
||||
# Dune
|
||||
cards = 'dune'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Glint
|
||||
cards = 'glint'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R, U', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Ink
|
||||
cards = 'ink'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'G, R, U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Witch
|
||||
cards = 'witch'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
|
||||
# Yore
|
||||
cards = 'yore'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, R, U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
break
|
||||
|
||||
# WUBRG
|
||||
cards = 'wubrg'
|
||||
print(f'Regenerating {cards}_cards.csv.')
|
||||
filter_by_color(df, 'colorIdentity', 'B, G, R, U, W', f'csv_files/{cards}_cards.csv')
|
||||
print(f'A new {cards}_cards.csv file has been made\n')
|
||||
# Once files are regenerated, create a new legendary list
|
||||
determine_legendary()
|
||||
|
||||
def generate_staple_lists():
|
||||
colors = ['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']
|
||||
|
||||
for color in colors:
|
||||
staples = []
|
||||
print(f'Checking for {color} staples file.')
|
||||
|
|
@ -638,3 +167,35 @@ def generate_staple_lists():
|
|||
for items in staples:
|
||||
f.write('%s\n' %items)
|
||||
|
||||
def add_tags():
|
||||
pass
|
||||
|
||||
def setup():
|
||||
while True:
|
||||
print('Which setup operation would you like to perform?\n'
|
||||
'If this is your first time setting up, do the initial setup.\n'
|
||||
'If you\'ve done the basic setup before, you can regenerate the CSV files\n')
|
||||
|
||||
choice = 'Menu'
|
||||
while choice == 'Menu':
|
||||
question = [
|
||||
inquirer.List('menu',
|
||||
choices=['Initial Setup', 'Regenerate CSV Files', 'Back'],
|
||||
carousel=True)
|
||||
]
|
||||
answer = inquirer.prompt(question)
|
||||
choice = answer['menu']
|
||||
|
||||
# Run through initial setup
|
||||
while choice == 'Initial Setup':
|
||||
initial_setup()
|
||||
break
|
||||
|
||||
# Regenerate CSV files
|
||||
while choice == 'Regenerate CSV Files':
|
||||
regenerate_csvs()
|
||||
break
|
||||
# Go back
|
||||
while choice == 'Back':
|
||||
break
|
||||
break
|
||||
Loading…
Add table
Add a link
Reference in a new issue