예제 #1
0
    def activate(self, hero, data):
        from the_tale.game.abilities.postponed_tasks import UseAbilityTask

        data['transaction_id'] = None

        if self.TYPE.cost > 0:

            status, transaction_id = game_tt_api.change_energy_balance(
                account_id=hero.account_id,
                type='help-{}'.format(self.TYPE.value),
                energy=-self.TYPE.cost,
                async=False,
                autocommit=False)

            if not status:
                return None

            data['transaction_id'] = transaction_id

        data['hero_id'] = hero.id
        data['account_id'] = hero.account_id

        ability_task = UseAbilityTask(processor_id=self.TYPE.value,
                                      hero_id=hero.id,
                                      data=data)

        task = PostponedTaskPrototype.create(ability_task)

        environment.workers.supervisor.cmd_logic_task(hero.account_id, task.id)

        return task
예제 #2
0
    def setUp(self):
        super(UseAbilityTasksTests, self).setUp()

        create_test_map()

        self.account = self.accounts_factory.create_account()
        self.storage = LogicStorage()
        self.storage.load_account_data(self.account)
        self.hero = self.storage.accounts_to_heroes[self.account.id]

        self.task = UseAbilityTask(processor_id=ABILITY_TYPE.HELP.value,
                                   hero_id=self.hero.id,
                                   data={'hero_id': self.hero.id})
예제 #3
0
    def setUp(self):
        super(ComplexChangeTasksTests, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '*****@*****.**', '111111')

        self.account = AccountPrototype.get_by_id(account_id)
        self.storage = LogicStorage()
        self.storage.load_account_data(self.account)
        self.hero = self.storage.accounts_to_heroes[self.account.id]

        self.task = UseAbilityTask(processor_id=ABILITY_TYPE.HELP.value,
                                   hero_id=self.hero.id,
                                   data={'hero_id': self.hero.id})
예제 #4
0
    def activate(self, hero, data):
        from the_tale.game.abilities.postponed_tasks import UseAbilityTask

        data['hero_id'] = hero.id
        data['account_id'] = hero.account_id

        ability_task = UseAbilityTask(processor_id=self.TYPE.value,
                                      hero_id=hero.id,
                                      data=data)

        task = PostponedTaskPrototype.create(ability_task)

        environment.workers.supervisor.cmd_logic_task(hero.account_id, task.id)

        return task