From 291498ced933c399118538848100be9ac8e43333 Mon Sep 17 00:00:00 2001 From: Philip Kendall Date: Mon, 23 Dec 2019 19:24:07 +0000 Subject: [PATCH 1/3] Add power and toughness to card model. --- source/mtga/models/card.py | 9 ++++++--- source/mtga/set_data/dynamic.py | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/mtga/models/card.py b/source/mtga/models/card.py index 32442b8..9d830d1 100644 --- a/source/mtga/models/card.py +++ b/source/mtga/models/card.py @@ -9,7 +9,8 @@ class Card(object): def __init__(self, name="", pretty_name="", cost=None, color_identity=None, card_type="", sub_types="", - abilities=None, set_id="", rarity="", collectible=True, set_number=-1, mtga_id=-1): + abilities=None, set_id="", rarity="", collectible=True, set_number=-1, mtga_id=-1, + power=None, toughness=None): self.name = name self.set = set_id self.pretty_name = pretty_name @@ -28,6 +29,8 @@ def __init__(self, name="", pretty_name="", cost=None, color_identity=None, card if abilities is None: abilities = [] self.abilities = abilities + self.power = power + self.toughness = toughness @property def abilities_decoded(self): @@ -104,8 +107,8 @@ def __str__(self): class GameCard(Card): - def __init__(self, name, pretty_name, cost, color_identity, card_type, sub_types, set_id, rarity, set_number, mtga_id, owner_seat_id, game_id=-1): - super().__init__(name, pretty_name, cost, color_identity, card_type, sub_types, set_id, rarity, set_number, mtga_id) + def __init__(self, name, pretty_name, cost, color_identity, card_type, sub_types, set_id, rarity, set_number, mtga_id, owner_seat_id, game_id=-1, power=None, toughness=None): + super().__init__(name, pretty_name, cost, color_identity, card_type, sub_types, set_id, rarity, set_number, mtga_id, power, toughness) self.game_id = game_id self.previous_iids = [] self.owner_seat_id = owner_seat_id diff --git a/source/mtga/set_data/dynamic.py b/source/mtga/set_data/dynamic.py index 26fe688..18f5e12 100644 --- a/source/mtga/set_data/dynamic.py +++ b/source/mtga/set_data/dynamic.py @@ -131,10 +131,13 @@ def _get_data_location_hardcoded(): abilities.append(aid) all_abilities[aid] = text + power = card["power"] + toughness = card["toughness"] + new_card_obj = Card(name=card_name_snake_cased, pretty_name=card_title, cost=cost, color_identity=color_identity, card_type=card_types, sub_types=sub_types, abilities=abilities, set_id=set_id, rarity=rarity, collectible=collectible, - set_number=set_number, mtga_id=grp_id) + set_number=set_number, mtga_id=grp_id, power=power, toughness=toughness) set_card_objs.append(new_card_obj) except Exception: From 404b42365bea6c1a3c30d2b1de6b625b158d9e3b Mon Sep 17 00:00:00 2001 From: Philip Kendall Date: Sat, 8 Aug 2020 23:08:42 +0100 Subject: [PATCH 2/3] Make casing of "collectorNumber" key match updated data files. --- source/mtga/set_data/dynamic.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/mtga/set_data/dynamic.py b/source/mtga/set_data/dynamic.py index ebd7f35..876dd32 100644 --- a/source/mtga/set_data/dynamic.py +++ b/source/mtga/set_data/dynamic.py @@ -146,10 +146,10 @@ def get_win_data_location(): token_count += 1 else: try: - if card["CollectorNumber"].startswith("GR") or card["CollectorNumber"].startswith("GP"): - set_number = int(card["CollectorNumber"][2]) * 1000 + if card["collectorNumber"].startswith("GR") or card["collectorNumber"].startswith("GP"): + set_number = int(card["collectorNumber"][2]) * 1000 else: - set_number = int(card["CollectorNumber"]) + set_number = int(card["collectorNumber"]) except ValueError: set_number = card["grpid"] @@ -177,7 +177,7 @@ def get_win_data_location(): except Exception: print("hit an error on {} / {} / {}".format(card["grpid"], loc_map[card["titleId"]], - card["CollectorNumber"])) + card["collectorNumber"])) # raise card_set_obj = Set(set_name_class_cased, cards=set_card_objs) dynamic_set_tuples.append((card_set_obj, all_abilities)) From c11672633ce6f982d5aa7e057370f57c69a55740 Mon Sep 17 00:00:00 2001 From: Philip Kendall Date: Sat, 8 Aug 2020 23:13:26 +0100 Subject: [PATCH 3/3] Make things work on my hacky Linux setup again. --- source/mtga/set_data/dynamic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/mtga/set_data/dynamic.py b/source/mtga/set_data/dynamic.py index 876dd32..798aa49 100644 --- a/source/mtga/set_data/dynamic.py +++ b/source/mtga/set_data/dynamic.py @@ -26,12 +26,13 @@ def _get_data_location_hardcoded(): def get_data_location(): current_os = sys.platform - if current_os not in ["darwin", "win32"]: + if current_os not in ["darwin", "win32", "linux"]: raise return { "darwin": get_darwin_data_location, "win32": get_win_data_location, + "linux": get_win_data_location, }[current_os]() def get_darwin_data_location():