本文整理汇总了Python中the_tale.game.pvp.prototypes.Battle1x1Prototype.get_by_account_id方法的典型用法代码示例。如果您正苦于以下问题:Python Battle1x1Prototype.get_by_account_id方法的具体用法?Python Battle1x1Prototype.get_by_account_id怎么用?Python Battle1x1Prototype.get_by_account_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.game.pvp.prototypes.Battle1x1Prototype
的用法示例。
在下文中一共展示了Battle1x1Prototype.get_by_account_id方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_initiate_battle_with_bot__create_battle
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def test_initiate_battle_with_bot__create_battle(self):
self.hero_1._model.level = 50
self.hero_1.save()
result, bot_account_id, bundle_id = register_user('bot_user', '[email protected]', '111111', is_bot=True)
records_to_remove, records_to_exclude = self.worker._initiate_battle_with_bot(self.battle_1_record())
bot_battle = Battle1x1Prototype.get_by_id(records_to_exclude[1].battle_id)
bot_record = QueueRecord(account_id=bot_account_id,
battle_id=bot_battle.id,
created_at=bot_battle.created_at + datetime.timedelta(seconds=0),
hero_level=1)
self.assertEqual(records_to_remove, [])
self.assertEqual(records_to_exclude, [self.battle_1_record(), bot_record])
self.assertEqual(SupervisorTask.objects.all().count(), 1)
battle_player = Battle1x1Prototype.get_by_account_id(self.account_1.id)
battle_bot = Battle1x1Prototype.get_by_account_id(bot_account_id)
self.assertEqual(battle_player.enemy_id, bot_account_id)
self.assertFalse(battle_player.calculate_rating)
self.assertEqual(battle_bot.enemy_id, self.account_1.id)
self.assertFalse(battle_bot.calculate_rating)
示例2: accept_battle
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def accept_battle(cls, pvp_balancer, battle_id, hero_id):
accepted_battle = Battle1x1Prototype.get_by_id(battle_id)
if accepted_battle is None:
return ACCEPT_BATTLE_RESULT.BATTLE_NOT_FOUND
if not accepted_battle.state.is_WAITING:
return ACCEPT_BATTLE_RESULT.WRONG_ACCEPTED_BATTLE_STATE
if not accepted_battle.account_id in pvp_balancer.arena_queue:
return ACCEPT_BATTLE_RESULT.NOT_IN_QUEUE
initiator_id = heroes_logic.load_hero(hero_id=hero_id).account_id
initiator_battle = Battle1x1Prototype.get_by_account_id(initiator_id)
if initiator_battle is not None and not initiator_battle.state.is_WAITING:
return ACCEPT_BATTLE_RESULT.WRONG_INITIATOR_BATTLE_STATE
if initiator_id not in pvp_balancer.arena_queue:
pvp_balancer.add_to_arena_queue(hero_id)
pvp_balancer.force_battle(accepted_battle.account_id, initiator_id)
return ACCEPT_BATTLE_RESULT.PROCESSED
示例3: use_ability
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [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)
示例4: leave_arena_queue
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def leave_arena_queue(self, hero_id):
hero = heroes_logic.load_hero(hero_id=hero_id)
battle = Battle1x1Prototype.get_by_account_id(hero.account_id)
if not battle.state.is_WAITING:
return
if battle.account_id not in self.arena_queue:
self.logger.error("can not leave queue: battle %d in waiting state but no in arena queue" % battle.id)
return
del self.arena_queue[battle.account_id]
battle.remove()
示例5: use
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def use(self, task, storage, **kwargs): # pylint: disable=R0911
battle = Battle1x1Prototype.get_by_account_id(task.hero.account_id)
if battle and not battle.state.is_WAITING:
return task.logic_result(next_step=ComplexChangeTask.STEP.ERROR)
if not task.hero.can_be_helped():
return task.logic_result(next_step=ComplexChangeTask.STEP.ERROR)
task.hero.on_help()
action = task.hero.actions.current_action
choice = action.get_help_choice()
if choice is None:
return task.logic_result(next_step=ComplexChangeTask.STEP.ERROR)
if action.HABIT_MODE.is_AGGRESSIVE:
task.hero.update_habits(HABIT_CHANGE_SOURCE.HELP_AGGRESSIVE)
elif action.HABIT_MODE.is_PEACEFUL:
task.hero.update_habits(HABIT_CHANGE_SOURCE.HELP_UNAGGRESSIVE)
elif action.HABIT_MODE.is_COMPANION:
if task.hero.companion:
for habit_source in task.hero.companion.modify_attribute(heroes_relations.MODIFIERS.HABITS_SOURCES, set()):
task.hero.update_habits(habit_source, multuplier=task.hero.companion_habits_multiplier)
else:
raise exceptions.UnknownHabitModeError(mode=action.HABIT_MODE)
critical = random.uniform(0, 1) < task.hero.might_crit_chance
result = self._use(task, choice, action, task.hero, critical)
if result[0].is_SUCCESSED:
task.hero.statistics.change_help_count(1)
if task.hero.actions.current_action.state == task.hero.actions.current_action.STATE.PROCESSED:
storage.process_turn__single_hero(hero=task.hero,
logger=None,
continue_steps_if_needed=True)
task.hero.cards.change_help_count(1)
self.process_removed_artifacts(task.hero)
return result
示例6: say
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def say(self):
battle = Battle1x1Prototype.get_by_account_id(self.account.id)
if battle is None or not battle.state.is_PROCESSING:
return self.json_error("pvp.say.no_battle", u"Бой не идёт, вы не можете говорить")
say_form = SayForm(self.request.POST)
if not say_form.is_valid():
return self.json_error("pvp.say.form_errors", say_form.errors)
say_task = SayInBattleLogTask(battle_id=battle.id, text=say_form.c.text)
task = PostponedTaskPrototype.create(say_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(task.status_url)
示例7: use
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def use(self, task, storage, pvp_balancer=None, **kwargs):
if task.step.is_LOGIC:
battle = Battle1x1Prototype.get_by_account_id(task.hero.account_id)
if battle is None:
return task.logic_result()
task.hero.add_message('angel_ability_arena_pvp_1x1_leave_queue', hero=task.hero)
task.hero.update_habits(HABIT_CHANGE_SOURCE.ARENA_LEAVE)
return task.logic_result(next_step=ComplexChangeTask.STEP.PVP_BALANCER)
elif task.step.is_PVP_BALANCER:
pvp_balancer.leave_arena_queue(task.data['hero_id'])
return task.logic_result()
示例8: use
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def use(self, task, storage, pvp_balancer, **kwargs):
if task.step.is_LOGIC:
if not task.hero.can_participate_in_pvp:
return task.logic_result(next_step=ComplexChangeTask.STEP.ERROR)
task.hero.add_message('angel_ability_arena_pvp_1x1', hero=task.hero)
task.hero.update_habits(HABIT_CHANGE_SOURCE.ARENA_SEND)
return task.logic_result(next_step=ComplexChangeTask.STEP.PVP_BALANCER)
elif task.step.is_PVP_BALANCER:
battle = Battle1x1Prototype.get_by_account_id(task.data['account_id'])
if battle is None:
pvp_balancer.add_to_arena_queue(task.data['hero_id'])
return task.logic_result()
示例9: pvp_page
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def pvp_page(self):
battle = Battle1x1Prototype.get_by_account_id(self.account.id)
if battle is None or not battle.state.is_PROCESSING:
return self.redirect(reverse("game:"))
own_abilities = sorted(self.own_hero.abilities.all, key=lambda x: x.NAME)
enemy_account = AccountPrototype.get_by_id(battle.enemy_id)
enemy_hero = HeroPrototype.get_by_account_id(battle.enemy_id)
enemy_abilities = sorted(enemy_hero.abilities.all, key=lambda x: x.NAME)
say_form = SayForm()
clan = None
if self.account.clan_id is not None:
clan = ClanPrototype.get_by_id(self.account.clan_id)
enemy_clan = None
if enemy_account.clan_id is not None:
enemy_clan = ClanPrototype.get_by_id(enemy_account.clan_id)
return self.template(
"pvp/pvp_page.html",
{
"enemy_account": AccountPrototype.get_by_id(battle.enemy_id),
"own_hero": self.own_hero,
"own_abilities": own_abilities,
"enemy_abilities": enemy_abilities,
"game_settings": game_settings,
"say_form": say_form,
"clan": clan,
"enemy_clan": enemy_clan,
"battle": battle,
"EQUIPMENT_SLOT": EQUIPMENT_SLOT,
"ABILITIES": (Ice, Blood, Flame),
},
)
示例10: game_page
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def game_page(context):
battle = Battle1x1Prototype.get_by_account_id(context.account.id)
if battle and battle.state.is_PROCESSING:
return dext_views.Redirect(url('game:pvp:'))
clan = None
if context.account.clan_id is not None:
clan = ClanPrototype.get_by_id(context.account.clan_id)
cards = sorted(EFFECTS.values(), key=lambda x: (x.TYPE.rarity.value, x.TYPE.text))
return dext_views.Page('game/game_page.html',
content={'map_settings': map_settings,
'game_settings': game_settings,
'EQUIPMENT_SLOT': EQUIPMENT_SLOT,
'current_map_version': map_info_storage.version,
'clan': clan,
'CARDS': cards,
'resource': context.resource,
'hero': context.account_hero} )
示例11: pvp_page
# 需要导入模块: from the_tale.game.pvp.prototypes import Battle1x1Prototype [as 别名]
# 或者: from the_tale.game.pvp.prototypes.Battle1x1Prototype import get_by_account_id [as 别名]
def pvp_page(self):
battle = Battle1x1Prototype.get_by_account_id(self.account.id)
if battle is None or not battle.state.is_PROCESSING:
return self.redirect(reverse('game:'))
own_abilities = sorted(self.own_hero.abilities.all, key=lambda x: x.NAME)
enemy_account = AccountPrototype.get_by_id(battle.enemy_id)
enemy_hero = HeroPrototype.get_by_account_id(battle.enemy_id)
enemy_abilities = sorted(enemy_hero.abilities.all, key=lambda x: x.NAME)
say_form = SayForm()
clan = None
if self.account.clan_id is not None:
clan = ClanPrototype.get_by_id(self.account.clan_id)
enemy_clan = None
if enemy_account.clan_id is not None:
enemy_clan = ClanPrototype.get_by_id(enemy_account.clan_id)
return self.template('pvp/pvp_page.html',
{'enemy_account': AccountPrototype.get_by_id(battle.enemy_id),
'own_hero': self.own_hero,
'own_abilities': own_abilities,
'enemy_abilities': enemy_abilities,
'game_settings': game_settings,
'say_form': say_form,
'clan': clan,
'enemy_clan': enemy_clan,
'battle': battle,
'EQUIPMENT_SLOT': EQUIPMENT_SLOT,
'ABILITIES': (Ice, Blood, Flame)} )