top of page

LEVEL 2

Congratulations ! You have reached the next level.

Here are the next 3 steps in our contract:

​

Step1. Create a crecord named "game" which will store all the game related details like - "gameId"(int), "player1Id"(address), "player2Id"(address), game_moves"(map - int,int), "gameCompleted"(bool) and "gameWinner"(address).

​

Step2. Create a record player containg "playerId"(address), "playerName"(string), "numGamesWon"(int)

​

Step 3. Create an init() function to initialise the state structure. You can use an address called the - "Contract.creator" to intialise the playerId.

Key takeaways:

1. The square->move mapping is created in the form of "game_moves" to keep track of the moves made by the player.

2. The superhero wallet address will be the id of the player using which the losing player can transfer money to the winning player.

3. Each game can have only two players - so the players addresses are also mapped to the game using player1Id and player2Id.

Try Code
Show Solution
bottom of page