def setUp(self): super(MetaProxyActionForArenaPvP1x1Tests, self).setUp() create_test_map() result, account_1_id, bundle_id = register_user('test_user_1', '*****@*****.**', '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(AccountPrototype.get_by_id(self.account_1.id)) self.storage.load_account_data(AccountPrototype.get_by_id(self.account_2.id)) self.hero_1 = self.storage.accounts_to_heroes[account_1_id] self.hero_2 = self.storage.accounts_to_heroes[account_2_id] self.action_idl_1 = self.hero_1.actions.current_action self.action_idl_2 = self.hero_2.actions.current_action self.pvp_create_battle(self.account_1, self.account_2, BATTLE_1X1_STATE.PROCESSING) self.pvp_create_battle(self.account_2, self.account_1, BATTLE_1X1_STATE.PROCESSING) self.bundle_id = 666 meta_action_battle = MetaActionArenaPvP1x1Prototype.create(self.storage, self.hero_1, self.hero_2, bundle_id=self.bundle_id) self.action_proxy_1 = ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=self.bundle_id, meta_action=meta_action_battle) self.action_proxy_2 = ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=self.bundle_id, meta_action=meta_action_battle) self.storage.merge_bundles([self.action_idl_1.bundle_id, self.action_idl_2.bundle_id], self.bundle_id) self.meta_action_battle = self.storage.meta_actions.values()[0]
def setUp(self): super(MetaProxyActionForArenaPvP1x1Tests, self).setUp() 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(AccountPrototype.get_by_id(self.account_1.id)) self.storage.load_account_data(AccountPrototype.get_by_id(self.account_2.id)) 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.action_idl_1 = self.hero_1.actions.current_action self.action_idl_2 = self.hero_2.actions.current_action self.pvp_create_battle(self.account_1, self.account_2, BATTLE_1X1_STATE.PROCESSING) self.pvp_create_battle(self.account_2, self.account_1, BATTLE_1X1_STATE.PROCESSING) self.bundle_id = 666 meta_action_battle = meta_actions.ArenaPvP1x1.create(self.storage, self.hero_1, self.hero_2) self.action_proxy_1 = ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=self.bundle_id, meta_action=meta_action_battle) self.action_proxy_2 = ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=self.bundle_id, meta_action=meta_action_battle) self.storage.merge_bundles([self.action_idl_1.bundle_id, self.action_idl_2.bundle_id], self.bundle_id) self.meta_action_battle = self.storage.meta_actions.values()[0]
def process_arena_pvp_1x1(self, bundle_id): # pylint: disable=R0914 from the_tale.accounts.prototypes import AccountPrototype from the_tale.game.actions.prototypes import ActionMetaProxyPrototype from the_tale.game.actions import meta_actions from the_tale.game.logic_storage import LogicStorage from the_tale.game.pvp.prototypes import Battle1x1Prototype from the_tale.game.pvp.models import BATTLE_1X1_STATE storage = LogicStorage() account_1_id, account_2_id = list(self.members) account_1 = AccountPrototype.get_by_id(account_1_id) account_2 = AccountPrototype.get_by_id(account_2_id) storage.load_account_data(account_1) storage.load_account_data(account_2) hero_1 = storage.accounts_to_heroes[account_1_id] hero_2 = storage.accounts_to_heroes[account_2_id] old_bundle_1_id = hero_1.actions.current_action.bundle_id old_bundle_2_id = hero_2.actions.current_action.bundle_id meta_action_battle = meta_actions.ArenaPvP1x1.create( storage, hero_1, hero_2) ActionMetaProxyPrototype.create(hero=hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle) ActionMetaProxyPrototype.create(hero=hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle) storage.merge_bundles([old_bundle_1_id, old_bundle_2_id], bundle_id) storage.save_bundle_data(bundle_id) battle_1 = Battle1x1Prototype.get_by_account_id(account_1_id) battle_1.state = BATTLE_1X1_STATE.PROCESSING battle_1.save() battle_2 = Battle1x1Prototype.get_by_account_id(account_2_id) battle_2.state = BATTLE_1X1_STATE.PROCESSING battle_2.save()
def setUp(self): super(MetaProxyActionForArenaPvP1x1Tests, self).setUp() 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( AccountPrototype.get_by_id(self.account_1.id)) self.storage.load_account_data( AccountPrototype.get_by_id(self.account_2.id)) 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.action_idl_1 = self.hero_1.actions.current_action self.action_idl_2 = self.hero_2.actions.current_action self.pvp_create_battle(self.account_1, self.account_2, BATTLE_1X1_STATE.PROCESSING) self.pvp_create_battle(self.account_2, self.account_1, BATTLE_1X1_STATE.PROCESSING) self.bundle_id = 666 meta_action_battle = meta_actions.ArenaPvP1x1.create( self.storage, self.hero_1, self.hero_2) self.action_proxy_1 = ActionMetaProxyPrototype.create( hero=self.hero_1, _bundle_id=self.bundle_id, meta_action=meta_action_battle) self.action_proxy_2 = ActionMetaProxyPrototype.create( hero=self.hero_2, _bundle_id=self.bundle_id, meta_action=meta_action_battle) self.storage.merge_bundles( [self.action_idl_1.bundle_id, self.action_idl_2.bundle_id], self.bundle_id) self.meta_action_battle = self.storage.meta_actions.values()[0]
def process_arena_pvp_1x1(self, bundle_id): # pylint: disable=R0914 from the_tale.accounts.prototypes import AccountPrototype from the_tale.game.actions.prototypes import ActionMetaProxyPrototype from the_tale.game.actions import meta_actions from the_tale.game.logic_storage import LogicStorage from the_tale.game.pvp.prototypes import Battle1x1Prototype from the_tale.game.pvp.models import BATTLE_1X1_STATE storage = LogicStorage() account_1_id, account_2_id = list(self.members) account_1 = AccountPrototype.get_by_id(account_1_id) account_2 = AccountPrototype.get_by_id(account_2_id) storage.load_account_data(account_1) storage.load_account_data(account_2) hero_1 = storage.accounts_to_heroes[account_1_id] hero_2 = storage.accounts_to_heroes[account_2_id] old_bundle_1_id = hero_1.actions.current_action.bundle_id old_bundle_2_id = hero_2.actions.current_action.bundle_id meta_action_battle = meta_actions.ArenaPvP1x1.create(storage, hero_1, hero_2) ActionMetaProxyPrototype.create(hero=hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle) ActionMetaProxyPrototype.create(hero=hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle) storage.merge_bundles([old_bundle_1_id, old_bundle_2_id], bundle_id) storage.save_bundle_data(bundle_id) battle_1 = Battle1x1Prototype.get_by_account_id(account_1_id) battle_1.state = BATTLE_1X1_STATE.PROCESSING battle_1.save() battle_2 = Battle1x1Prototype.get_by_account_id(account_2_id) battle_2.state = BATTLE_1X1_STATE.PROCESSING battle_2.save()