本文整理汇总了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