def make_own_value_frame_for_user(cls,
                                   user: User,
                                   card_details: CardDetails = None):
     """Makes the cards for a user, cached for immediate reuse."""
     if card_details is None:
         card_details = global_data.all_cards
     own_value = OwnValueFrame.from_user(user, card_details)
     return own_value
 def run(self) -> OwnValueFrame:
     """Call for the card displays to be displayed at the given page."""
     start_index = self._get_start_card_index()
     displays_on_page = OwnValueFrame(
         self.value_info.user,
         self.value_info[start_index:start_index + self.cards_per_page],
     )
     return displays_on_page
Exemple #3
0
 def sort(cards):
     """Sorts cards from highest to lowest card value."""
     cards.index.names = [name + "_index" for name in cards.index.names]
     sorted_df = cards.sort_values(
         by=[
             OwnValueFrame.PLAY_VALUE_NAME, OwnValueFrame.COUNT_IN_DECK_NAME
         ],
         ascending=[False, True],
     )
     return OwnValueFrame(cards.user, sorted_df)
Exemple #4
0
 def sort(cards):
     """Sorts the cards by highest to lowest card value
      per shiftstone crafting cost."""
     cards.index.names = [name + "_index" for name in cards.index.names]
     sorted_df = cards.sort_values(
         by=[
             OwnValueFrame.PLAY_CRAFT_EFFICIENCY_NAME,
             OwnValueFrame.COUNT_IN_DECK_NAME,
         ],
         ascending=[False, True],
     )
     return OwnValueFrame(cards.user, sorted_df)
    def _group_page(
            page: OwnValueFrame) -> OwnValueFrame:  # todo make less disgusting
        """Groups the card value displays in the list as a single item.

        Grouped displays are given new minimum and maximum attributes
        representing the cards minimum and maximum counts in the list."""

        min_max_page = CardDisplayPage._get_min_max_of_page(page)
        min_max_dropped_duplicates = min_max_page.drop_duplicates()
        min_max_dropped_index_duplicates = min_max_dropped_duplicates[
            ~min_max_dropped_duplicates.index.duplicated(keep="first")]

        reindexed = page.set_index(CardDisplayPage.INDEX_KEYS)
        deduplicated_index = reindexed[~reindexed.index.duplicated(
            keep="first")].index
        original_order = min_max_dropped_index_duplicates.reindex(
            index=deduplicated_index)

        reset_original_order = original_order.reset_index()
        no_duplicates = reset_original_order.drop_duplicates(
            subset=CardDisplayPage.INDEX_KEYS)

        return no_duplicates
Exemple #6
0
 def filter(self, cards):
     """Filters out uncraftable."""
     filtered_df = cards[np.logical_not(
         card_set.CardSet.is_campaign_from_num(cards.set_num))]
     return OwnValueFrame(cards.user, filtered_df)
Exemple #7
0
 def filter(self, cards):
     filtered_df = cards.query("is_owned == True")
     return OwnValueFrame(cards.user, filtered_df)
Exemple #8
0
 def filter(self, cards):
     filtered_df = cards[cards["is_in_expedition"] == True]
     return OwnValueFrame(cards.user, filtered_df)
Exemple #9
0
 def filter(self, cards):
     filtered_df = cards[cards["rarity"] != self.rarity]
     return OwnValueFrame(cards.user, filtered_df)