fix description formatting when read from dominion_cards.txt
This commit is contained in:
parent
11ba180f79
commit
3d9b2add59
@ -259,10 +259,7 @@ class DominionTabs:
|
|||||||
if useExtra and card.extra:
|
if useExtra and card.extra:
|
||||||
descriptions = (card.extra,)
|
descriptions = (card.extra,)
|
||||||
else:
|
else:
|
||||||
if self.options.read_yaml:
|
|
||||||
descriptions = re.split("\n",card.description)
|
descriptions = re.split("\n",card.description)
|
||||||
else:
|
|
||||||
descriptions = re.split("--+",card.description)
|
|
||||||
|
|
||||||
height = 0
|
height = 0
|
||||||
for d in descriptions:
|
for d in descriptions:
|
||||||
@ -333,25 +330,42 @@ class DominionTabs:
|
|||||||
c.extra = extras[c.name]
|
c.extra = extras[c.name]
|
||||||
#print c.name + ' ::: ' + extra
|
#print c.name + ' ::: ' + extra
|
||||||
|
|
||||||
|
baseactionRE = re.compile("^\s*(\+\d+\s+\w+)(?:[,.;])")
|
||||||
|
|
||||||
def add_definition_line(self,card,line):
|
def add_definition_line(self,card,line):
|
||||||
|
# Unfortunately, the way things are specified in the old card spec
|
||||||
|
# format is somewhat haphazard. In particular:
|
||||||
|
# 1) Sometimes "basic actions", which would be separated on the
|
||||||
|
# actual card text by separate lines, are instead only separated
|
||||||
|
# by punctuation ('.', ',', or ';')
|
||||||
|
# [Example: Intrigue - Courtyard]
|
||||||
|
# 2) When there is an actual horizontal line drawn on the card, this
|
||||||
|
# can be represented using either '____' or '-----'
|
||||||
|
# 3) There are sometimes random blank lines
|
||||||
|
|
||||||
|
# To solve:
|
||||||
|
|
||||||
|
# 1)
|
||||||
#try to figure out if this a 'basic action' like +X Cards or +Y Actions
|
#try to figure out if this a 'basic action' like +X Cards or +Y Actions
|
||||||
baseaction = re.compile("^\s*(\+\d+\s+\w+)(?:[,.;])")
|
descriptions = [card.description]
|
||||||
m = baseaction.match(line)
|
while True:
|
||||||
prefix = ''
|
m = self.baseactionRE.match(line)
|
||||||
while m:
|
if not m:
|
||||||
prefix += line[m.start(1):m.end(1)] + '----'
|
break
|
||||||
|
descriptions.append(m.group(1))
|
||||||
line = line[m.end():]
|
line = line[m.end():]
|
||||||
m = baseaction.match(line)
|
|
||||||
line = prefix + line
|
# 2) Standardize on '____' as the format for a divider line
|
||||||
#this is a messy way to preserve the way the card spec file indicates separation
|
line = line.strip()
|
||||||
#and add our own via '---' sequences. Needs to be completely replaced, probably
|
if not line.strip('-'):
|
||||||
#at the same time as changing the card spec file format.
|
line = line.replace('-', '_')
|
||||||
if not card.description.strip().endswith(';')\
|
|
||||||
and not card.description.strip().endswith('---')\
|
# 3) get rid of blank lines
|
||||||
and not line.startswith('-'):
|
descriptions.append(line)
|
||||||
card.description += '----' + line
|
descriptions = [x.strip() for x in descriptions]
|
||||||
else:
|
descriptions = [x for x in descriptions if x]
|
||||||
card.description += line
|
|
||||||
|
card.description = '\n'.join(descriptions)
|
||||||
|
|
||||||
def read_card_defs(self,fname,fileobject=None):
|
def read_card_defs(self,fname,fileobject=None):
|
||||||
cards = []
|
cards = []
|
||||||
@ -618,9 +632,6 @@ class DominionTabs:
|
|||||||
cards = yaml.load(cardfile)
|
cards = yaml.load(cardfile)
|
||||||
else:
|
else:
|
||||||
cards = self.read_card_defs(os.path.join(self.filedir,"dominion_cards.txt"))
|
cards = self.read_card_defs(os.path.join(self.filedir,"dominion_cards.txt"))
|
||||||
for c in cards:
|
|
||||||
c.description = re.sub('----+','\n',c.description)
|
|
||||||
c.description = re.sub('\n\s*\n','\n',c.description)
|
|
||||||
self.read_card_extras(os.path.join(self.filedir,"dominion_card_extras.txt"),cards)
|
self.read_card_extras(os.path.join(self.filedir,"dominion_card_extras.txt"),cards)
|
||||||
|
|
||||||
if self.options.expansions:
|
if self.options.expansions:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user