From 2c71de733fb981dcdb44733436fd8192325a93ad Mon Sep 17 00:00:00 2001 From: henriquenakashima Date: Fri, 19 Mar 2021 22:22:36 -0400 Subject: [PATCH] Report per color --- archetype_report.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/archetype_report.py b/archetype_report.py index da88f1e..c8679bb 100644 --- a/archetype_report.py +++ b/archetype_report.py @@ -2,6 +2,7 @@ import argparse from collections import defaultdict +from typing import List import cubecobra_csv @@ -39,6 +40,7 @@ ARCHETYPE_TAGS = [ def main(): parser = argparse.ArgumentParser() parser.add_argument('-a', '--archetype') + parser.add_argument('-c', '--category') arguments = parser.parse_args() csv_path = cubecobra_csv.request_cube_csv('TheElegantCube_fetched', 'elegant') @@ -52,26 +54,38 @@ def main(): if tag in ARCHETYPE_TAGS: archetype_counts_per_category[tag][cube_card.color_category].append(cube_card) - if not arguments.archetype: + if not arguments.archetype and not arguments.category: for tag in ARCHETYPE_TAGS: print(f'Archetype: {tag}') cards_per_category = archetype_counts_per_category[tag] for category, cards in cards_per_category.items(): print(f'{category} {len(cards)}') print() - else: + elif arguments.archetype: cards_per_category = archetype_counts_per_category[arguments.archetype] for category, cards in cards_per_category.items(): - print(f'Category: {category} - {len(cards)} card{"s" if len(cards) != 1 else ""}') - for i, card in enumerate(cards, 1): - intersection = [tag for tag in card.tags if tag != arguments.archetype and tag in ARCHETYPE_TAGS] - print(f'{i:2d} {card.name} ([{len(intersection) + 1}]: {intersection})') - print() + _print_detailed(category, cards) print() for category, cards in cards_per_category.items(): print(f'{category} {len(cards)}') + elif arguments.category: + cards = [] + for cube_card in cube_cards: + if 'core' not in cube_card.tags: + continue + if cube_card.color_category == arguments.category: + cards.append(cube_card) + _print_detailed(arguments.category, cards) + + +def _print_detailed(category: str, cards: List[cubecobra_csv.CubeCard]) -> None: + print(f'Category: {category} | {len(cards)} card{"s" if len(cards) != 1 else ""}') + for i, card in enumerate(cards, 1): + intersection = [tag for tag in card.tags if tag in ARCHETYPE_TAGS] + print(f'{i:2d} {card.name} ([{len(intersection)}]: {intersection})') + print() if __name__ == '__main__':