Skip to content

Commit

Permalink
カードタイプ判別関数を入れました
Browse files Browse the repository at this point in the history
  • Loading branch information
poslogithub committed Mar 10, 2022
1 parent be20833 commit 89e58c1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
10 changes: 7 additions & 3 deletions script/generate_set_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def generate_set_map(loc, cards, enums, set_name):
sub_types_ids = [enum_map["SubType"][sub_type] for sub_type in card["subtypes"]]
sub_types = " ".join([loc_map[loc_id] for loc_id in sub_types_ids])

super_types_ids = [enum_map["SuperType"][super_type] for super_type in card["supertypes"]]
super_types = " ".join([loc_map[loc_id] for loc_id in super_types_ids])

set_id = set_name.upper()

rarity = RARITY_ID_MAP[card["rarity"]]
Expand All @@ -105,11 +108,11 @@ def generate_set_map(loc, cards, enums, set_name):
abilities.append(aid)
all_abilities[aid] = text
indentation_length = len("{} = Card(".format(card_name_class_cased_suffixed))
# params: name, pretty_name, cost, color_identity, card_type, sub_types, set_id, rarity, set_number, mtga_id
# params: name, pretty_name, cost, color_identity, card_type, sub_types, super_types, set_id, rarity, set_number, mtga_id
# ex: "a_b_c", "A B C", ['3', 'W', 'W'], ['W'], "Creature", "Angel", "AKH", "Mythic Rare", 1, 64801
# name, pretty_name, cost, color_identity, card_type, sub_types, set_id, rarity, set_number, mtga_id
# name, pretty_name, cost, color_identity, card_type, sub_types, super_types, set_id, rarity, set_number, mtga_id
new_card_str = '{} = Card(name="{}", pretty_name="{}", cost={},\n' \
'{{}}color_identity={}, card_type="{}", sub_types="{}",\n' \
'{{}}color_identity={}, card_type="{}", sub_types="{}", super_types="{}",\n' \
'{{}}abilities={}, set_id="{}", rarity="{}", collectible={}, set_number={},\n' \
'{{}}mtga_id={})'.format(
card_name_class_cased_suffixed,
Expand All @@ -119,6 +122,7 @@ def generate_set_map(loc, cards, enums, set_name):
color_identity,
card_types,
sub_types,
super_types,
abilities,
set_id,
rarity,
Expand Down
3 changes: 2 additions & 1 deletion source/mtga/models/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Card(object):

def __init__(self, name="", pretty_name="", cost=None, color_identity=None, card_type="", sub_types="",
def __init__(self, name="", pretty_name="", cost=None, color_identity=None, card_type="", sub_types="", super_types="",
abilities=None, set_id="", rarity="", collectible=True, set_number=-1, mtga_id=-1,
is_token=False, is_secondary_card=False, is_rebalanced=False):
self.name = name
Expand All @@ -22,6 +22,7 @@ def __init__(self, name="", pretty_name="", cost=None, color_identity=None, card
self.color_identity = color_identity
self.card_type = card_type
self.sub_types = sub_types
self.super_types = super_types
self.set_number = set_number
self.mtga_id = mtga_id
self.rarity = rarity
Expand Down
2 changes: 1 addition & 1 deletion source/mtga/models/card_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def generate_library(self, owner_id=-1):
library = Library(self.pool_name, self.deck_id, owner_id, -1)
for card in self.cards:
game_card = GameCard(card.name, card.pretty_name, card.cost, card.color_identity, card.card_type,
card.sub_types, card.set, card.set_number, card.mtga_id, owner_id, -1)
card.sub_types, card.super_types, card.set, card.set_number, card.mtga_id, owner_id, -1)
library.cards.append(game_card)
return library

Expand Down
9 changes: 8 additions & 1 deletion source/mtga/set_data/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def del_ruby(s):
sub_types_ids = []
sub_types = " ".join([loc_map[loc_id] for loc_id in sub_types_ids])

# TODO: super_types
try:
super_types_ids = [enum_map["SuperType"][super_type] for super_type in card["supertypes"]]
except KeyError:
super_types_ids = []
super_types = " ".join([loc_map[loc_id] for loc_id in super_types_ids])

set_id = set_name.upper()

try:
Expand Down Expand Up @@ -239,7 +246,7 @@ def del_ruby(s):
all_abilities[aid] = text

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,
color_identity=color_identity, card_type=card_types, sub_types=sub_types, super_types=super_types,
abilities=abilities, set_id=set_id, rarity=rarity, collectible=collectible,
set_number=set_number, mtga_id=grp_id,
is_token=is_token, is_secondary_card=is_secondary_card, is_rebalanced=is_rebalanced)
Expand Down

0 comments on commit 89e58c1

Please sign in to comment.