Skip to content

Commit

Permalink
HOT FIX card rarity filter (can only be accessed by query string manu…
Browse files Browse the repository at this point in the history
…al manipulation)
  • Loading branch information
patrickwieth committed Jan 26, 2024
1 parent a7e426c commit e6fe6cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/components/elements/GalleryComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ const props = withDefaults(
defineProps<{
allCardIds: Array<number>;
cardsPerPage: number;
rarityFilter: string;
cardCallback: (card: Card) => void
}>(),
{
allCardIds: () => [],
cardsPerPage: 100,
rarityFilter: "none",
cardCallback: () => {}
}
);
Expand Down Expand Up @@ -94,7 +96,6 @@ const cardIdsOnPage = computed(() => {
state.pageId * props.cardsPerPage,
(state.pageId + 1) * props.cardsPerPage
);
console.log(r);
return r;
});
Expand Down Expand Up @@ -152,7 +153,11 @@ const loadCard = async (cardId: number) => {
let card: Card = await getCard(cardId);
props.cardCallback(card)
if (card.Content) {
state.cards.push(card);
// TODO remove this "if" once proper rarity search from blockchain side works
if (card.rarity == props.rarityFilter || props.rarityFilter == "none") {
state.cards.push(card);
}
} else if (!card.owner) {
console.error("card without content and owner: ", card);
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/model/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class ChainCard {
votePool: Coin = new Coin();
voters: Array<string> = [];
balanceAnchor: boolean = false;
rarity: string ="";
hash: string = "";

static from(json: any) {
Expand Down Expand Up @@ -47,6 +48,7 @@ export class ChainCard {

card.type = cardType;
card.owner = this.owner;
card.rarity = this.rarity;
card.status = this.status;
card.artist = this.artist;
card.Content = content;
Expand Down
7 changes: 5 additions & 2 deletions src/views/GalleryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<GalleryComponent
:cards-per-page="galleryFilters.cardsPerPage"
:all-card-ids="state.cardList"
:rarity-filter="state.rarity"
/>
</div>
</template>
Expand Down Expand Up @@ -192,6 +193,7 @@ type PageQuery = {
cardType: string;
classes: string;
sortBy: string;
rarity: string;
nameContains: string;
keywordsContains: string;
notesContains: string;
Expand All @@ -217,10 +219,10 @@ onMounted(() => {
}
});
const loadCardList = () => loadQueryCardList(getDefaultQuery())
const normalizeQuery = (query: PageQuery): PageQuery => {
state.rarity = query.rarity
return {
status: query.status ? query.status.toLowerCase() : "playable", // default playable
owner: query.owner ? query.owner : "",
Expand All @@ -229,6 +231,7 @@ const normalizeQuery = (query: PageQuery): PageQuery => {
sortBy: query.sortBy
? query.sortBy.replace(/\s+/g, "").replace(/\(.*?\)/g, "")
: "",
rarity: query.rarity,
nameContains: query.nameContains ? query.nameContains : "",
keywordsContains: query.keywordsContains ? query.keywordsContains : "",
notesContains: query.notesContains
Expand All @@ -244,7 +247,7 @@ const normalizeQuery = (query: PageQuery): PageQuery => {
? ""
: loggedIn.value
? ""
: "Finished", // non-logged in users (noobs), without any filters, will only see the alpha set
: "Finished", // non-logged in users (noobs), without any filters, will only see the alpha set, this is a HACK to cheat in notesContains
};
};
Expand Down

0 comments on commit e6fe6cc

Please sign in to comment.