Пример #1
0
    def setUp(self):
        super(BuyMarketLotPosponedTaskTests, self).setUp()

        self.seller_account = self.accounts_factory.create_account()

        tt_api.debug_clear_service()
        cards_tt_api.debug_clear_service()

        self.card = cards.CARD.LEVEL_UP.effect.create_card(
            available_for_auction=True, type=cards.CARD.LEVEL_UP)

        cards_tt_api.change_cards(accounts_logic.get_system_user_id(),
                                  operation_type='#test',
                                  to_add=[self.card])

        self.lot = objects.Lot(owner_id=self.seller_account.id,
                               full_type=self.card.item_full_type,
                               item_id=self.card.uid,
                               price=self.amount)

        tt_api.place_sell_lots([self.lot])

        self.task = logic.close_lot(item_type=self.lot.full_type,
                                    price=self.amount,
                                    buyer_id=self.account.id)
        self.invoice = bank_prototypes.InvoicePrototype.get_by_id(
            self.task.transaction.invoice_id)

        self.market_basic_information = tt_api.info()

        self.cmd_update_with_account_data__call_count = 0  # no need in updating hero state
        self.with_referrals = False  # no money for referrals

        pm_tt_api.debug_clear_service()
Пример #2
0
    def setUp(self):
        super().setUp()

        tt_api.debug_clear_service()
        cards_tt_api.debug_clear_service()

        self.cards = [
            cards.CARD.LEVEL_UP.effect.create_card(available_for_auction=True,
                                                   type=cards.CARD.LEVEL_UP),
            cards.CARD.LEVEL_UP.effect.create_card(available_for_auction=True,
                                                   type=cards.CARD.LEVEL_UP),
            cards.CARD.ADD_GOLD_COMMON.effect.create_card(
                available_for_auction=True, type=cards.CARD.ADD_GOLD_COMMON)
        ]

        cards_tt_api.change_cards(self.account.id,
                                  operation_type='#test',
                                  to_add=self.cards)

        self.post_ajax_json(logic.create_sell_lot_url(), {
            'card': [self.cards[0].uid, self.cards[2].uid],
            'price': 100
        })
        self.post_ajax_json(logic.create_sell_lot_url(), {
            'card': [self.cards[1].uid],
            'price': 100500
        })
Пример #3
0
    def setUp(self):
        super(CreateSellLotTests, self).setUp()

        tt_api.debug_clear_service()
        cards_tt_api.debug_clear_service()

        self.cards = [cards.CARD.LEVEL_UP.effect.create_card(available_for_auction=True, type=cards.CARD.LEVEL_UP),
                      cards.CARD.ADD_GOLD_COMMON.effect.create_card(available_for_auction=True, type=cards.CARD.ADD_GOLD_COMMON)]

        cards_tt_api.change_cards(self.account.id, operation_type='#test', to_add=self.cards)
Пример #4
0
 def test_no_cards_in_storage(self):
     cards_tt_api.change_cards(self.account.id,
                               operation_type='#test',
                               to_remove=[self.cards[0]])
     response = self.post_ajax_json(
         logic.create_sell_lot_url(), {
             'cards': [self.cards[0].uid, self.cards[1].uid],
             'price': 100500
         })
     self.check_ajax_error(response, 'card.not_specified')
Пример #5
0
 def test_not_tradable_card(self):
     wrong_card = cards.CARD.CANCEL_QUEST.effect.create_card(
         available_for_auction=False, type=cards.CARD.CANCEL_QUEST)
     cards_tt_api.change_cards(self.account.id,
                               operation_type='#test',
                               to_add=[wrong_card])
     response = self.post_ajax_json(
         logic.create_sell_lot_url(), {
             'card': [self.cards[0].uid, self.cards[1].uid, wrong_card.uid],
             'price': 100
         })
     self.check_ajax_error(response, 'not_available_for_auction')
Пример #6
0
    def handle(self, *args, **options):

        HELP_COUNTS_TO_NEW_CARD = 9

        for hero in models.Hero.objects.all().order_by('id').iterator():
            print('process hero {}'.format(hero.id))

            cards = hero.data.get('cards', {})

            help_count = cards.get('help_count', 0)
            premium_help_count = cards.get('premium_help_count', 0)

            non_tradable_cards = (
                help_count - premium_help_count) // HELP_COUNTS_TO_NEW_CARD

            if (help_count - premium_help_count) % HELP_COUNTS_TO_NEW_CARD:
                non_tradable_cards += 1

            tradable_cards = premium_help_count // HELP_COUNTS_TO_NEW_CARD

            if premium_help_count % HELP_COUNTS_TO_NEW_CARD:
                tradable_cards += 1

            energy = hero.energy + hero.energy_bonus

            if hero.premium_state_end_at < datetime.datetime.utcnow():
                non_tradable_cards += energy // (4 * 9)
            else:
                tradable_cards += energy // (4 * 9)

            cards = []

            for i in range(non_tradable_cards):
                cards.append(
                    cards_logic.create_card(allow_premium_cards=False,
                                            available_for_auction=False))

            for i in range(tradable_cards):
                cards.append(
                    cards_logic.create_card(allow_premium_cards=True,
                                            available_for_auction=True))

            cards_tt_api.change_cards(account_id=hero.account_id,
                                      operation_type='migrate-to-tt-bank',
                                      storage=cards_relations.STORAGE.NEW,
                                      to_add=cards)

            print('hero received {} premium cards and {} non-premium'.format(
                tradable_cards, non_tradable_cards))
    def handle(self, *args, **options):

        cards_to_store = []

        for i in range(options['number']):
            for card_type in cards.CARD.records:
                cards_to_store.append(
                    card_type.effect.create_card(
                        available_for_auction=random.choice((True, False)),
                        type=card_type))

        tt_api.change_cards(account_id=options['account'],
                            operation_type='test-import',
                            to_add=cards_to_store,
                            storage=relations.STORAGE(options['storage']))
Пример #8
0
    def setUp(self):
        super(CancelSellLotTests, self).setUp()

        tt_api.debug_clear_service()
        cards_tt_api.debug_clear_service()

        self.card = cards.CARD.LEVEL_UP.effect.create_card(available_for_auction=True, type=cards.CARD.LEVEL_UP)

        self.item_info = objects.ItemTypeSummary(full_type=self.card.item_full_type,
                                                 sell_number=1,
                                                 min_sell_price=100,
                                                 max_sell_price=100)

        cards_tt_api.change_cards(self.account.id, operation_type='#test', to_add=[self.card])

        response = self.post_ajax_json(logic.create_sell_lot_url(), {'card': [self.card.uid], 'price': 100})
        self.check_ajax_ok(response)
Пример #9
0
def cards_for_new_hero(hero):
    from the_tale.game.cards import tt_api
    from the_tale.game.cards import cards

    tt_api.change_cards(
        hero.account_id,
        operation_type='new-hero-gift',
        to_add=[
            cards.CARD.CHANGE_HERO_SPENDINGS.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.CHANGE_HERO_SPENDINGS,
                item=relations.ITEMS_OF_EXPENDITURE.BUYING_ARTIFACT),
            cards.CARD.HEAL_COMPANION_COMMON.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.HEAL_COMPANION_COMMON),
            cards.CARD.ADD_EXPERIENCE_COMMON.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.ADD_EXPERIENCE_COMMON),
            cards.CARD.CHANGE_ABILITIES_CHOICES.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.CHANGE_ABILITIES_CHOICES),
            cards.CARD.CHANGE_PREFERENCE.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.CHANGE_PREFERENCE,
                preference=relations.PREFERENCE_TYPE.ENERGY_REGENERATION_TYPE),
            cards.CARD.CHANGE_PREFERENCE.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.CHANGE_PREFERENCE,
                preference=relations.PREFERENCE_TYPE.ENERGY_REGENERATION_TYPE),
            cards.CARD.CHANGE_PREFERENCE.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.CHANGE_PREFERENCE,
                preference=relations.PREFERENCE_TYPE.PLACE),
            cards.CARD.CHANGE_PREFERENCE.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.CHANGE_PREFERENCE,
                preference=relations.PREFERENCE_TYPE.ARCHETYPE),
            cards.CARD.CHANGE_PREFERENCE.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.CHANGE_PREFERENCE,
                preference=relations.PREFERENCE_TYPE.FRIEND),
            cards.CARD.ADD_BONUS_ENERGY_RARE.effect.create_card(
                available_for_auction=False,
                type=cards.CARD.ADD_BONUS_ENERGY_RARE)
        ])