Skip to content

Commit

Permalink
Updated routes and added OpenMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Aug 18, 2023
1 parent 888e085 commit 76160fd
Show file tree
Hide file tree
Showing 27 changed files with 1,688 additions and 420 deletions.
96 changes: 96 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33513,6 +33513,16 @@ paths:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
playerB:
type: object
properties:
Expand All @@ -33533,6 +33543,16 @@ paths:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
outcome:
type: string
enum:
Expand Down Expand Up @@ -33614,6 +33634,16 @@ paths:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
playerB:
type: object
properties:
Expand All @@ -33634,6 +33664,16 @@ paths:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
outcome:
type: string
enum:
Expand Down Expand Up @@ -68522,6 +68562,16 @@ definitions:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
playerB:
type: object
properties:
Expand All @@ -68542,6 +68592,16 @@ definitions:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
outcome:
type: string
enum:
Expand Down Expand Up @@ -68572,6 +68632,16 @@ definitions:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
DecentralCardGame.cardchain.cardchain.MsgAddArtworkResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgAddArtworkToCollectionResponse:
Expand Down Expand Up @@ -68615,6 +68685,12 @@ definitions:
type: object
DecentralCardGame.cardchain.cardchain.MsgFinalizeCollectionResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgMsgOpenMatchResponse:
type: object
properties:
matchId:
type: string
format: uint64
DecentralCardGame.cardchain.cardchain.MsgMultiVoteCardResponse:
type: object
DecentralCardGame.cardchain.cardchain.MsgOpenBoosterPackResponse:
Expand Down Expand Up @@ -68990,6 +69066,16 @@ definitions:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
playerB:
type: object
properties:
Expand All @@ -69010,6 +69096,16 @@ definitions:
- Draw
- Aborted
default: AWon
deck:
type: array
items:
type: string
format: uint64
votedCards:
type: array
items:
type: string
format: uint64
outcome:
type: string
enum:
Expand Down
2 changes: 2 additions & 0 deletions proto/cardchain/cardchain/match.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ message MatchPlayer {
repeated uint64 playedCards = 2;
bool confirmed = 3;
Outcome outcome = 4;
repeated uint64 deck = 5;
repeated uint64 votedCards = 6;
}
46 changes: 29 additions & 17 deletions proto/cardchain/cardchain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ service Msg {

// this line is used by starport scaffolding # proto/tx/rpc
rpc MultiVoteCard (MsgMultiVoteCard) returns (MsgMultiVoteCardResponse);
rpc MsgOpenMatch (MsgMsgOpenMatch ) returns (MsgMsgOpenMatchResponse );
}
message MsgCreateuser {
string creator = 1;
Expand All @@ -71,11 +72,11 @@ message MsgBuyCardScheme {
cosmos.base.v1beta1.Coin bid = 2 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin"];

/*
string bid = 2;
string bid = 2;
*/}

message MsgBuyCardSchemeResponse {
uint64 cardId = 1;
uint64 cardId = 1;
}

message MsgVoteCard {
Expand All @@ -95,9 +96,9 @@ message MsgSaveCardContent {

// bytes image = 4;
// string fullArt = 5;
string notes = 4;
string artist = 5;
bool balanceAnchor = 6;
string notes = 4;
string artist = 5;
bool balanceAnchor = 6;
}

message MsgSaveCardContentResponse {
Expand Down Expand Up @@ -153,12 +154,11 @@ message MsgRegisterForCouncil {
message MsgRegisterForCouncilResponse {}

message MsgReportMatch {
string creator = 1;
string playerA = 2;
string playerB = 3;
repeated uint64 cardsA = 5;
repeated uint64 cardsB = 6;
Outcome outcome = 7;
string creator = 1;
uint64 matchId = 2;
repeated uint64 playedCardsA = 3;
repeated uint64 playedCardsB = 4;
Outcome outcome = 5;
}

enum Outcome {
Expand Down Expand Up @@ -339,9 +339,10 @@ message MsgRewokeCouncilRegistration {
message MsgRewokeCouncilRegistrationResponse {}

message MsgConfirmMatch {
string creator = 1;
uint64 matchId = 2;
Outcome outcome = 3;
string creator = 1;
uint64 matchId = 2;
Outcome outcome = 3;
repeated uint64 votedCards = 4;
}

message MsgConfirmMatchResponse {}
Expand Down Expand Up @@ -400,17 +401,28 @@ message MsgSetUserBiography {

message MsgSetUserBiographyResponse {}


message SingleVote {
uint64 cardId = 1;
string voteType = 2;
}

// this line is used by starport scaffolding # proto/tx/message
message MsgMultiVoteCard {
string creator = 1;
repeated SingleVote votes = 2;
string creator = 1;
repeated SingleVote votes = 2;
}

message MsgMultiVoteCardResponse {}

message MsgMsgOpenMatch {
string creator = 1;
string playerA = 2;
string playerB = 3;
repeated uint64 playerADeck = 4;
repeated uint64 playerBDeck = 5;
}

message MsgMsgOpenMatchResponse {
uint64 matchId = 1;
}

1 change: 1 addition & 0 deletions x/cardchain/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func GetTxCmd() *cobra.Command {
cmd.AddCommand(CmdSetUserWebsite())
cmd.AddCommand(CmdSetUserBiography())
cmd.AddCommand(CmdMultiVoteCard())
cmd.AddCommand(CmdMsgOpenMatch())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
40 changes: 40 additions & 0 deletions x/cardchain/client/cli/tx_msg_open_match.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cli

import (
"strconv"

"github.com/DecentralCardGame/Cardchain/x/cardchain/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdMsgOpenMatch() *cobra.Command {
cmd := &cobra.Command{
Use: "msg-open-match",
Short: "Broadcast message MsgOpenMatch",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) (err error) {

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgMsgOpenMatch(
clientCtx.GetFromAddress().String(),
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
18 changes: 10 additions & 8 deletions x/cardchain/client/cli/tx_report_match.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ var _ = strconv.Itoa(0)

func CmdReportMatch() *cobra.Command {
cmd := &cobra.Command{
Use: "report-match [player-a] [player-b] [cards-a] [cards-b] [outcome]",
Use: "report-match [match-id] [cards-a] [cards-b] [outcome]",
Short: "Broadcast message ReportMatch",
Args: cobra.ExactArgs(5),
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argPlayerA := args[0]
argPlayerB := args[1]
argMatchId, err := strconv.Atoi(args[0])
if err != nil {
return err
}

var argCardsA []uint64
var argCardsB []uint64

err = json.Unmarshal([]byte(args[2]), &argCardsA)
err = json.Unmarshal([]byte(args[1]), &argCardsA)
if err != nil {
return err
}
err = json.Unmarshal([]byte(args[3]), &argCardsB)
err = json.Unmarshal([]byte(args[2]), &argCardsB)
if err != nil {
return err
}
Expand All @@ -42,8 +45,7 @@ func CmdReportMatch() *cobra.Command {

msg := types.NewMsgReportMatch(
clientCtx.GetFromAddress().String(),
argPlayerA,
argPlayerB,
uint64(argMatchId),
argCardsA,
argCardsB,
argOutcome,
Expand Down
10 changes: 5 additions & 5 deletions x/cardchain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
if genState.CardAuctionPrice.Denom != "" {
k.SetCardAuctionPrice(ctx, genState.CardAuctionPrice)
}
if genState.LastCardModified != nil {
k.SetLastCardModified(ctx, *genState.LastCardModified)
}
if genState.LastCardModified != nil {
k.SetLastCardModified(ctx, *genState.LastCardModified)
}
k.Logger(ctx).Info("reading cards with id:")
for currId, record := range genState.CardRecords {
_, err := keywords.Unmarshal(record.Content)
Expand All @@ -71,7 +71,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
params := k.GetParams(ctx)
// params := types.DefaultParams()
cardAuctionPrice := k.GetCardAuctionPrice(ctx)
lastCardModified := k.GetLastCardModified(ctx)
lastCardModified := k.GetLastCardModified(ctx)
sellOffers := k.SellOffers.GetAll(ctx)
pools := k.Pools.GetAll(ctx)
records := k.Cards.GetAll(ctx)
Expand Down Expand Up @@ -100,6 +100,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
Images: images,
RunningAverages: runningAverages,
Servers: servers,
LastCardModified: &lastCardModified,
LastCardModified: &lastCardModified,
}
}
Loading

0 comments on commit 76160fd

Please sign in to comment.