function joinMiniGame() public disableContract
    {        
        require(now >= minigames[ miniGameId ].startTime && minigames[ miniGameId ].ended == false);
        
        PlayerData storage p = players[msg.sender];
        if (now <= minigames[ miniGameId ].endTime) {
            
            if (p.currentMiniGameId == miniGameId) {
                p.totalJoin = p.totalJoin + 1;
            } else {
                
                updateShareCrystal();
                p.currentMiniGameId = miniGameId;
                p.totalJoin = 1;
                p.miningWarRoundNumber = minigames[ miniGameId ].miningWarRoundNumber;
            }
            
            if ( p.totalJoin <= 1 ) { 
                minigames[ miniGameId ].totalPlayer = minigames[ miniGameId ].totalPlayer + 1;
            }
            minigames[ miniGameId ].playerWin = msg.sender;
            minigames[ miniGameId ].endTime = minigames[ miniGameId ].endTime + MINI_GAME_ADD_TIME_DEFAULT;
            emit eventJoinMiniGame(p.totalJoin);
        } else {
            
            if (minigames[ miniGameId ].playerWin == 0x0) {
                updateShareCrystal();
                p.currentMiniGameId = miniGameId;
                p.lastMiniGameId = miniGameId;
                p.totalJoin = 1;
                p.miningWarRoundNumber = minigames[ miniGameId ].miningWarRoundNumber;

                minigames[ miniGameId ].playerWin = msg.sender;
            }
            endMiniGame();
        }
    }