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() 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)
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 get_bot_pvp_properties(self): from the_tale.game.pvp.abilities import ABILITIES if 'bot_pvp_properties' in self.data: return self.data['bot_pvp_properties'] priorities = {ability.TYPE: random.uniform(0.1, 1.0) for ability in ABILITIES.values()} priorities_sum = sum(priorities.values()) priorities = {ability_type: ability_priority/priorities_sum for ability_type, ability_priority in priorities.items()} self.data['bot_pvp_properties'] = {'priorities': priorities, 'ability_chance': random.uniform(0.1, 0.33)} return self.data['bot_pvp_properties']
def get_bot_pvp_properties(cls): bot_priorities = { ability.TYPE: random.uniform(0.1, 1.0) for ability in PVP_ABILITIES.values() } bot_priorities_sum = sum(bot_priorities.values()) bot_priorities = { ability_type: ability_priority / bot_priorities_sum for ability_type, ability_priority in bot_priorities.items() } return { 'priorities': bot_priorities, 'ability_chance': random.uniform(0.1, 0.33) }
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)
def get_bot_pvp_properties(cls): bot_priorities = {ability.TYPE: random.uniform(0.1, 1.0) for ability in PVP_ABILITIES.values()} bot_priorities_sum = sum(bot_priorities.values()) bot_priorities = {ability_type: ability_priority/bot_priorities_sum for ability_type, ability_priority in bot_priorities.items()} return {'priorities': bot_priorities, 'ability_chance': random.uniform(0.1, 0.33)}
def setUp(self): super(UsePvPAbilityRequestsTests, self).setUp() self.ability = random.choice(ABILITIES.values()) self.change_style_url = url('game:pvp:use-ability', ability=self.ability.TYPE)