本文整理匯總了Python中the_tale.game.heroes.prototypes.HeroPrototype.create方法的典型用法代碼示例。如果您正苦於以下問題:Python HeroPrototype.create方法的具體用法?Python HeroPrototype.create怎麽用?Python HeroPrototype.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類the_tale.game.heroes.prototypes.HeroPrototype
的用法示例。
在下文中一共展示了HeroPrototype.create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: register_user
# 需要導入模塊: from the_tale.game.heroes.prototypes import HeroPrototype [as 別名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import create [as 別名]
def register_user(nick, email=None, password=None, referer=None, referral_of_id=None, action_id=None, is_bot=False):
if Account.objects.filter(nick=nick).exists():
return REGISTER_USER_RESULT.DUPLICATE_USERNAME, None, None
if email and Account.objects.filter(email=email).exists():
return REGISTER_USER_RESULT.DUPLICATE_EMAIL, None, None
try:
referral_of = AccountPrototype.get_by_id(referral_of_id)
except ValueError:
referral_of = None
if (email and not password) or (not email and password):
raise exceptions.EmailAndPasswordError()
is_fast = not (email and password)
if is_fast and is_bot:
raise exceptions.BotIsFastError()
if password is None:
password = accounts_settings.FAST_REGISTRATION_USER_PASSWORD
account = AccountPrototype.create(nick=nick,
email=email,
is_fast=is_fast,
is_bot=is_bot,
password=password,
referer=referer,
referral_of=referral_of,
action_id=action_id)
AccountAchievementsPrototype.create(account)
AccountItemsPrototype.create(account)
market_logic.create_goods(account.id)
hero = HeroPrototype.create(account=account)
dress_new_hero(hero)
messages_for_new_hero(hero)
hero.save()
return REGISTER_USER_RESULT.OK, account.id, hero.actions.current_action.bundle_id