예제 #1
0
class Skilled(DBOAspect):
    skills = DBOField({}, 'untyped')

    def _on_attach(self):
        self.fight = Fight(self)

    def add_skill(self, skill):
        if skill.template_key in self.skills:
            raise ActionError("Skill already exists.")
        self.skills[skill.template_key] = skill
        self._apply_skill(skill)

    def _apply_skill(self, skill):
        if skill.auto_start:
            skill.invoke(self)
        else:
            self.enhance_soul(skill)
        try:
            self.fight.update_skills()
        except AttributeError:
            pass

    def remove_skill(self, skill_id):
        try:
            skill = self.skills.pop(skill_id)
            if skill.auto_start:
                skill.revoke(self)
            else:
                 self.diminish_soul(skill)
            self.fight.update_skills()
        except KeyError:
            raise ActionError('{} does not have that skill'.format(self.name))
예제 #2
0
 def _on_attach(self):
     self.fight = Fight(self)