コード例 #1
0
ファイル: bestiary.py プロジェクト: spicykaiju/rpg
 def parse_csv(self, csv, sources):
     def strip_parens(text):
         return text.strip(')').strip('(').strip()
     self.prd = list()
     self.all_sources = set()
     for row in islice(app.unicode_csv_reader(csv), 1, None):
         entry = Entry(*row)
         if entry.is_template == '1':
             continue
         for field in 'bab ref'.split():
             setattr(entry, field, int(getattr(entry, field)))
         entry.subtype = strip_parens(entry.subtype)
         entry.hp_mods = strip_parens(entry.hp_mods)
         entry.ac_mods = strip_parens(entry.ac_mods)
         entry.save_mods = strip_parens(entry.save_mods)
         entry.abilitiy_score_mods = strip_parens(entry.abilitiy_score_mods)
         entry.racial_mods = strip_parens(entry.racial_mods)
         entry.special_abilities = self.split_special_abilities(entry.special_abilities)
         entry.spelllike_abilities = self.split_spelllike_abilities(entry.spelllike_abilities)
         if entry.source == 'PFRPG" Bestiary':
             entry.source = 'PFRPG Bestiary'
         self.all_sources.add(entry.source)
         for s in sources:
             if s.lower() in entry.source.lower():
                 self.prd.append(entry)
                 break
         else:
             self.prd.append(entry)
コード例 #2
0
ファイル: feats.py プロジェクト: spicykaiju/rpg
 def parse_csv(self, csv):
     self.sources = set()
     self.types = set()
     entries = list()
     # islice == strip off csv header.
     for row in islice(app.unicode_csv_reader(csv), 1, None):
         feat = RawFeatTuple(*row)
         # Fix errors in source CSV.
         wrong = [
                 ('Point-Blank Shot', 'Point Blank Shot'),
                 ('Spell focus', 'Spell Focus'),
                 ('Close Quarters Thrower', 'Close-Quarters Thrower'),
                 ]
         for find, replace in wrong:
             if find in feat.prerequisites or find in feat.name or find in feat.prerequisite_feats or find in feat.description:
                 feat = feat._replace(
                         name=feat.name.replace(find, replace),
                         prerequisites=feat.prerequisites.replace(find, replace),
                         prerequisite_feats=feat.prerequisite_feats.replace(find, replace),
                         description=feat.description.replace(find, replace),
                         )
         # Expand/Change source CSV.
         if 'See Armor Proficiency, Light' in feat.benefit:
             feat = feat._replace(
                     benefit=feat.benefit.replace('See Armor Proficiency, Light', 'When you wear a type of armor with which you are proficient, the armor check penalty for that armor applies only to Dexterity and Strength-based skill checks.'),
                     normal=feat.normal.replace('See Armor Proficiency, Light', 'A character who is wearing armor with which he is not proficient applies its armor check penalty to attack rolls and to all skill checks that involve moving.'),
                     )
         types = list()
         if feat.type and feat.type != 'General':
             types.append(feat.type)
             self.types.add(feat.type)
         for type in ['teamwork', 'critical', 'grit', 'style', 'peformance', 'racial']:
             text = getattr(feat, type)
             if text == '1':
                 types.append(type.capitalize())
                 self.types.add(type.capitalize())
         # Rename "Armor, Light" to "Light Armor".
         if ',' in feat.name:
             parts = feat.name.split(', ')
             if len(parts) > 2:
                 raise Exception('wtf [%s]' % feat.name)
             feat_name = '%s %s' % (parts[1], parts[0])
         else:
             feat_name = feat.name
         entries.append(Feat(feat.id, feat.name, feat.description, feat.prerequisites, feat.prerequisite_feats, feat.benefit, feat.normal, feat.special, feat.source, types, feat_name))
         self.sources.add(feat.source)
     return entries