Пример #1
0
def add_skill_action(target, obj):
    skill_args = target.split(' ')
    try:
        skill_name = skill_args[0]
    except IndexError:
        raise ActionError("Skill name required")
    try:
        skill_level = int(skill_args[1])
    except (IndexError, ValueError):
        skill_level = 1
    if ':' in skill_name:
        skill_id = skill_name
    else:
        skill_id = None
        for skill_type in dbo_types(SkillTemplate):
            if skill_name in db.fetch_set_keys(skill_type.dbo_set_key):
                skill_id = '{}:{}'.format(skill_type.dbo_key_type, skill_name)
                break
    if skill_id:
        skill_template = db.load_object(skill_id)
        if skill_template:
            add_skill(skill_template, obj, skill_level, 'immortal')
            if getattr(obj, 'dbo_id', None):
                db.save_object(obj)
            return "Added {} to {}".format(skill_name, obj.name)
    return "Skill {} not found ".format(skill_name)
Пример #2
0
def remove_skill(target, obj):
    if ':' in target:
        skill_id = target
    else:
        skill_id = None
        for skill_type in dbo_types(SkillTemplate):
            skill_id = '{}:{}'.format(skill_type.dbo_key_type, target)
            if skill_id in obj.skills:
                break
            else:
                skill_id = None
    obj.remove_skill(skill_id)
    if getattr(obj, 'dbo_id', None):
        db.save_object(obj)
    return "Removed {} from {}".format(target, obj.name)
Пример #3
0
def remove_skill(target, obj, **_):
    try:
        skill_name = target[0]
    except IndexError:
        raise ActionError("Skill name required")
    if ':' in skill_name:
        skill_id = skill_name
    else:
        for skill_type in dbo_types(SkillTemplate):
            skill_id = '{}:{}'.format(skill_type.dbo_key_type, skill_name)
            if skill_id in obj.skills:
                break
            else:
                skill_id = None
    obj.remove_skill(skill_id)
    if getattr(obj, 'dbo_id', None):
        db.save_object(obj)
    return "Removed {} from {}".format(skill_name, obj.name)
Пример #4
0
def editor_constants(**_):
    constants = {key: config_value(key) for key in ['attributes', 'resource_pools', 'equip_types', 'equip_slots', 'weapon_types',
                                                        'damage_types', 'damage_delivery', 'damage_groups', 'affinities', 'imm_levels']}
    constants['weapon_options'] = constants['weapon_types'] + [{'dbo_id': 'unused'}, {'dbo_id': 'unarmed'}, {'dbo_id': 'any'}]
    constants['skill_calculation'] = constants['attributes'] + [{'dbo_id': 'roll', 'name': 'Dice Roll'}, {'dbo_id': 'skill', 'name': 'Skill Level'}]
    constants['defense_damage_types'] = constants['damage_types'] + constants['damage_groups']
    constants['directions'] = Direction.ordered
    constants['article_load_types'] = ['equip', 'default']
    constants['broadcast_types'] = broadcast_types
    constants['broadcast_tokens'] = broadcast_tokens
    constants['skill_types'] =  [skill_template.dbo_key_type for skill_template in dbo_types(SkillTemplate)]
    constants['features'] = [get_dbo_class(feature_id)().edit_dto for feature_id in ['touchstone', 'entrance', 'store']]
    constants['action_args'] = action_keywords
    shadow_types = {}
    for class_id, cls in itertools.chain(implementors(Scriptable), instance_implementors(Scriptable)):
        shadows = [{'name': name, 'args': inspect.getargspec(member.func).args} for name, member in inspect.getmembers(cls) if isinstance(member, Shadow)]
        if shadows:
            shadow_types[class_id] = shadows
    constants['shadow_types'] = shadow_types
    constants['script_builders'] = sorted((builder.dto for builder in builders), key=lambda dto: dto['name'])
    return(constants)