本文整理汇总了Python中the_tale.common.postponed_tasks.PostponedTaskPrototype.create方法的典型用法代码示例。如果您正苦于以下问题:Python PostponedTaskPrototype.create方法的具体用法?Python PostponedTaskPrototype.create怎么用?Python PostponedTaskPrototype.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.common.postponed_tasks.PostponedTaskPrototype
的用法示例。
在下文中一共展示了PostponedTaskPrototype.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: purchase_lot
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def purchase_lot(buyer_id, lot):
from the_tale.common.postponed_tasks import PostponedTaskPrototype
from the_tale.finances.market import postponed_tasks
invoice = bank_prototypes.InvoicePrototype.create(recipient_type=bank_relations.ENTITY_TYPE.GAME_ACCOUNT,
recipient_id=lot.seller_id,
sender_type=bank_relations.ENTITY_TYPE.GAME_ACCOUNT,
sender_id=buyer_id,
currency=bank_relations.CURRENCY_TYPE.PREMIUM,
amount=lot.price,
description_for_sender=u'Покупка «%s»' % lot.name,
description_for_recipient=u'Продажа «%s»' % lot.name,
operation_uid=u'market-buy-lot-%s' % lot.type)
transaction = bank_transaction.Transaction(invoice.id)
logic_task = postponed_tasks.BuyLotTask(seller_id=lot.seller_id,
buyer_id=buyer_id,
lot_id=lot.id,
transaction=transaction)
task = PostponedTaskPrototype.create(logic_task)
amqp_environment.environment.workers.refrigerator.cmd_wait_task(task.id)
return task
示例2: choose_ability
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def choose_ability(self, ability_id):
choose_task = postponed_tasks.ChooseHeroAbilityTask(hero_id=self.hero.id, ability_id=ability_id)
task = PostponedTaskPrototype.create(choose_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(task.status_url)
示例3: change_credentials
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def change_credentials(self):
from the_tale.accounts.postponed_tasks import ChangeCredentials
change_credentials_task = ChangeCredentials(task_id=self.id)
task = PostponedTaskPrototype.create(change_credentials_task)
environment.workers.accounts_manager.cmd_task(task.id)
return task
示例4: test_initialization
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def test_initialization(self):
from the_tale.common.postponed_tasks import PostponedTask, PostponedTaskPrototype, POSTPONED_TASK_STATE, FakePostponedInternalTask
PostponedTaskPrototype.create(FakePostponedInternalTask())
self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 1)
self.worker.process_initialize()
self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 0)
self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.RESETED).count(), 1)
self.assertEqual(self.worker.tasks, {})
self.assertEqual(self.worker.accounts_for_tasks, {})
self.assertEqual(self.worker.accounts_owners, {self.account_1.id: 'game_logic_1', self.account_2.id: 'game_logic_2'})
self.assertEqual(self.worker.accounts_queues, {})
self.assertTrue(self.worker.initialized)
self.assertFalse(self.worker.wait_next_turn_answer)
self.assertTrue(GameState.is_working())
示例5: reset_name
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def reset_name(self):
change_task = postponed_tasks.ChangeHeroTask(hero_id=self.hero.id,
name=names.generator.get_name(self.hero.race, self.hero.gender),
race=self.hero.race,
gender=self.hero.gender)
task = PostponedTaskPrototype.create(change_task)
environment.workers.supervisor.cmd_logic_task(self.hero.account_id, task.id)
return self.json_processing(task.status_url)
示例6: create
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def create(context):
check_recipients(context.form)
logic_task = postponed_tasks.SendMessagesTask(
account_id=context.account.id, recipients=context.form.c.recipients, message=context.form.c.text
)
task = PostponedTaskPrototype.create(logic_task)
amqp_environment.environment.workers.accounts_manager.cmd_task(task.id)
return dext_views.AjaxProcessing(status_url=task.status_url)
示例7: reset_abilities
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def reset_abilities(self):
if not self.hero.abilities.can_reset:
return self.json_error('heroes.reset_abilities.reset_timeout', u'Сброс способностей пока не доступен')
reset_task = postponed_tasks.ResetHeroAbilitiesTask(hero_id=self.hero.id)
task = PostponedTaskPrototype.create(reset_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(task.status_url)
示例8: send_good_to_market
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def send_good_to_market(seller_id, good, price):
from the_tale.common.postponed_tasks import PostponedTaskPrototype
from the_tale.finances.market import postponed_tasks
logic_task = postponed_tasks.CreateLotTask(account_id=seller_id,
good_type=good.type,
good_uid=good.uid,
price=price)
task = PostponedTaskPrototype.create(logic_task)
amqp_environment.environment.workers.market_manager.cmd_logic_task(seller_id, task.id)
return task
示例9: use_ability
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def use_ability(self, ability):
battle = Battle1x1Prototype.get_by_account_id(self.account.id)
if battle is None or not battle.state.is_PROCESSING:
return self.json_error("pvp.use_ability.no_battle", u"Бой не идёт, вы не можете использовать способность")
use_ability_task = UsePvPAbilityTask(battle_id=battle.id, account_id=self.account.id, ability_id=ability.TYPE)
task = PostponedTaskPrototype.create(use_ability_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(task.status_url)
示例10: activate
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def activate(self, hero, card_uid, data):
data['hero_id'] = hero.id
data['account_id'] = hero.account_id
data['card_uid'] = card_uid
card_task = UseCardTask(processor_id=self.TYPE.value,
hero_id=hero.id,
data=data)
task = PostponedTaskPrototype.create(card_task)
environment.workers.supervisor.cmd_logic_task(hero.account_id, task.id)
return task
示例11: activate
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def activate(self, hero, data):
from the_tale.game.abilities.postponed_tasks import UseAbilityTask
data['hero_id'] = hero.id
data['account_id'] = hero.account_id
ability_task = UseAbilityTask(processor_id=self.TYPE.value,
hero_id=hero.id,
data=data)
task = PostponedTaskPrototype.create(ability_task)
environment.workers.supervisor.cmd_logic_task(hero.account_id, task.id)
return task
示例12: choose_preferences
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def choose_preferences(self):
choose_preferences_form = forms.ChoosePreferencesForm(self.request.POST)
if not choose_preferences_form.is_valid():
return self.json_error('heroes.choose_preferences.form_errors', choose_preferences_form.errors)
choose_task = postponed_tasks.ChoosePreferencesTask(hero_id=self.hero.id,
preference_type=choose_preferences_form.c.preference_type,
preference_id=choose_preferences_form.c.preference_id if choose_preferences_form.c.preference_id != '' else None)
task = PostponedTaskPrototype.create(choose_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(status_url=task.status_url)
示例13: close_lots_by_timeout
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def close_lots_by_timeout():
from the_tale.common.postponed_tasks import PostponedTaskPrototype
from the_tale.finances.market import postponed_tasks
expired_lots_query = models.Lot.objects.filter(state=relations.LOT_STATE.ACTIVE,
created_at__lt=datetime.datetime.now()-datetime.timedelta(days=conf.settings.LOT_LIVE_TIME))
tasks = []
for lot_id, seller_id in expired_lots_query.values_list('id', 'seller_id'):
logic_task = postponed_tasks.CloseLotByTimoutTask(lot_id=lot_id)
task = PostponedTaskPrototype.create(logic_task)
amqp_environment.environment.workers.market_manager.cmd_logic_task(seller_id, task.id)
tasks.append(task)
return tasks
示例14: initiate_transfer_money
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def initiate_transfer_money(sender_id, recipient_id, amount, comment):
from the_tale.common.postponed_tasks import PostponedTaskPrototype
from the_tale.accounts import postponed_tasks
commission = get_transfer_commission(amount)
task = postponed_tasks.TransferMoneyTask(sender_id=sender_id,
recipient_id=recipient_id,
amount=amount-commission,
commission=commission,
comment=comment)
task = PostponedTaskPrototype.create(task)
amqp_environment.environment.workers.refrigerator.cmd_wait_task(task.id)
return task
示例15: change_hero
# 需要导入模块: from the_tale.common.postponed_tasks import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.PostponedTaskPrototype import create [as 别名]
def change_hero(self):
edit_name_form = forms.EditNameForm(self.request.POST)
if not edit_name_form.is_valid():
return self.json_error('heroes.change_name.form_errors', edit_name_form.errors)
change_task = postponed_tasks.ChangeHeroTask(hero_id=self.hero.id,
name=edit_name_form.c.name,
race=edit_name_form.c.race,
gender=edit_name_form.c.gender)
task = PostponedTaskPrototype.create(change_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(task.status_url)