Skip to content

Commit

Permalink
Merge branch 'development' of github.com:DecentralCardGame/Cardchain …
Browse files Browse the repository at this point in the history
…into development
  • Loading branch information
lxgr-linux committed Feb 28, 2024
2 parents af876e0 + 3858f28 commit 07ea2fc
Show file tree
Hide file tree
Showing 10 changed files with 945 additions and 573 deletions.
3 changes: 2 additions & 1 deletion .fleet/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"backend.maxHeapSizeMb": 2744
"backend.maxHeapSizeMb": 2744,
"editor.formatOnSave": true
}
105 changes: 70 additions & 35 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33208,7 +33208,7 @@ paths:
additionalProperties: {}
tags:
- Query
/DecentralCardGame/Cardchain/cardchain/q_cards/{status}:
/DecentralCardGame/Cardchain/cardchain/q_cards:
get:
summary: Queries a list of QCards items.
operationId: DecentralCardGameCardchainCardchainQCards
Expand Down Expand Up @@ -33242,34 +33242,51 @@ paths:
type: string
additionalProperties: {}
parameters:
- name: status
in: path
required: true
type: string
enum:
- scheme
- prototype
- trial
- permanent
- suspended
- banned
- bannedSoon
- bannedVerySoon
- none
- playable
- unplayable
- name: owner
in: query
required: false
type: string
- name: cardType
- name: statuses
in: query
required: false
type: string
type: array
items:
type: string
enum:
- scheme
- prototype
- trial
- permanent
- suspended
- banned
- bannedSoon
- bannedVerySoon
- none
collectionFormat: multi
- name: cardTypes
in: query
required: false
type: array
items:
type: string
enum:
- place
- action
- entity
- headquarter
collectionFormat: multi
- name: classes
in: query
required: false
type: string
type: array
items:
type: string
enum:
- nature
- culture
- mysticism
- technology
collectionFormat: multi
- name: sortBy
in: query
required: false
Expand All @@ -33294,6 +33311,23 @@ paths:
in: query
required: false
type: boolean
- name: rarities
in: query
required: false
type: array
items:
type: string
enum:
- common
- uncommon
- rare
- exceptional
- unique
collectionFormat: multi
- name: multiClassOnly
in: query
required: false
type: boolean
tags:
- Query
/DecentralCardGame/Cardchain/cardchain/q_council/{councilId}:
Expand Down Expand Up @@ -68732,6 +68766,14 @@ definitions:
- active
- archived
default: design
DecentralCardGame.cardchain.cardchain.CardClass:
type: string
enum:
- nature
- culture
- mysticism
- technology
default: nature
DecentralCardGame.cardchain.cardchain.CardRarity:
type: string
enum:
Expand All @@ -68741,6 +68783,14 @@ definitions:
- exceptional
- unique
default: common
DecentralCardGame.cardchain.cardchain.CardType:
type: string
enum:
- place
- action
- entity
- headquarter
default: place
DecentralCardGame.cardchain.cardchain.CouncelingStatus:
type: string
enum:
Expand Down Expand Up @@ -69407,21 +69457,6 @@ definitions:
lastCardModified:
type: string
format: uint64
DecentralCardGame.cardchain.cardchain.QueryQCardsRequest.Status:
type: string
enum:
- scheme
- prototype
- trial
- permanent
- suspended
- banned
- bannedSoon
- bannedVerySoon
- none
- playable
- unplayable
default: scheme
DecentralCardGame.cardchain.cardchain.QueryQCardsResponse:
type: object
properties:
Expand Down
14 changes: 14 additions & 0 deletions proto/cardchain/cardchain/card.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ enum CardRarity {
unique = 4;
}

enum CardClass {
nature = 0;
culture = 1;
mysticism = 2;
technology = 3;
}

enum CardType {
place = 0;
action = 1;
entity = 2;
headquarter = 3;
}

message TimeStamp {
uint64 timeStamp = 1;
}
23 changes: 6 additions & 17 deletions proto/cardchain/cardchain/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ service Query {

// Queries a list of QCards items.
rpc QCards (QueryQCardsRequest) returns (QueryQCardsResponse) {
option (google.api.http).get = "/DecentralCardGame/Cardchain/cardchain/q_cards/{status}";
option (google.api.http).get = "/DecentralCardGame/Cardchain/cardchain/q_cards";

}

Expand Down Expand Up @@ -173,29 +173,18 @@ message QueryQVotingResultsResponse {
}

message QueryQCardsRequest {
enum Status {
scheme = 0;
prototype = 1;
trial = 2;
permanent = 3;
suspended = 4;
banned = 5;
bannedSoon = 6;
bannedVerySoon = 7;
none = 8;
playable = 9;
unplayable = 10;
}
string owner = 1;
Status status = 2;
string cardType = 3;
string classes = 4;
repeated Status statuses = 2;
repeated CardType cardTypes = 3;
repeated CardClass classes = 4;
string sortBy = 5;
string nameContains = 6;
string keywordsContains = 7;
string notesContains = 8;
bool onlyStarterCard = 9;
bool onlyBalanceAnchors = 10;
repeated CardRarity rarities = 11;
bool multiClassOnly = 12;
}

message QueryQCardsResponse {
Expand Down
93 changes: 75 additions & 18 deletions x/cardchain/client/cli/query_q_cards.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,83 @@ var _ = strconv.Itoa(0)

func CmdQCards() *cobra.Command {
cmd := &cobra.Command{
Use: "q-cards [owner] [status] [card-type] [classes] [sort-by] [name-contains] [keywords-contains] [notes-contains] [startercards-only] [balance-achors-only]",
Use: "q-cards [owner] [statuses] [card-types] [classes] [rarities] [sort-by] [name-contains] [keywords-contains] [notes-contains] [startercards-only] [balance-achors-only]",
Short: "Query qCards",
Args: cobra.ExactArgs(10),
Args: cobra.ExactArgs(11),
RunE: func(cmd *cobra.Command, args []string) (err error) {
reqOwner := args[0]
var reqOnlyStarterCards bool
var reqOnlyBalanceAnchors bool
var reqStatus types.QueryQCardsRequest_Status
if args[1] == "" {
reqStatus = types.QueryQCardsRequest_none
} else {
reqStatus = types.QueryQCardsRequest_Status(types.QueryQCardsRequest_Status_value[args[1]])
var statuses []string
var reqStatuses []types.Status

err = getJsonArg(args[1], &statuses)
if err != nil {
return err
}

for _, status := range statuses {
s, ok := types.Status_value[status]
if !ok {
return fmt.Errorf("invalid status %s", status)
}
reqStatuses = append(reqStatuses, types.Status(s))
}

var cardTypes []string
var reqCardTypes []types.CardType

err = getJsonArg(args[2], &cardTypes)
if err != nil {
return err
}

for _, cardType := range cardTypes {
s, ok := types.CardType_value[cardType]
if !ok {
return fmt.Errorf("invalid class %s", cardType)
}
reqCardTypes = append(reqCardTypes, types.CardType(s))
}

var classes []string
var reqClasses []types.CardClass

err = getJsonArg(args[3], &classes)
if err != nil {
return err
}

for _, class := range classes {
s, ok := types.CardClass_value[class]
if !ok {
return fmt.Errorf("invalid class %s", class)
}
reqClasses = append(reqClasses, types.CardClass(s))
}
reqCardType := args[2]
reqClasses := args[3]
reqSortBy := args[4]
reqNameContains := args[5]
reqKeywordsContains := args[6]
reqNotesContains := args[7]

switch args[8] {

var rarities []string
var reqRarities []types.CardRarity

err = getJsonArg(args[4], &rarities)
if err != nil {
return err
}

for _, rarity := range rarities {
s, ok := types.CardRarity_value[rarity]
if !ok {
return fmt.Errorf("invalid rarity %s", rarity)
}
reqRarities = append(reqRarities, types.CardRarity(s))
}

reqSortBy := args[5]
reqNameContains := args[6]
reqKeywordsContains := args[7]
reqNotesContains := args[8]

switch args[9] {
case "yes":
reqOnlyStarterCards = true
case "no":
Expand All @@ -43,7 +99,7 @@ func CmdQCards() *cobra.Command {
return fmt.Errorf("arg 'only-startercard' has to be either yes or no but not %s", args[8])
}

switch args[9] {
switch args[10] {
case "yes":
reqOnlyBalanceAnchors = true
case "no":
Expand All @@ -62,9 +118,10 @@ func CmdQCards() *cobra.Command {
params := &types.QueryQCardsRequest{

Owner: reqOwner,
Status: reqStatus,
CardType: reqCardType,
Statuses: reqStatuses,
CardTypes: reqCardTypes,
Classes: reqClasses,
Rarities: reqRarities,
SortBy: reqSortBy,
NameContains: reqNameContains,
KeywordsContains: reqKeywordsContains,
Expand Down
7 changes: 7 additions & 0 deletions x/cardchain/client/cli/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cli

import "encoding/json"

func getJsonArg[T any](from string, into *T) error {
return json.Unmarshal([]byte(from), into)
}
Loading

0 comments on commit 07ea2fc

Please sign in to comment.