Skip to content

Commit

Permalink
#135 Added startercard query option
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Sep 28, 2023
1 parent 9be7893 commit 2594a4e
Show file tree
Hide file tree
Showing 6 changed files with 316 additions and 169 deletions.
8 changes: 8 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33136,6 +33136,8 @@ paths:
type: boolean
hash:
type: string
starterCard:
type: boolean
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -33330,6 +33332,10 @@ paths:
in: query
required: false
type: string
- name: onlyStarterCard
in: query
required: false
type: boolean
tags:
- Query
/DecentralCardGame/cardchain/cardchain/q_collection/{collectionId}:
Expand Down Expand Up @@ -68858,6 +68864,8 @@ definitions:
type: boolean
hash:
type: string
starterCard:
type: boolean
DecentralCardGame.cardchain.cardchain.OutpCollection:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions proto/cardchain/cardchain/card.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ message Card {
uint64 inappropriateVotes = 12;
int64 nerflevel = 13;
bool balanceAnchor = 15;
bool starterCard = 16;
}

message OutpCard {
Expand All @@ -42,6 +43,7 @@ message OutpCard {
int64 nerflevel = 13;
bool balanceAnchor = 15;
string hash = 16;
bool starterCard = 17;
}

enum Status {
Expand Down
1 change: 1 addition & 0 deletions proto/cardchain/cardchain/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ message QueryQCardsRequest {
string nameContains = 6;
string keywordsContains = 7;
string notesContains = 8;
bool onlyStarterCard = 9;
}

message QueryQCardsResponse {
Expand Down
6 changes: 6 additions & 0 deletions x/cardchain/keeper/grpc_query_q_cards.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ func (k Keeper) QCards(goCtx context.Context, req *types.QueryQCardsRequest) (*t
for ; iterator.Valid(); iterator.Next() {
idx, gottenCard := iterator.Value()

// filter for starterCards
if req.OnlyStarterCard && !gottenCard.StarterCard {
continue
}

// first skip all cards with irrelevant status
if gottenCard.Status == types.Status_none || gottenCard.Status == types.Status_scheme {
continue
}

// then check if a status constrain was given and skip the card if it has the wrong status
if req.Status != types.QueryQCardsRequest_none {
if !slices.Contains(states, gottenCard.Status) {
Expand Down
165 changes: 126 additions & 39 deletions x/cardchain/types/card.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2594a4e

Please sign in to comment.