# The Play Game Elements
Make sure you have all you need before proceeding:
To play a game a player only needs to specify:
- The ID of the game the player wants to join. Call the field
- The initial positions of the pawn. Call the fields
fromYand make them
- The final position of the pawn after a player's move. Call the fields
The player does not need to be explicitly added as a field in the message because the player is implicitly the signer of the message. Name the object
Unlike when creating the game, you want to return:
- The game ID again. Call this field
- The captured piece, if any. Call the fields
- The winner in the field
# With Starport
Now Starport only creates a response object with a single field. You can update the object after Starport has run:
Starport once more creates all the necessary Protobuf files and the boilerplate for you. All you have left to do is:
Add the missing fields to the response in
int64here so that you can enter
-1when no pawns have been captured.
Fill in the needed part in
TODOis replaced as per below.
# The move handling
rules represent the ready-made file containing the rules of the game you imported earlier. Declare them in
x/checkers/types/errors.go given your code has to handle new error situations:
Take the following steps to replace the
Fetch the stored game information:
Keeper.GetStoredGame(opens new window) function created by Starport.
Is the player legitimate? Check with:
Using the certainty that the
MsgPlayMove.Creatorhas been verified by its signature (opens new window).
Instantiate the board to implement the rules:
Good thing you previously created this helper (opens new window).
Is it the player's turn? Check with:
Using the rules file's own
TurnIs(opens new window) function.
Properly conduct the move:
Again using the rules proper
Move(opens new window) function.
Prepare the updated board to be stored and store the information:
Updating the fields that were modified using the
Keeper.SetStoredGame(opens new window) function just as when you created and saved the game.
Return relevant information regarding the move's result:
Winnerinformation would be lost if you do not. More accurately, one would have to replay the transaction to find out the values. Better be a good citizen and make this information easily accessible.
That is all there is to it: good preparation and the use of Starport.
# Next up
If you want to skip ahead and see how you can assist a player in not submitting a transaction that would result in a failed move, you can create a query to test a move.