This is a simple smart contract to play Tic Tac Toe on the blockchain.
-
Create a Game: Call the
createGamefunction with the address of the person you want to play with as a parameter. This will create a new game. -
Accept Invitation: The invited player should accept the invitation by calling the
acceptInvitationfunction with thegameIdof the game that was created. -
Start Playing: Once the invitation is accepted, the game begins. Check who the first player is and start making moves.
-
Make a Move: To make a move, call the
makeMovefunction with thegameIdand the square position where you want to place your mark. -
Game Completion: The game ends when one player wins or when there's a draw. At this point:
- The game status changes to
Completed. - If there's a winner, their address will be saved in the
winnerfield. - In case of a draw, the game status will change to
Completed, but thewinnerfield will be set to the zero address.
- The game status changes to
- Install dependencies:
yarn - Deploy the contract:
yarn deploy
- Install dependencies:
yarn - Run the tests:
yarn test