How to check if data populates in mapping and how to get the value and display for checking?
address[] public players;
address public owner;
struct Bet {
uint256 amountBet;
uint16 matchSelected;
uint16 resultSelected;
// address[] players;
}
struct Player {
uint256 amountBet;
uint16 matchSelected;
uint16 resultSelected;
uint numFunders;
mapping (uint => Bet) Bets;
}
mapping(uint16 => bool) matchBettingActive;
mapping(address => Player) public playerInfo;
function for bet:
function bet(uint16 _matchSelected, uint16 _resultSelected) public payable {
Player storage c = playerInfo[_matchSelected];
require(matchBettingActive[_matchSelected], "Betting: match voting is disabled");
//Check if the player already exist
require(!checkIfPlayerExists(msg.sender, _matchSelected));
//Check if the value sended by the player is higher than the min value
require(msg.value >= minimumBet);
//Set the player informations : amount of the bet, match and result selected
playerInfo[msg.sender].amountBet = msg.value;
playerInfo[msg.sender].matchSelected = _matchSelected;
playerInfo[msg.sender].resultSelected = _resultSelected;
c.Bets[c.numFunders++] = Bet({ amountBet:msg.value,matchSelected: _matchSelected,resultSelected: _resultSelected});
//Add the address of the player to the players array
players.push(msg.sender);
//Finally increment the stakes of the team selected with the player bet
if ( _resultSelected == 1){
totalBetHome[_matchSelected] += msg.value;
}
else if( _resultSelected == 2){
totalBetAway[_matchSelected] += msg.value;
}
else{
totalBetDraw[_matchSelected] += msg.value;
}
}