本文整理汇总了Python中the_tale.game.heroes.prototypes.HeroPrototype.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python HeroPrototype.get_by_id方法的具体用法?Python HeroPrototype.get_by_id怎么用?Python HeroPrototype.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.game.heroes.prototypes.HeroPrototype
的用法示例。
在下文中一共展示了HeroPrototype.get_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_all
# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
def test_save_all(self):
self.hero_1.health = 1
self.hero_2.health = 1
self.hero_1.actions.updated = True
self.storage.save_all()
self.assertEqual(self.hero_1.health, HeroPrototype.get_by_id(self.hero_1.id).health)
self.assertEqual(self.hero_2.health, HeroPrototype.get_by_id(self.hero_2.id).health)
self.assertFalse(self.hero_1.actions.updated)
示例2: accept_battle
# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_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 = HeroPrototype.get_by_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: _test_save
# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
def _test_save(self):
for hero_id in self.heroes:
self._save_hero_data(hero_id)
test_storage = LogicStorage()
for hero_id in self.heroes:
test_storage._add_hero(HeroPrototype.get_by_id(hero_id))
return self == test_storage
示例4: test_use
# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
def test_use(self):
self.hero.add_experience(self.hero.experience_to_next_level / 2)
self.assertTrue(self.hero.experience > 0)
self.assertEqual(self.hero.level, 1)
with self.check_not_changed(lambda: self.hero.experience):
with self.check_delta(lambda: self.hero.level, 1):
result, step, postsave_actions = self.card.use(**self.use_attributes(storage=self.storage, hero=self.hero))
self.assertEqual((result, step, postsave_actions), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))
saved_hero = HeroPrototype.get_by_id(self.hero.id)
self.assertEqual(saved_hero.abilities.destiny_points, self.abilities.destiny_points)
示例5: test_dispatch_command_for_unregistered_account
# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
def test_dispatch_command_for_unregistered_account(self):
self.worker.process_initialize()
result, account_3_id, bundle_id = register_user('test_user_3', '[email protected]', '111111')
account_3 = AccountPrototype.get_by_id(account_3_id)
hero_3 = HeroPrototype.get_by_id(account_3_id)
with mock.patch('the_tale.game.workers.logic.Worker.cmd_logic_task') as logic_task_counter:
with mock.patch.object(self.worker.logger, 'warn') as logger_warn_counter:
self.worker.process_update_hero_with_account_data(account_3_id,
is_fast=account_3.is_fast,
premium_end_at=account_3.premium_end_at,
active_end_at=account_3.active_end_at,
ban_end_at=account_3.ban_game_end_at,
might=666,
actual_bills=7)
self.assertEqual(logic_task_counter.call_count, 0)
self.assertEqual(logger_warn_counter.call_count, 1)
self.assertFalse(account_3_id in self.worker.accounts_owners)
self.assertTrue(account_3_id in self.worker.accounts_queues)
示例6: add_to_arena_queue
# 需要导入模块: from the_tale.game.heroes.prototypes import HeroPrototype [as 别名]
# 或者: from the_tale.game.heroes.prototypes.HeroPrototype import get_by_id [as 别名]
def add_to_arena_queue(self, hero_id):
hero = HeroPrototype.get_by_id(hero_id)
if hero.account_id in self.arena_queue:
return None
battle = Battle1x1Prototype.create(AccountPrototype.get_by_id(hero.account_id))
if not battle.state.is_WAITING:
raise PvPBalancerException('account %d already has battle not in waiting state' % hero.account_id)
record = QueueRecord(account_id=battle.account_id,
created_at=battle.created_at,
battle_id=battle.id,
hero_level=hero.level)
if record.account_id in self.arena_queue:
raise PvPBalancerException('account %d already added in balancer queue' % record.account_id)
self.arena_queue[record.account_id] = record
return battle