当前位置: 首页>>代码示例>>Python>>正文


Python Form.generate方法代码示例

本文整理汇总了Python中form.Form.generate方法的典型用法代码示例。如果您正苦于以下问题:Python Form.generate方法的具体用法?Python Form.generate怎么用?Python Form.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在form.Form的用法示例。


在下文中一共展示了Form.generate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_art

# 需要导入模块: from form import Form [as 别名]
# 或者: from form.Form import generate [as 别名]
def create_art(nation, creator):
    category = creator.choice(ART_CATEGORIES[creator.periods[-1].role])

    style = ''
    sub_category = ''
    material = ''

    if category == 'drawing':
        style = creator.choice(ART_STYLES[category])
        sub_category = creator.choice(ART_SUBCATEGORIES[category])

        gen_forms = creator.choice(ART_SUBJECTS[sub_category])
    else:
        gen_forms = creator.choice(ART_SUBJECTS[category])

    gen = Form(gen_forms, custom_weights=creator.periods[-1].custom_weights)
    subject, content = gen.generate(nation=nation, creator=creator)

    if subject is not None:
        creator.periods[-1].custom_weights = gen.custom_weights

        material_gen = None
        if style in ART_MATERIALS:
            material_gen = Form(ART_MATERIALS[style], custom_weights=creator.periods[-1].custom_weights)
        elif category in ART_MATERIALS:
            material_gen = Form(ART_MATERIALS[category], custom_weights=creator.periods[-1].custom_weights)

        name = utility.titlecase(nation.language.translateTo(subject))

        if material_gen is not None:
            material = material_gen.generate(nation=nation, creator=creator)[0]
            creator.periods[-1].custom_weights = material_gen.custom_weights

        return Art(nation, creator, name, subject, category, style, sub_category, content, material, None, gen)
    else:
        return None
开发者ID:Kytuzian,项目名称:History-Generator,代码行数:38,代码来源:culture.py


注:本文中的form.Form.generate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。