def combine(self, combined_cards): if len(combined_cards) != 3: return None if not self.check_types(combined_cards): return None if not self.check_data_equality(combined_cards): return None return self.next_card_type.effect.create_card( available_for_auction=all(card.available_for_auction for card in combined_cards), type=self.next_card_type, habit=game_relations.HABIT_TYPE( combined_cards[0].data['habit_id']), direction=combined_cards[0].data['direction'])
def use(self, task, storage, **kwargs): # pylint: disable=R0911,W0613 card = objects.Card.deserialize(uuid.UUID(task.data['card']['id']), task.data['card']['data']) habit = game_relations.HABIT_TYPE(card.data['habit_id']) delta = card.data['direction'] * self.modificator old_habits = (task.hero.habit_honor.raw_value, task.hero.habit_peacefulness.raw_value) task.hero.change_habits(habit, delta) if old_habits == (task.hero.habit_honor.raw_value, task.hero.habit_peacefulness.raw_value): return task.logic_result( next_step=postponed_tasks.UseCardTask.STEP.ERROR, message='Применение карты никак не изменит черты героя.') return task.logic_result(message='Черта героя изменена.')
def _name_for_card(self, type, habit_id, direction): return '{}: {} {:+d}'.format(type.text, game_relations.HABIT_TYPE(habit_id).text, int(self.modificator * direction))
class GuideResource(Resource): def initialize(self, *args, **kwargs): super(GuideResource, self).initialize(*args, **kwargs) @handler('', method='get') def index(self): return self.redirect(reverse('guide:game')) @handler('registration', method='get') def registration(self): return self.template('guide/registration.html', {'section': 'registration'}) @handler('user-agreement', method='get') def user_agreement(self): return self.template('guide/user-agreement.html', {'section': 'user-agreement'}) @handler('account-types', method='get') def account_types(self): return self.template('guide/account_types.html', {'section': 'account-types'}) @handler('payments', method='get') def payments(self): return self.template('guide/payments.html', {'section': 'payments'}) @handler('behavior-rules', method='get') def behavior_rules(self): return self.template('guide/behavior_rules.html', {'section': 'behavior-rules'}) @handler('game', method='get') def game(self): return self.template('guide/game.html', {'section': 'game'}) @handler('keepers', method='get') def keepers(self): return self.template('guide/keepers.html', {'section': 'keepers'}) @handler('quests', method='get') def quests(self): return self.template('guide/quests.html', {'section': 'quests'}) @handler('persons', method='get') def persons(self): return self.template( 'guide/persons.html', { 'section': 'persons', 'persons_settings': persons_conf.settings, 'INNER_CIRCLE_SIZE': persons_logic.PersonPoliticPower.INNER_CIRCLE_SIZE, 'JOBS_EFFECTS': jobs_effects.EFFECT, 'PERSON_TYPES': sorted(persons_relations.PERSON_TYPE.records, key=lambda r: r.text), 'PERSONALITY_COSMETIC': sorted(persons_relations.PERSONALITY_COSMETIC.records, key=lambda r: r.text), 'PERSONALITY_PRACTICAL': sorted(persons_relations.PERSONALITY_PRACTICAL.records, key=lambda r: r.text) }) @handler('cities', method='get') def cities(self): from the_tale.game.places.modifiers import CITY_MODIFIERS from the_tale.game.places.relations import ATTRIBUTE return self.template( 'guide/cities.html', { 'section': 'cities', 'places_settings': places_conf.settings, 'INNER_CIRCLE_SIZE': places_logic.PlacePoliticPower.INNER_CIRCLE_SIZE, 'ATTRIBUTES': sorted(ATTRIBUTE.records, key=lambda modifier: modifier.text), 'MODIFIERS': sorted(CITY_MODIFIERS.records, key=lambda modifier: modifier.text) }) @handler('politics', method='get') def politics(self): from the_tale.game.bills.conf import bills_settings from the_tale.game.bills.bills import BILLS_BY_ID return self.template( 'guide/politics.html', { 'section': 'politics', 'bills_settings': bills_settings, 'heroes_settings': heroes_settings, 'BILLS_BY_ID': BILLS_BY_ID }) @handler('clans', method='get') def clans(self): return self.template('guide/clans.html', { 'section': 'clans', 'clans_settings': clans_settings }) @handler('map', method='get') def map(self): return self.template('guide/map.html', {'section': 'map'}) @handler('pvp', method='get') def pvp(self): return self.template( 'guide/pvp.html', { 'section': 'pvp', 'pvp_settings': pvp_settings, 'pvp_abilities': pvp_abilities }) @handler('api', method='get') def api(self): return self.template( 'guide/api.html', { 'section': 'api', 'api_forum_thread': guide_settings.API_FORUM_THREAD, 'methods': API_METHODS, 'types': API_TYPES }) @validate_argument('ability_type', lambda x: ABILITY_TYPE(int(x)), 'guide.hero_abilities', 'Неверный формат типа способности') @validate_argument('activation_type', lambda x: ABILITY_ACTIVATION_TYPE(int(x)), 'guide.hero_abilities', 'Неверный формат типа активации') @validate_argument('availability', lambda x: ABILITY_AVAILABILITY(int(x)), 'guide.hero_abilities', 'Неверный формат типа доступности') @handler('hero-abilities', method='get') def hero_abilities(self, ability_type=None, activation_type=None, availability=ABILITY_AVAILABILITY.FOR_ALL): abilities = list(ABILITIES.values()) is_filtering = False if ability_type is not None: is_filtering = True abilities = [ ability for ability in abilities if ability.TYPE == ability_type ] if activation_type is not None: is_filtering = True abilities = [ ability for ability in abilities if ability.ACTIVATION_TYPE == activation_type ] if availability is not ABILITY_AVAILABILITY.FOR_ALL: if availability is not ABILITY_AVAILABILITY.FOR_ALL: is_filtering = True abilities = [ ability for ability in abilities if ability.AVAILABILITY == availability ] abilities = [ ability(level=ability.MAX_LEVEL) for ability in sorted(abilities, key=lambda x: x.NAME) ] url_builder = UrlBuilder( reverse('guide:hero-abilities'), arguments={ 'ability_type': ability_type.value if ability_type is not None else None, 'activation_type': activation_type.value if activation_type is not None else None, 'availability': availability.value }) return self.template( 'guide/hero-abilities.html', { 'section': 'hero-abilities', 'url_builder': url_builder, 'abilities': abilities, 'is_filtering': is_filtering, 'ability_type': ability_type, 'activation_type': activation_type, 'availability': availability, 'ABILITY_ACTIVATION_TYPE': ABILITY_ACTIVATION_TYPE, 'ABILITY_TYPE': ABILITY_TYPE, 'ABILITY_AVAILABILITY': ABILITY_AVAILABILITY }) @handler('hero-preferences', method='get') def hero_preferences(self): return self.template('guide/hero-preferences.html', { 'section': 'hero-preferences', 'PREFERENCE_TYPE': PREFERENCE_TYPE }) @handler('referrals', method='get') def referrals(self): return self.template( 'guide/referrals.html', { 'section': 'referrals', 'account': self.account, 'accounts_settings': accounts_settings, 'referral_link': full_url( 'http', 'portal:', **{ accounts_settings.REFERRAL_URL_ARGUMENT: self.account.id if self.account else None }) }) @handler('zero-player-game', name='zpg', method='get') def zpg(self): return self.template('guide/zpg.html', {'section': 'zpg'}) @handler('hero-habits', method='get') def habits(self): cards = sorted(iter(cards_effects.HABIT_POINTS_CARDS.values()), key=lambda x: (x.TYPE.rarity.value, x.TYPE.text)) return self.template( 'guide/hero-habits.html', { 'section': 'hero-habits', 'HABIT_TYPE': game_relations.HABIT_TYPE, 'HABIT_POINTS_CARDS': cards }) @validate_argument('habit', lambda x: game_relations.HABIT_TYPE(int(x)), 'guide.hero_habit_info', 'Неверный тип черты') @handler('hero-habit-info', method='get') def habit_info(self, habit): return self.template('guide/hero-habit-info.html', { 'habit': habit, 'HABIT_TYPE': game_relations.HABIT_TYPE }) @handler('press-kit', name='press-kit') def press_kit(self): from the_tale.game.mobs.storage import mobs_storage return self.template( 'guide/press_kit.html', { 'section': 'press-kit', 'mob': random.choice(mobs_storage.get_available_mobs_list(level=666)) }) @handler('intro-comix') def intro_comix(self): return self.template('guide/intro_comix.html', {'section': 'intro-comix'}) @handler('game-resources') def game_resources(self): return self.template('guide/game_resources.html', {'section': 'game-resources'})