added rarity to the default fields
This commit is contained in:
parent
0ec41d60a6
commit
f0e631e015
5 changed files with 14815 additions and 14758 deletions
29488
data/output.txt
29488
data/output.txt
File diff suppressed because it is too large
Load diff
27
encode.py
27
encode.py
|
@ -36,16 +36,16 @@ def main(fname, oname = None, verbose = True, dupes = 0, encoding = 'std', stabl
|
||||||
dupes = 1
|
dupes = 1
|
||||||
elif encoding in ['rmana']:
|
elif encoding in ['rmana']:
|
||||||
if dupes == 0:
|
if dupes == 0:
|
||||||
dupes = 3
|
dupes = 1
|
||||||
randomize_mana = True
|
randomize_mana = True
|
||||||
elif encoding in ['rmana_dual']:
|
elif encoding in ['rmana_dual']:
|
||||||
if dupes == 0:
|
if dupes == 0:
|
||||||
dupes = 3
|
dupes = 1
|
||||||
fmt_ordered = fmt_ordered + [cardlib.field_cost]
|
fmt_ordered = fmt_ordered + [cardlib.field_cost]
|
||||||
randomize_mana = True
|
randomize_mana = True
|
||||||
elif encoding in ['rfields']:
|
elif encoding in ['rfields']:
|
||||||
if dupes == 0:
|
if dupes == 0:
|
||||||
dupes = 10
|
dupes = 1
|
||||||
fmt_labeled = cardlib.fmt_labeled_default
|
fmt_labeled = cardlib.fmt_labeled_default
|
||||||
randomize_fields = True
|
randomize_fields = True
|
||||||
#randomize_mana = True
|
#randomize_mana = True
|
||||||
|
@ -79,11 +79,26 @@ def main(fname, oname = None, verbose = True, dupes = 0, encoding = 'std', stabl
|
||||||
for json_cardname in sorted(json_srcs):
|
for json_cardname in sorted(json_srcs):
|
||||||
if len(json_srcs[json_cardname]) > 0:
|
if len(json_srcs[json_cardname]) > 0:
|
||||||
jcards = json_srcs[json_cardname]
|
jcards = json_srcs[json_cardname]
|
||||||
card = cardlib.Card(json_srcs[json_cardname][0])
|
|
||||||
|
# look for a normal rarity version, in a set we can use
|
||||||
|
idx = 0
|
||||||
|
card = cardlib.Card(jcards[idx])
|
||||||
|
while (idx < len(jcards)
|
||||||
|
and (card.rarity == utils.rarity_special_marker
|
||||||
|
or exclude_sets(jcards[idx][utils.json_field_set_name]))):
|
||||||
|
idx += 1
|
||||||
|
if idx < len(jcards):
|
||||||
|
card = cardlib.Card(jcards[idx])
|
||||||
|
# if there isn't one, settle with index 0
|
||||||
|
if idx >= len(jcards):
|
||||||
|
idx = 0
|
||||||
|
card = cardlib.Card(jcards[idx])
|
||||||
|
# we could go back and look for a card satisfying one of the criteria,
|
||||||
|
# but eh
|
||||||
|
|
||||||
skip = False
|
skip = False
|
||||||
if (exclude_sets(jcards[0][utils.json_field_set_name])
|
if (exclude_sets(jcards[idx][utils.json_field_set_name])
|
||||||
or exclude_layouts(jcards[0]['layout'])):
|
or exclude_layouts(jcards[idx]['layout'])):
|
||||||
skip = True
|
skip = True
|
||||||
for cardtype in card.types:
|
for cardtype in card.types:
|
||||||
if exclude_types(cardtype):
|
if exclude_types(cardtype):
|
||||||
|
|
|
@ -74,6 +74,7 @@ fmt_ordered_default = [
|
||||||
field_types,
|
field_types,
|
||||||
field_loyalty,
|
field_loyalty,
|
||||||
field_subtypes,
|
field_subtypes,
|
||||||
|
field_rarity,
|
||||||
field_pt,
|
field_pt,
|
||||||
field_cost,
|
field_cost,
|
||||||
field_text,
|
field_text,
|
||||||
|
@ -191,21 +192,32 @@ def fields_from_json(src_json):
|
||||||
fields[field_subtypes] = [(-1, map(lambda s: utils.to_ascii(s.lower()),
|
fields[field_subtypes] = [(-1, map(lambda s: utils.to_ascii(s.lower()),
|
||||||
src_json['subtypes']))]
|
src_json['subtypes']))]
|
||||||
|
|
||||||
|
if 'rarity' in src_json:
|
||||||
|
if src_json['rarity'] in utils.json_rarity_map:
|
||||||
|
fields[field_rarity] = [(-1, utils.json_rarity_map[src_json['rarity']])]
|
||||||
|
else:
|
||||||
|
fields[field_rarity] = [(-1, src_json['rarity'])]
|
||||||
|
parsed = False
|
||||||
|
else:
|
||||||
|
parsed = False
|
||||||
|
|
||||||
if 'loyalty' in src_json:
|
if 'loyalty' in src_json:
|
||||||
fields[field_loyalty] = [(-1, utils.to_unary(str(src_json['loyalty'])))]
|
fields[field_loyalty] = [(-1, utils.to_unary(str(src_json['loyalty'])))]
|
||||||
|
|
||||||
p_t = ''
|
p_t = ''
|
||||||
|
parsed_pt = True
|
||||||
if 'power' in src_json:
|
if 'power' in src_json:
|
||||||
p_t = utils.to_ascii(utils.to_unary(src_json['power'])) + '/' # hardcoded
|
p_t = utils.to_ascii(utils.to_unary(src_json['power'])) + '/' # hardcoded
|
||||||
valid = False
|
parsed_pt = False
|
||||||
if 'toughness' in src_json:
|
if 'toughness' in src_json:
|
||||||
p_t = p_t + utils.to_ascii(utils.to_unary(src_json['toughness']))
|
p_t = p_t + utils.to_ascii(utils.to_unary(src_json['toughness']))
|
||||||
valid = True
|
parsed_pt = True
|
||||||
elif 'toughness' in src_json:
|
elif 'toughness' in src_json:
|
||||||
p_t = '/' + utils.to_ascii(utils.to_unary(src_json['toughness'])) # hardcoded
|
p_t = '/' + utils.to_ascii(utils.to_unary(src_json['toughness'])) # hardcoded
|
||||||
valid = False
|
parsed_pt = False
|
||||||
if p_t:
|
if p_t:
|
||||||
fields[field_pt] = [(-1, p_t)]
|
fields[field_pt] = [(-1, p_t)]
|
||||||
|
parsed = parsed and parsed_pt
|
||||||
|
|
||||||
# similarly, return the actual Manatext object
|
# similarly, return the actual Manatext object
|
||||||
if 'text' in src_json:
|
if 'text' in src_json:
|
||||||
|
@ -533,7 +545,11 @@ class Card:
|
||||||
outstr += ' ' + self.__dict__[field_cost].format(for_forum = for_forum)
|
outstr += ' ' + self.__dict__[field_cost].format(for_forum = for_forum)
|
||||||
|
|
||||||
if self.__dict__[field_rarity]:
|
if self.__dict__[field_rarity]:
|
||||||
outstr += ' (' + self.__dict__[rarity] + ')'
|
if self.__dict__[field_rarity] in utils.json_rarity_unmap:
|
||||||
|
rarity = utils.json_rarity_unmap[self.__dict__[field_rarity]]
|
||||||
|
else:
|
||||||
|
rarity = self.__dict__[field_rarity]
|
||||||
|
outstr += ' (' + rarity + ')'
|
||||||
|
|
||||||
if not self.parsed:
|
if not self.parsed:
|
||||||
outstr += ' _UNPARSED_'
|
outstr += ' _UNPARSED_'
|
||||||
|
@ -594,7 +610,11 @@ class Card:
|
||||||
cardname = self.__dict__[field_name]
|
cardname = self.__dict__[field_name]
|
||||||
outstr += cardname
|
outstr += cardname
|
||||||
if self.__dict__[field_rarity]:
|
if self.__dict__[field_rarity]:
|
||||||
outstr += ' (' + self.__dict__[field_rarity] + ')'
|
if self.__dict__[field_rarity] in utils.json_rarity_unmap:
|
||||||
|
rarity = utils.json_rarity_unmap[self.__dict__[field_rarity]]
|
||||||
|
else:
|
||||||
|
rarity = self.__dict__[field_rarity]
|
||||||
|
outstr += ' (' + rarity.lower() + ')'
|
||||||
if not self.parsed:
|
if not self.parsed:
|
||||||
outstr += ' _UNPARSED_'
|
outstr += ' _UNPARSED_'
|
||||||
if not self.valid:
|
if not self.valid:
|
||||||
|
|
|
@ -22,6 +22,14 @@ choice_close_delimiter = ']'
|
||||||
x_marker = 'X'
|
x_marker = 'X'
|
||||||
tap_marker = 'T'
|
tap_marker = 'T'
|
||||||
untap_marker = 'Q'
|
untap_marker = 'Q'
|
||||||
|
# second letter of the word
|
||||||
|
rarity_common_marker = 'O'
|
||||||
|
rarity_uncommon_marker = 'N'
|
||||||
|
rarity_rare_marker = 'A'
|
||||||
|
rarity_mythic_marker = 'Y'
|
||||||
|
# with some crazy exceptions
|
||||||
|
rarity_special_marker = 'E'
|
||||||
|
rarity_basic_land_marker = 'L'
|
||||||
|
|
||||||
# unambiguous synonyms
|
# unambiguous synonyms
|
||||||
counter_rename = 'uncast'
|
counter_rename = 'uncast'
|
||||||
|
@ -41,7 +49,7 @@ unary_exceptions = {
|
||||||
|
|
||||||
# field labels, to allow potential reordering of card format
|
# field labels, to allow potential reordering of card format
|
||||||
field_label_name = '1'
|
field_label_name = '1'
|
||||||
field_label_rarity = 'Y' # 2 is part of some mana symbols {2/B} ...
|
field_label_rarity = '0' # 2 is part of some mana symbols {2/B} ...
|
||||||
field_label_cost = '3'
|
field_label_cost = '3'
|
||||||
field_label_supertypes = '4'
|
field_label_supertypes = '4'
|
||||||
field_label_types = '5'
|
field_label_types = '5'
|
||||||
|
@ -49,7 +57,6 @@ field_label_subtypes = '6'
|
||||||
field_label_loyalty = '7'
|
field_label_loyalty = '7'
|
||||||
field_label_pt = '8'
|
field_label_pt = '8'
|
||||||
field_label_text = '9'
|
field_label_text = '9'
|
||||||
# one left, could use for managing bsides
|
|
||||||
|
|
||||||
# additional fields we add to the json cards
|
# additional fields we add to the json cards
|
||||||
json_field_bside = 'bside'
|
json_field_bside = 'bside'
|
||||||
|
|
17
lib/utils.py
17
lib/utils.py
|
@ -24,6 +24,22 @@ choice_close_delimiter = config.choice_close_delimiter
|
||||||
x_marker = config.x_marker
|
x_marker = config.x_marker
|
||||||
tap_marker = config.tap_marker
|
tap_marker = config.tap_marker
|
||||||
untap_marker = config.untap_marker
|
untap_marker = config.untap_marker
|
||||||
|
rarity_common_marker = config.rarity_common_marker
|
||||||
|
rarity_uncommon_marker = config.rarity_uncommon_marker
|
||||||
|
rarity_rare_marker = config.rarity_rare_marker
|
||||||
|
rarity_mythic_marker = config.rarity_mythic_marker
|
||||||
|
rarity_special_marker = config.rarity_special_marker
|
||||||
|
rarity_basic_land_marker = config.rarity_basic_land_marker
|
||||||
|
|
||||||
|
json_rarity_map = {
|
||||||
|
'Common' : rarity_common_marker,
|
||||||
|
'Uncommon' : rarity_uncommon_marker,
|
||||||
|
'Rare' : rarity_rare_marker,
|
||||||
|
'Mythic Rare' : rarity_mythic_marker,
|
||||||
|
'Special' : rarity_special_marker,
|
||||||
|
'Basic Land' : rarity_basic_land_marker,
|
||||||
|
}
|
||||||
|
json_rarity_unmap = {json_rarity_map[k] : k for k in json_rarity_map}
|
||||||
|
|
||||||
# unambiguous synonyms
|
# unambiguous synonyms
|
||||||
counter_rename = config.counter_rename
|
counter_rename = config.counter_rename
|
||||||
|
@ -458,4 +474,3 @@ def from_symbols(s, for_forum = False):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
unletters_regex = r"[^abcdefghijklmnopqrstuvwxyz']"
|
unletters_regex = r"[^abcdefghijklmnopqrstuvwxyz']"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue