Example #1
0
 def add(self, name=None):
     if not name:
         raise ValueError("No specialty name entered!")
     name = dramatic_capitalize(sanitize_string(name))
     if self.game.specialties.filter(stat_id=self.id, key__iexact=name).count():
         raise ValueError("Specialty name already in use.")
     new_mod = self.game.specialties.create(stat_id=self.id, key=name)
     new_spec = self.specialty(self, new_mod)
     self.specialties.append(new_spec)
     self.specialties_dict[new_mod.id] = new_spec
     return new_spec
Example #2
0
 def add(self, creator, name=None):
     if not name:
         raise ValueError("No name entered!")
     name = dramatic_capitalize(sanitize_string(name))
     if self.model.stats.filter(key__iexact=name).count():
         raise ValueError("Name already in use.")
     new_mod = self.model.stats.create(key=name, creator=creator)
     new_stat = self.use(self, new_mod)
     self.stats.append(new_stat)
     self.stats_dict[new_mod.id] = new_stat
     return new_stat
Example #3
0
 def extend(self, name=None):
     if not self.can_extend:
         raise ValueError("Cannot extend %s with new sub-categories." %
                          self.name)
     if not name:
         raise ValueError("No name entered!")
     name = dramatic_capitalize(sanitize_string(name))
     new_mod = self.model.children.create(game=self.game, key=name)
     new_sub = self.sub(self, root=self.root, model=new_mod)
     self.subs.append(new_sub)
     self.subs_dict[new_sub.sub_id] = new_sub
     self.subs_name[name] = new_sub
     return new_sub
Example #4
0
 def create(self, creator, name=None):
     if not self.can_create:
         raise ValueError("Cannot add entries to %s!" % self.name)
     if not name:
         raise ValueError("No name entered!")
     name = dramatic_capitalize(sanitize_string(name))
     if self.model.entries.filter(key__iexact=name).count():
         raise ValueError("Name is already in use!")
     new_mod = self.model.entries.create(creator=creator, key=name)
     new_stat = self.stat(self, new_mod)
     self.stats.append(new_stat)
     self.stats_dict[new_stat.id] = new_stat
     self.stats_name[name] = new_stat
     return new_stat
Example #5
0
def clean_string(value):
    return dramatic_capitalize(sanitize_string(value, strip_ansi=True, strip_mxp=True,
                                               strip_newlines=True, strip_indents=True))
Example #6
0
    def convert_ex3(self, character):
        # First, let's convert templates.
        template = character.mush.getstat('D`INFO', 'Class') or 'Mortal'

        sub_class = character.mush.getstat('D`INFO', 'Caste') or None
        attribute_string = character.mush.mushget('D`ATTRIBUTES') or ''
        skill_string = character.mush.mushget('D`ABILITIES') or ''
        special_string = character.mush.mushget('D`SPECIALTIES')
        power = character.mush.getstat('D`INFO', 'POWER') or 1
        power_string = 'POWER~%s' % power
        willpower = character.mush.getstat('D`INFO', 'WILLPOWER')
        if willpower:
            willpower_string = 'WILLPOWER~%s' % willpower
        else:
            willpower_string = ''
        stat_string = "|".join([attribute_string, skill_string, willpower_string, power_string])
        stat_list = [element for element in stat_string.split('|') if len(element)]
        stats_dict = dict()
        for stat in stat_list:
            name, value = stat.split('~', 1)
            try:
                int_value = int(value)
            except ValueError:
                int_value = 0
            stats_dict[name] = int(int_value)

        character.setup_storyteller()
        character.storyteller.swap_template(template)
        try:
            character.storyteller.set('Caste', sub_class)
        except:
            pass

        new_stats = character.storyteller.stats.all()

        custom_dict = {'D`CRAFTS': 'craft', 'D`STYLES': 'style'}
        for k, v in custom_dict.iteritems():
            self.ex3_custom(character, k, v)

        for special in special_string.split('|'):
            if not len(special) > 2:
                continue
            stat_name, spec_name = special.split('/', 1)
            spec_name, value = spec_name.split('~', 1)
            find_stat = partial_match(stat_name, new_stats)
            if find_stat:
                find_stat.specialize(dramatic_capitalize(spec_name), value)

        favored_string = character.mush.mushget('D`FAVORED`ABILITIES') + '|' + character.mush.mushget('D`FAVORED`ATTRIBUTES')
        supernal_string = character.mush.mushget('D`SUPERNAL`ABILITIES')

        for k, v in stats_dict.iteritems():
            find_stat = partial_match(k, new_stats)
            if not find_stat:
                continue
            find_stat.rating = v
            find_stat.save()

        merits_dict = {'D`MERITS`*': 'merit', 'D`FLAWS`*': 'flaw'}
        for k, v in merits_dict.iteritems():
            self.ex3_merits(character, k, v)

        charms_dict = {'D`CHARMS`SOLAR': 'solar_charm', 'D`CHARMS`LUNAR': 'lunar_charm',
                       'D`CHARMS`ABYSSAL': 'abyssal_charm'}
        for k, v in charms_dict.iteritems():
            self.ex3_charms(character, k, v)


        self.ex3_spells(character)