Skip to content

Commit

Permalink
Add player info object.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierlepretre committed Feb 12, 2024
1 parent f10151b commit 298459c
Show file tree
Hide file tree
Showing 26 changed files with 3,235 additions and 118 deletions.
254 changes: 254 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,185 @@ paths:
additionalProperties: {}
tags:
- Query
/b9lab/checkers/checkers/player_info:
get:
summary: Queries a list of PlayerInfo items.
operationId: B9LabCheckersCheckersPlayerInfoAll
responses:
'200':
description: A successful response.
schema:
type: object
properties:
playerInfo:
type: array
items:
type: object
properties:
index:
type: string
wonCount:
type: string
format: uint64
lostCount:
type: string
format: uint64
forfeitedCount:
type: string
format: uint64
pagination:
type: object
properties:
next_key:
type: string
format: byte
title: |-
next_key is the key to be passed to PageRequest.key to
query the next page most efficiently
total:
type: string
format: uint64
title: >-
total is total number of results available if
PageRequest.count_total

was set, its value is undefined otherwise
description: >-
PageResponse is to be embedded in gRPC response messages where
the

corresponding request message has used PageRequest.

message SomeResponse {
repeated Bar results = 1;
PageResponse page = 2;
}
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
parameters:
- name: pagination.key
description: |-
key is a value returned in PageResponse.next_key to begin
querying the next page most efficiently. Only one of offset or key
should be set.
in: query
required: false
type: string
format: byte
- name: pagination.offset
description: >-
offset is a numeric offset that can be used when key is unavailable.

It is less efficient than using key. Only one of offset or key
should

be set.
in: query
required: false
type: string
format: uint64
- name: pagination.limit
description: >-
limit is the total number of results to be returned in the result
page.

If left empty it will default to a value to be set by each app.
in: query
required: false
type: string
format: uint64
- name: pagination.count_total
description: >-
count_total is set to true to indicate that the result set should
include

a count of the total number of items available for pagination in
UIs.

count_total is only respected when offset is used. It is ignored
when key

is set.
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/b9lab/checkers/checkers/player_info/{index}':
get:
summary: Queries a PlayerInfo by index.
operationId: B9LabCheckersCheckersPlayerInfo
responses:
'200':
description: A successful response.
schema:
type: object
properties:
playerInfo:
type: object
properties:
index:
type: string
wonCount:
type: string
format: uint64
lostCount:
type: string
format: uint64
forfeitedCount:
type: string
format: uint64
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
parameters:
- name: index
in: path
required: true
type: string
tags:
- Query
/b9lab/checkers/checkers/stored_game:
get:
summary: Queries a list of StoredGame items.
Expand Down Expand Up @@ -29824,6 +30003,64 @@ definitions:
b9lab.checkers.checkers.Params:
type: object
description: Params defines the parameters for the module.
b9lab.checkers.checkers.PlayerInfo:
type: object
properties:
index:
type: string
wonCount:
type: string
format: uint64
lostCount:
type: string
format: uint64
forfeitedCount:
type: string
format: uint64
b9lab.checkers.checkers.QueryAllPlayerInfoResponse:
type: object
properties:
playerInfo:
type: array
items:
type: object
properties:
index:
type: string
wonCount:
type: string
format: uint64
lostCount:
type: string
format: uint64
forfeitedCount:
type: string
format: uint64
pagination:
type: object
properties:
next_key:
type: string
format: byte
title: |-
next_key is the key to be passed to PageRequest.key to
query the next page most efficiently
total:
type: string
format: uint64
title: >-
total is total number of results available if
PageRequest.count_total

was set, its value is undefined otherwise
description: |-
PageResponse is to be embedded in gRPC response messages where the
corresponding request message has used PageRequest.

message SomeResponse {
repeated Bar results = 1;
PageResponse page = 2;
}
b9lab.checkers.checkers.QueryAllStoredGameResponse:
type: object
properties:
Expand Down Expand Up @@ -29890,6 +30127,23 @@ definitions:
type: boolean
reason:
type: string
b9lab.checkers.checkers.QueryGetPlayerInfoResponse:
type: object
properties:
playerInfo:
type: object
properties:
index:
type: string
wonCount:
type: string
format: uint64
lostCount:
type: string
format: uint64
forfeitedCount:
type: string
format: uint64
b9lab.checkers.checkers.QueryGetStoredGameResponse:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions proto/checkers/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
import "checkers/params.proto";
import "checkers/system_info.proto";
import "checkers/stored_game.proto";
import "checkers/player_info.proto";
// this line is used by starport scaffolding # genesis/proto/import

option go_package = "github.com/b9lab/checkers/x/checkers/types";
Expand All @@ -14,5 +15,6 @@ message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
SystemInfo systemInfo = 2 [(gogoproto.nullable) = false];
repeated StoredGame storedGameList = 3 [(gogoproto.nullable) = false];
repeated PlayerInfo playerInfoList = 4 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}
12 changes: 12 additions & 0 deletions proto/checkers/player_info.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package b9lab.checkers.checkers;

option go_package = "github.com/b9lab/checkers/x/checkers/types";

message PlayerInfo {
string index = 1;
uint64 wonCount = 2;
uint64 lostCount = 3;
uint64 forfeitedCount = 4;
}

29 changes: 29 additions & 0 deletions proto/checkers/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "checkers/params.proto";
import "checkers/system_info.proto";
import "checkers/stored_game.proto";
import "checkers/player_info.proto";
// this line is used by starport scaffolding # 1

option go_package = "github.com/b9lab/checkers/x/checkers/types";
Expand Down Expand Up @@ -36,6 +37,16 @@ service Query {
option (google.api.http).get = "/b9lab/checkers/checkers/can_play_move/{gameIndex}/{player}/{fromX}/{fromY}/{toX}/{toY}";
}

// Queries a PlayerInfo by index.
rpc PlayerInfo(QueryGetPlayerInfoRequest) returns (QueryGetPlayerInfoResponse) {
option (google.api.http).get = "/b9lab/checkers/checkers/player_info/{index}";
}

// Queries a list of PlayerInfo items.
rpc PlayerInfoAll(QueryAllPlayerInfoRequest) returns (QueryAllPlayerInfoResponse) {
option (google.api.http).get = "/b9lab/checkers/checkers/player_info";
}

// this line is used by starport scaffolding # 2
}

Expand Down Expand Up @@ -85,4 +96,22 @@ message QueryCanPlayMoveResponse {
string reason = 2;
}

message QueryGetPlayerInfoRequest {
string index = 1;

}

message QueryGetPlayerInfoResponse {
PlayerInfo playerInfo = 1 [(gogoproto.nullable) = false];
}

message QueryAllPlayerInfoRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllPlayerInfoResponse {
repeated PlayerInfo playerInfo = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// this line is used by starport scaffolding # 3
Loading

0 comments on commit 298459c

Please sign in to comment.