Categorygithub.com/lukevenediger/checkers
modulepackage
0.1.0
Repository: https://github.com/lukevenediger/checkers.git
Documentation: pkg.go.dev

# README

A Checkers Game Implementation for Cosmos SDK

  • Module provides a way to play checkers on a Cosmos SDK app chain
  • Demonstrates how to read, validate, and write data to the chain
  • Demonstrates how to create test suites for queries and transactions

About a Checkers Game

  • A checkers game contains all the state for a game, including:

    • the game's start time
    • the game status
    • the checkers board with current pieces and positions
    • the addresses of the players
  • a checkers game can be forfeited

    • only games that are in the Ready or Playing state may be forfeited
    • only the player who's turn it is may forfeit the game
  • a game is completed, either through forfeit, win, or expiry

    • the end time is recorded upon completion

Commands available

Transactions:

  • CheckersCreateGm
    • create a new Checkers game
    • takes in a game ID - this must be unique
    • takes in addresses of two players - they must not be the same
    • CLI: $chain_bin tx checkers-torram create $GAME_ID $PLAYER_1 $PLAYER_2
  • ForfeitGame
    • forfeit an active game
    • this transaction must be signed by the player wishing to forfeit
    • the signer must be the player who's turn it is in the game
    • CLI: $chain_bin tx checkers-torram forfeit $GAME_ID

Queries:

  • GetGame
    • retrieves a game by its game ID
    • an empty result is returned if no game is found
    • CLI: $chain_bin query checkers-torram get-game $GAME_ID

Contributions

  • We'd love to get your contributions
  • Please check out CONTRIBUTING.md for more information

TODO List

Storage improvements

  • use a more optimal data type for storage keys (not strings)

Quality improvements

  • Create a test suite for stored-game.go
  • Create a test suite for genesis.go
    • especially to confirm the duplicate game check

CI Improvements

  • Protect the main branch and disallow direct commits
    • everything must be submitted via a PR

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
NewGenesisState creates a new instance of GenesisState with default values.
No description provided by the author
NewStoredGame creates a new stored game with a fresh board.
No description provided by the author
RegisterInterfaces registers the module's interface types with the app's interfacae registry.
RegisterQueryHandler registers the http handlers for service Query to "mux".
RegisterQueryHandlerClient registers the http handlers for service Query to "mux".
RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
No description provided by the author

# Constants

The game is complete - no more moves can be made.
The game has expired - no further moves will be accepted.
The game has been forfeited by one of the players.
The game state is not set.
The game is in progress.
The game board is set up and ready to play.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Initial state definition for the checkers module.
A stored game identified by an index.
Config and settings for the checkers module.
QueryGetGameRequest defines the request type for the Query/GetGame RPC method.
QueryGetGameResponse contains the Game state.
ReqCheckersTorram defines the CheckersTorram/CreateGm request type.
ReqForfeitGm defines the CheckersTorram/ForfeitGm request type.
ResCheckersTorram defines the CheckersTorram/CreateGm response type.
ResForfeitGm defines the CheckersTorram/ForfeitGm response type.
StoredGame is the state of play for a single game.
UnimplementedCheckersTorramServer can be embedded to have forward compatible implementations.
UnimplementedQueryServer can be embedded to have forward compatible implementations.

# Interfaces

CheckersTorramClient is the client API for CheckersTorram service.
CheckersTorramServer is the server API for CheckersTorram service.
QueryClient is the client API for Query service.
QueryServer is the server API for Query service.

# Type aliases

All possible checkers game states.