Ejemplo n.º 1
0
 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
Ejemplo n.º 2
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