I have a map of game IDs to game structs in my Solidity contract. I want to test if a game struct for a given ID does not exist or has been deleted. I am using the code below:
// The map that maps a game ID to a specific game.
mapping(uint256 => structGame) public s_mapGameIdToGame;
/// Make sure the game ID has been explicitly set and does not belong to a deleted game.
/// @param _gameId - a valid game ID.
modifier onlyIfValidGameId(uint256 _gameId) {
// Make sure the game ID has been explicitly set.
require(_gameId != id_invalid, "The game ID is invalid.");
// Make sure the game has not been deleted.
require(s_mapGameIdToGame[_gameId] != 0, "The ID given belongs to a deleted game.");
_;
}
Unfortunately Solidity is giving me the following error for the existence check on the game struct:
./contracts/GameFactory.sol:178:17: TypeError: Operator == not
compatible with types struct EtherBandBattlesManager.structGame
storage ref and int_const 0
require(s_mapGameIdToGame[_gameId] == 0, "The ID given belongs to
a deleted game.");
^-----------------------------^
How can I make my existence check/test work?