def test_wrong_ability_id(self): task = UsePvPAbilityTask(battle_id=self.battle.id, account_id=self.account_1.id, ability_id='wrong_ability_id') task.process(FakePostpondTaskPrototype(), self.storage) self.assertEqual(task.state, USE_PVP_ABILITY_TASK_STATE.WRONG_ABILITY_ID)
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 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)
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)