This is a simple smart contract to play Tic Tac Toe on the blockchain.
-
Create a Game: Call the
createGame
function 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
acceptInvitation
function with thegameId
of 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
makeMove
function with thegameId
and 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
winner
field. - In case of a draw, the game status will change to
Completed
, but thewinner
field 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