Beispiel #1
0
 def test_process_add_to_arena_queue_two_requests_from_one_account(self):
     battle_1 = Battle1x1Prototype.create(
         AccountPrototype.get_by_id(self.account_1.id))
     battle_2 = Battle1x1Prototype.create(
         AccountPrototype.get_by_id(self.account_1.id))
     self.assertEqual(Battle1x1.objects.all().count(), 1)
     self.assertEqual(battle_1.id, battle_2.id)
Beispiel #2
0
    def test_register_account_last_in_task(self):
        self.worker.process_initialize()

        Battle1x1Prototype.create(self.account_1).set_enemy(self.account_2)
        Battle1x1Prototype.create(self.account_2).set_enemy(self.account_1)
        task = SupervisorTaskPrototype.create_arena_pvp_1x1(
            self.account_1, self.account_2)

        self.worker.register_task(task)

        with mock.patch(
                'the_tale.game.workers.logic.Worker.cmd_register_account'
        ) as register_account_counter:
            self.worker.register_account(self.account_1.id)
            self.worker.register_account(self.account_2.id)

        self.assertEqual(register_account_counter.call_count, 2)
        self.assertEqual(set(self.worker.accounts_for_tasks.keys()), set())
        self.assertEqual(self.worker.tasks.values(), [])
        self.assertEqual(SupervisorTask.objects.all().count(), 0)

        self.assertEqual(self.worker.accounts_owners, {
            self.account_1.id: 'game_logic_1',
            self.account_2.id: 'game_logic_1'
        })
    def test_process_arena_pvp_1x1(self):
        task = SupervisorTaskPrototype.create_arena_pvp_1x1(
            self.account_1, self.account_2)

        task.capture_member(self.account_1.id)
        task.capture_member(self.account_2.id)

        battle_1 = Battle1x1Prototype.create(self.account_1)
        battle_1.set_enemy(self.account_2)
        battle_1.save()

        battle_2 = Battle1x1Prototype.create(self.account_2)
        battle_2.set_enemy(self.account_1)
        battle_2.save()

        self.assertEqual(
            Battle1x1.objects.filter(
                state=BATTLE_1X1_STATE.PREPAIRING).count(), 2)
        self.assertEqual(
            Battle1x1.objects.filter(
                state=BATTLE_1X1_STATE.PROCESSING).count(), 0)

        old_hero = heroes_logic.load_hero(account_id=self.account_1.id)
        old_hero.health = 1
        heroes_logic.save_hero(old_hero)

        task.process(bundle_id=666)

        new_hero = heroes_logic.load_hero(account_id=self.account_1.id)
        new_hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)

        self.assertEqual(new_hero.actions.current_action.bundle_id,
                         new_hero_2.actions.current_action.bundle_id)
        self.assertNotEqual(new_hero.actions.actions_list[0].bundle_id,
                            new_hero.actions.actions_list[1].bundle_id)
        self.assertNotEqual(new_hero_2.actions.actions_list[0].bundle_id,
                            new_hero_2.actions.actions_list[1].bundle_id)

        self.assertNotEqual(old_hero, new_hero)
        self.assertTrue(old_hero.actions.number < new_hero.actions.number)
        self.assertEqual(new_hero.health, new_hero.max_health)

        self.assertEqual(new_hero.actions.number, 2)
        self.assertEqual(new_hero_2.actions.number, 2)

        self.assertEqual(
            new_hero.actions.current_action.meta_action.serialize(),
            new_hero_2.actions.current_action.meta_action.serialize())

        self.assertEqual(
            Battle1x1.objects.filter(
                state=BATTLE_1X1_STATE.PREPAIRING).count(), 0)
        self.assertEqual(
            Battle1x1.objects.filter(
                state=BATTLE_1X1_STATE.PROCESSING).count(), 2)
Beispiel #4
0
 def test_help_when_battle_waiting(self):
     battle = Battle1x1Prototype.create(self.account)
     self.assertTrue(battle.state.is_WAITING)
     with self.check_delta(lambda: self.hero.statistics.help_count, 1):
         self.assertEqual(self.ability.use(**self.use_attributes),
                          (ComplexChangeTask.RESULT.SUCCESSED,
                           ComplexChangeTask.STEP.SUCCESS, ()))
Beispiel #5
0
    def setUp(self):
        super(SayInBattleLogTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        result, account_1_id, bundle_id = register_user(
            'test_user', '*****@*****.**', '111111')
        result, account_2_id, bundle_id = register_user(
            'test_user_2', '*****@*****.**', '111111')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.task = SayInBattleLogTask(battle_id=self.battle.id,
                                       text=u'some pvp message')
Beispiel #6
0
    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
Beispiel #7
0
    def setUp(self):
        super(UsePvPAbilityTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        result, account_1_id, bundle_id = register_user(
            'test_user', '*****@*****.**', '111111')
        result, account_2_id, bundle_id = register_user(
            'test_user_2', '*****@*****.**', '111111')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.ability = random.choice(ABILITIES.values())

        self.task = UsePvPAbilityTask(battle_id=self.battle.id,
                                      account_id=self.account_1.id,
                                      ability_id=self.ability.TYPE)
    def setUp(self):
        super(UsePvPAbilityTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        result, account_1_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        result, account_2_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.ability = random.choice(ABILITIES.values())

        self.task = UsePvPAbilityTask(battle_id=self.battle.id, account_id=self.account_1.id, ability_id=self.ability.TYPE)
Beispiel #9
0
    def setUp(self):
        super(UsePvPAbilityTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.ability = random.choice(list(ABILITIES.values()))

        self.task = UsePvPAbilityTask(battle_id=self.battle.id, account_id=self.account_1.id, ability_id=self.ability.TYPE)

        self.meta_action_battle = meta_actions.ArenaPvP1x1.create(self.storage, self.hero_1, self.hero_2)
        self.meta_action_battle.set_storage(self.storage)

        actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=self.hero_1.actions.current_action.bundle_id, meta_action=self.meta_action_battle)
        actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=self.hero_1.actions.current_action.bundle_id, meta_action=self.meta_action_battle)
Beispiel #10
0
    def test_help_when_battle_not_waiting(self):
        battle = Battle1x1Prototype.create(self.account)
        battle.state = BATTLE_1X1_STATE.PREPAIRING
        battle.save()

        self.assertFalse(battle.state.is_WAITING)
        with self.check_not_changed(lambda: self.hero.statistics.help_count):
            self.assertEqual(self.ability.use(**self.use_attributes), (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR, ()))
Beispiel #11
0
 def pvp_create_battle(self, account, enemy, state=None, calculate_rating=False):
     battle = Battle1x1Prototype.create(account)
     if enemy:
         battle.set_enemy(enemy)
     if state is not None:
         battle.state = state
     battle.calculate_rating = calculate_rating
     battle.save()
     return battle
Beispiel #12
0
    def setUp(self):
        super(BalancerTestsBase, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.hero_1 = heroes_logic.load_hero(account_id=self.account_1.id)
        self.hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)

        environment.deinitialize()
        environment.initialize()

        Battle1x1Prototype.create(self.account_1)

        self.worker = environment.workers.pvp_balancer
        self.worker.process_initialize('pvp_balancer')
Beispiel #13
0
    def setUp(self):
        super(BalancerTestsBase, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.hero_1 = heroes_logic.load_hero(account_id=self.account_1.id)
        self.hero_2 = heroes_logic.load_hero(account_id=self.account_2.id)

        environment.deinitialize()
        environment.initialize()

        Battle1x1Prototype.create(self.account_1)

        self.worker = environment.workers.pvp_balancer
        self.worker.process_initialize('pvp_balancer')
    def test_register_account_last_in_task(self):
        self.worker.process_initialize()

        Battle1x1Prototype.create(self.account_1).set_enemy(self.account_2)
        Battle1x1Prototype.create(self.account_2).set_enemy(self.account_1)
        task = SupervisorTaskPrototype.create_arena_pvp_1x1(self.account_1, self.account_2)

        self.worker.register_task(task)

        with mock.patch('the_tale.game.workers.logic.Worker.cmd_register_account') as register_account_counter:
            self.worker.register_account(self.account_1.id)
            self.worker.register_account(self.account_2.id)

        self.assertEqual(register_account_counter.call_count, 2)
        self.assertEqual(set(self.worker.accounts_for_tasks.keys()), set())
        self.assertEqual(self.worker.tasks.values(), [])
        self.assertEqual(SupervisorTask.objects.all().count(), 0)

        self.assertEqual(self.worker.accounts_owners, {self.account_1.id: 'game_logic_1', self.account_2.id: 'game_logic_1'})
    def test_1_register_task(self):
        self.worker.process_initialize()

        task = SupervisorTaskPrototype.create_arena_pvp_1x1(self.account_1, self.account_2)

        battle_1 = Battle1x1Prototype.create(self.account_1)
        battle_1.set_enemy(self.account_2)
        battle_1.save()

        battle_2 = Battle1x1Prototype.create(self.account_2)
        battle_2.set_enemy(self.account_1)
        battle_2.save()

        self.assertEqual(len(self.worker.tasks), 0)
        self.assertEqual(len(self.worker.accounts_for_tasks), 0)

        with mock.patch('the_tale.game.workers.logic.Worker.cmd_release_account') as release_accounts_counter:
            self.worker.register_task(task, release_accounts=True)

        self.assertEqual(len(self.worker.tasks), 1)
        self.assertEqual(len(self.worker.accounts_for_tasks), 2)
        self.assertFalse(self.worker.tasks.values()[0].all_members_captured)
        self.assertEqual(self.worker.accounts_owners, {self.account_1.id: None, self.account_2.id: None})
        self.assertEqual(self.worker.accounts_queues, {})

        self.worker.process_account_released(self.account_1.id)
        self.assertEqual(self.worker.accounts_owners, {self.account_1.id: 'game_supervisor', self.account_2.id: None})

        #test commands queue
        self.worker.process_start_hero_caching(self.account_1.id)
        self.worker.process_start_hero_caching(self.account_2.id)
        self.worker.process_logic_task(self.account_1.id, 666)
        self.assertEqual(self.worker.accounts_queues, { self.account_1.id: [('start_hero_caching', {'account_id': self.account_1.id}),
                                                                            ('logic_task', {'account_id': self.account_1.id, 'task_id': 666}),],
                                                        self.account_2.id: [('start_hero_caching', {'account_id': self.account_2.id})]})

        self.worker.process_account_released(self.account_2.id)
        self.assertEqual(self.worker.accounts_owners, {self.account_1.id: 'game_logic_1', self.account_2.id: 'game_logic_1'})

        self.assertEqual(len(self.worker.tasks), 0)

        self.assertEqual(release_accounts_counter.call_count, 2)
    def test_process_arena_pvp_1x1(self):
        task = SupervisorTaskPrototype.create_arena_pvp_1x1(self.account_1, self.account_2)

        task.capture_member(self.account_1.id)
        task.capture_member(self.account_2.id)

        battle_1 = Battle1x1Prototype.create(self.account_1)
        battle_1.set_enemy(self.account_2)
        battle_1.save()

        battle_2 = Battle1x1Prototype.create(self.account_2)
        battle_2.set_enemy(self.account_1)
        battle_2.save()

        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PREPAIRING).count(), 2)
        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PROCESSING).count(), 0)

        old_hero = HeroPrototype.get_by_account_id(self.account_1.id)
        old_hero.health = 1
        old_hero.save()

        task.process(bundle_id=666)

        new_hero = HeroPrototype.get_by_account_id(self.account_1.id)
        new_hero_2 = HeroPrototype.get_by_account_id(self.account_2.id)

        self.assertEqual(new_hero.actions.current_action.bundle_id, new_hero_2.actions.current_action.bundle_id)
        self.assertNotEqual(new_hero.actions.actions_list[0].bundle_id, new_hero.actions.actions_list[1].bundle_id)
        self.assertNotEqual(new_hero_2.actions.actions_list[0].bundle_id, new_hero_2.actions.actions_list[1].bundle_id)

        self.assertNotEqual(old_hero, new_hero)
        self.assertTrue(old_hero.actions.number < new_hero.actions.number)
        self.assertEqual(new_hero.health, new_hero.max_health)

        self.assertEqual(new_hero.actions.number, 2)
        self.assertEqual(new_hero_2.actions.number, 2)

        self.assertEqual(new_hero.actions.current_action.meta_action.serialize(),
                         new_hero_2.actions.current_action.meta_action.serialize())

        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PREPAIRING).count(), 0)
        self.assertEqual(Battle1x1.objects.filter(state=BATTLE_1X1_STATE.PROCESSING).count(), 2)
Beispiel #17
0
    def test_help_when_battle_not_waiting(self):
        battle = Battle1x1Prototype.create(self.account)
        battle.state = BATTLE_1X1_STATE.PREPAIRING
        battle.save()

        self.assertFalse(battle.state.is_WAITING)
        with self.check_not_changed(lambda: self.hero.statistics.help_count):
            self.assertEqual(
                self.ability.use(**self.use_attributes),
                (ComplexChangeTask.RESULT.FAILED, ComplexChangeTask.STEP.ERROR,
                 ()))
Beispiel #18
0
    def test_process_leave_queue_not_waiting_state(self):
        battle_1 = Battle1x1Prototype.create(self.account_1)

        battle_1.set_enemy(self.account_2)
        battle_1.save()

        self.assertTrue(Battle1x1Prototype.get_by_id(battle_1.id).state.is_PREPAIRING)

        self.worker.leave_arena_queue(self.hero_1.id)

        self.assertTrue(Battle1x1Prototype.get_by_id(battle_1.id).state.is_PREPAIRING)
Beispiel #19
0
    def test_process_leave_queue_not_waiting_state(self):
        battle_1 = Battle1x1Prototype.create(self.account_1)

        battle_1.set_enemy(self.account_2)
        battle_1.save()

        self.assertTrue(Battle1x1Prototype.get_by_id(battle_1.id).state.is_PREPAIRING)

        self.worker.leave_arena_queue(self.hero_1.id)

        self.assertTrue(Battle1x1Prototype.get_by_id(battle_1.id).state.is_PREPAIRING)
Beispiel #20
0
    def setUp(self):
        super(BalancerTestsBase, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        result, account_1_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        result, account_2_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.hero_1 = HeroPrototype.get_by_account_id(account_1_id)
        self.hero_2 = HeroPrototype.get_by_account_id(account_2_id)

        environment.deinitialize()
        environment.initialize()

        Battle1x1Prototype.create(self.account_1)

        self.worker = environment.workers.pvp_balancer
        self.worker.process_initialize('pvp_balancer')
Beispiel #21
0
    def setUp(self):
        super(BalancerTestsBase, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        result, account_1_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        result, account_2_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.hero_1 = heroes_logic.load_hero(account_id=account_1_id)
        self.hero_2 = heroes_logic.load_hero(account_id=account_2_id)

        environment.deinitialize()
        environment.initialize()

        Battle1x1Prototype.create(self.account_1)

        self.worker = environment.workers.pvp_balancer
        self.worker.process_initialize('pvp_balancer')
Beispiel #22
0
 def pvp_create_battle(self,
                       account,
                       enemy,
                       state=None,
                       calculate_rating=False):
     battle = Battle1x1Prototype.create(account)
     if enemy:
         battle.set_enemy(enemy)
     if state is not None:
         battle.state = state
     battle.calculate_rating = calculate_rating
     battle.save()
     return battle
Beispiel #23
0
    def setUp(self):
        super(SayInBattleLogTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.task = SayInBattleLogTask(battle_id=self.battle.id, text='some pvp message')
Beispiel #24
0
    def setUp(self):
        super(SayInBattleLogTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.task = SayInBattleLogTask(battle_id=self.battle.id,
                                       text='some pvp message')
Beispiel #25
0
    def add_to_arena_queue(self, hero_id):

        hero = heroes_logic.load_hero(hero_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
    def setUp(self):
        super(SayInBattleLogTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        result, account_1_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        result, account_2_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')

        self.account_1 = AccountPrototype.get_by_id(account_1_id)
        self.account_2 = AccountPrototype.get_by_id(account_2_id)

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.task = SayInBattleLogTask(battle_id=self.battle.id, text=u'some pvp message')
Beispiel #27
0
    def setUp(self):
        super(UsePvPAbilityTests, self).setUp()

        self.p1, self.p2, self.p3 = create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.storage = LogicStorage()
        self.storage.load_account_data(self.account_1)
        self.storage.load_account_data(self.account_2)

        self.hero_1 = self.storage.accounts_to_heroes[self.account_1.id]
        self.hero_2 = self.storage.accounts_to_heroes[self.account_2.id]

        self.battle = Battle1x1Prototype.create(self.account_1)
        self.battle.set_enemy(self.account_2)
        self.battle.save()

        self.ability = random.choice(list(ABILITIES.values()))

        self.task = UsePvPAbilityTask(battle_id=self.battle.id,
                                      account_id=self.account_1.id,
                                      ability_id=self.ability.TYPE)

        self.meta_action_battle = meta_actions.ArenaPvP1x1.create(
            self.storage, self.hero_1, self.hero_2)
        self.meta_action_battle.set_storage(self.storage)

        actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_1,
            _bundle_id=self.hero_1.actions.current_action.bundle_id,
            meta_action=self.meta_action_battle)
        actions_prototypes.ActionMetaProxyPrototype.create(
            hero=self.hero_2,
            _bundle_id=self.hero_1.actions.current_action.bundle_id,
            meta_action=self.meta_action_battle)
Beispiel #28
0
 def test_process_add_to_arena_queue_two_requests_from_one_account(self):
     battle_1 = Battle1x1Prototype.create(AccountPrototype.get_by_id(self.account_1.id))
     battle_2 = Battle1x1Prototype.create(AccountPrototype.get_by_id(self.account_1.id))
     self.assertEqual(Battle1x1.objects.all().count(), 1)
     self.assertEqual(battle_1.id, battle_2.id)
Beispiel #29
0
 def test_help_when_battle_waiting(self):
     battle = Battle1x1Prototype.create(self.account)
     self.assertTrue(battle.state.is_WAITING)
     with self.check_delta(lambda: self.hero.statistics.help_count, 1):
         self.assertEqual(self.ability.use(**self.use_attributes), (ComplexChangeTask.RESULT.SUCCESSED, ComplexChangeTask.STEP.SUCCESS, ()))