def edit_rules() -> wrappers.Response: cnum = rs.num_classified_decks() tnum = ds.num_decks(rs.classified_decks_query()) archetypes = archs.load_archetypes_deckless(order_by='a.name') view = EditRules(cnum, tnum, rs.doubled_decks(), rs.mistagged_decks(), rs.overlooked_decks(), rs.load_all_rules(), archetypes, rs.excluded_archetype_info()) return view.response()
def edit_archetypes(search_results: Optional[List[Deck]] = None, q: str = '', notq: str = '') -> str: if search_results is None: search_results = [] view = EditArchetypes(archs.load_archetypes_deckless(order_by='a.name'), search_results, q, notq) return view.page()
def archetypes(deck_type: Optional[str] = None) -> str: tournament_only = validate_deck_type( deck_type, [DeckType.ALL, DeckType.TOURNAMENT]) == DeckType.TOURNAMENT season_id = get_season_id() deckless_archetypes = archs.load_archetypes_deckless( season_id=season_id, tournament_only=tournament_only) all_matchups = archs.load_matchups(season_id=season_id, tournament_only=tournament_only) view = Archetypes(deckless_archetypes, all_matchups, tournament_only=tournament_only) return view.page()
def __init__(self, d: deck.Deck, person_id: Optional[int] = None, discord_id: Optional[int] = None) -> None: super().__init__() self.deck = d self.prepare_deck(self.deck) self.cards = d.all_cards() if not self.deck.is_in_current_run(): deck.load_similar_decks([d]) # This is called 'decks' and not something more sane because of limitations of Mustache and our desire to use a partial for decktable. self.decks = [ sd for sd in d.similar_decks if not sd.is_in_current_run() ] else: self.decks = [] self.has_similar = len(self.decks) > 0 self.matches = match.get_matches(d, True) for m in self.matches: m.display_date = dtutil.display_date(m.date) if m.opponent: m.opponent_url = url_for('person', person_id=m.opponent) else: m.opponent = 'BYE' m.opponent_url = False if m.opponent_deck_id: m.opponent_deck_url = url_for('deck', deck_id=m.opponent_deck_id) else: m.opponent_deck_url = False if m.opponent_deck and m.opponent_deck.is_in_current_run(): m.opponent_deck_name = '(Active League Run)' elif m.opponent_deck: m.opponent_deck_name = m.opponent_deck.name else: m.opponent_deck_name = '-' if self.has_rounds(): m.display_round = display_round(m) self.deck['maindeck'].sort(key=lambda x: oracle.deck_sort(x['card'])) self.deck['sideboard'].sort(key=lambda x: oracle.deck_sort(x['card'])) self.archetypes = archetype.load_archetypes_deckless(order_by='a.name') self.edit_archetype_url = url_for('edit_archetypes') self.legal_formats = list( sorted(d.legal_formats, key=legality.order_score)) self.is_in_current_run = d.is_in_current_run() self.person_id = person_id self.discord_id = discord_id
def __init__(self, archetype: archs.Archetype, archetypes: List[archs.Archetype], matchups: List[Container], season_id: int, tournament_only: bool = False ) -> None: super().__init__() if not archetype: raise DoesNotExistException('No archetype supplied to view.') self.archetype = next(a for a in archetypes if a.id == archetype.id) if archetypes else archetype self.archetype.decks = archetype.decks self.archetype.decks_tournament = archetype.decks_tournament # Load the deck information from archetype into skinny archetype loaded by load_archetypes_deckless_for with tree information. self.archetypes = archetypes self.decks = self.archetype.decks self.decks_tournament = self.archetype.decks_tournament self.roots = [a for a in self.archetypes if a.is_root] self.tournament_only = tournament_only matchup_archetypes = archs.load_archetypes_deckless(season_id=season_id) matchups_by_id = {m.id: m for m in matchups} for m in matchup_archetypes: # Overwite totals with vs-archetype specific details. Wipe out if there are none. m.update(matchups_by_id.get(m.id, {'hide_archetype': True})) for m in matchup_archetypes: self.prepare_archetype(m, matchup_archetypes) # Storing this in matchups_container like this lets us include two different archetype trees on the same page without collision. self.matchups_container = [{ 'is_matchups': True, 'roots': [m for m in matchup_archetypes if m.is_root], }] self.show_seasons = True self.show_tournament_toggle = True if tournament_only: self.toggle_results_url = url_for('.archetype', archetype_id=self.archetype.id) else: self.toggle_results_url = url_for('.archetype_tournament', archetype_id=self.archetype.id) self.show_archetype = any(d.archetype_id != self.archetype.id for d in self.decks) self.show_archetype_tree = len(self.archetypes) > 0
def __init__(self, archetype, archetypes, matchups): self.archetype = next(a for a in archetypes if a.id == archetype.id) self.archetype.decks = archetype.decks # Load the deck information from archetype into skinny archetype loaded by load_archetypes_deckless_for with tree information. self.archetypes = archetypes self.decks = self.archetype.decks self.roots = [a for a in self.archetypes if a.is_root] matchup_archetypes = archs.load_archetypes_deckless() matchups_by_id = {m.id: m for m in matchups} for m in matchup_archetypes: # Overwite totals with vs-archetype specific details. Wipe out if there are none. m.update(matchups_by_id.get(m.id, {'hide_archetype': True})) for m in matchup_archetypes: self.prepare_archetype(m, matchup_archetypes) # Storing this in matchups_container like this lets us include two different archetype trees on the same page without collision. self.matchups_container = [{ 'hide_num_decks': True, 'roots': [m for m in matchup_archetypes if m.is_root], }]
def matchups() -> str: hero, enemy = {}, {} for k, v in request.args.items(): if k.startswith('hero_'): k = k.replace('hero_', '') hero[k] = v else: k = k.replace('enemy_', '') enemy[k] = v season_id = request.args.get('season_id') results = mus.matchup(hero, enemy, season_id=season_id) if request.args else {} matchup_archetypes = archs.load_archetypes_deckless() matchup_archetypes.sort(key=lambda a: a.name) matchup_people = list(ps.load_people(where='p.mtgo_username IS NOT NULL')) matchup_people.sort(key=lambda p: p.name) matchup_cards = cs.load_cards() matchup_cards.sort(key=lambda c: c.name) view = Matchups(hero, enemy, season_id, matchup_archetypes, matchup_people, matchup_cards, results) return view.page()
def __init__(self, archetype: archs.Archetype, archetypes: List[archs.Archetype], matchups: List[Container], season_id: int, tournament_only: bool = False) -> None: super().__init__() if not archetype: raise DoesNotExistException('No archetype supplied to view.') self.archetype = next( a for a in archetypes if a.id == archetype.id) if archetypes else archetype self.archetype.decks = archetype.decks # Load the deck information from archetype into skinny archetype loaded by load_archetypes_deckless_for with tree information. self.archetypes = archetypes self.tournament_only = self.hide_source = tournament_only matchup_archetypes = archs.load_archetypes_deckless( season_id=season_id) matchups_by_id = {m.id: m for m in matchups} for m in matchup_archetypes: # Overwite totals with vs-archetype specific details. Wipe out if there are none. m.update(matchups_by_id.get(m.id, {'hide_archetype': True})) # Prepare the second archetype tree manually becuase its archetypes don't have the standard name. for m in matchup_archetypes: self.prepare_archetype(m, matchup_archetypes) # Storing this in matchups_container like this lets us include two different archetype trees on the same page without collision. self.matchups_container = [{ 'is_matchups': True, 'archetypes': matchup_archetypes, }] self.show_seasons = True self.show_tournament_toggle = True self.toggle_results_url = url_for( '.archetype', archetype_id=self.archetype.id, deck_type=None if tournament_only else DeckType.TOURNAMENT.value) self.show_archetype = any(d.archetype_id != self.archetype.id for d in self.decks) self.show_archetype_tree = len(self.archetypes) > 0
def __init__(self, d: deck.Deck, person_id: Optional[int] = None, discord_id: Optional[int] = None) -> None: super().__init__() self.deck = d prepare.prepare_deck(self.deck) self.cards = d.all_cards() self.matches = match.load_matches_by_deck(d, should_load_decks=True) for m in self.matches: m.display_date = dtutil.display_date(m.date) if m.opponent: m.opponent_url = url_for('.person', mtgo_username=m.opponent) else: m.opponent = 'BYE' m.opponent_url = False if m.opponent_deck_id: m.opponent_deck_url = url_for('deck', deck_id=m.opponent_deck_id) else: m.opponent_deck_url = False if m.opponent_deck and m.opponent_deck.is_in_current_run(): m.opponent_deck_name = '(Active League Run)' elif m.opponent_deck: m.opponent_deck_name = m.opponent_deck.name else: m.opponent_deck_name = '-' if self.has_rounds(): m.display_round = display_round(m) self.deck['maindeck'].sort(key=lambda x: oracle.deck_sort(x.card)) self.deck['sideboard'].sort(key=lambda x: oracle.deck_sort(x.card)) self.archetypes = archetype.load_archetypes_deckless(order_by='a.name') self.edit_archetype_url = url_for('edit_archetypes') self.legal_formats = d.legal_formats self.is_in_current_run = d.is_in_current_run() self.person_id = person_id self.discord_id = discord_id self.is_deck_page = True
def archetypes_tournament() -> str: season_id = get_season_id() deckless_archetypes = archs.load_archetypes_deckless(season_id=season_id) all_matchups = archs.load_all_matchups(season_id=season_id) view = Archetypes(deckless_archetypes, all_matchups, tournament_only=True) return view.page()
def archetypes() -> str: season_id = get_season_id() deckless_archetypes = archs.load_archetypes_deckless(season_id=season_id) all_matchups = archs.load_all_matchups(season_id=season_id) view = Archetypes(deckless_archetypes, all_matchups) return view.page()
def archetypes(): view = Archetypes(archs.load_archetypes_deckless(season_id=get_season_id())) return view.page()
def edit_archetypes(search_results=None): if search_results is None: search_results = [] view = EditArchetypes(archs.load_archetypes_deckless(order_by='a.name'), search_results) return view.page()
def archetypes(): view = Archetypes(archs.load_archetypes_deckless()) return view.page()