I was trying to create a contract that has multiple rooms, in each room there would be some amount of players. Pls how do I acheive this? This is my approach but it's not working. I am unable to return the mapped array also.
contract TheGame {
uint256 totalRoom;
struct Room {
address player;
uint256 amount;
}
Room[] public room;
mapping(uint256 => Room[]) public eachRoomNumberToEachRoom;
function createRoom(uint256 _amount) public {
room.push(Room({
player: msg.sender,
amount: _amount
}));
totalRoom += 1;
eachRoomNumberToEachRoom[totalRoom] = room;
}
function getEachRoom(uint256 _index) public view returns () {
return eachRoomNumberToEachRoom[totalRoom][_index];
}
}