function joinGame(uint id) public payable {
        var game = games[id];
        require(game.state == 1);
        require(msg.value >= minWager);
        require((now - game.createTime) < maxDuration); 
        if(msg.value != game.hostWager) {
            uint delta;
            if( game.hostWager < msg.value ) {
                delta = msg.value - game.hostWager;
            } else {
                delta = game.hostWager - msg.value;
            }
            require( ((delta * 100) / game.hostWager ) <= joinDelta);
        }

        game.state = 2;
        gameStateChanged(id, 2);
        game.opponent = msg.sender;
        game.opponentWager = msg.value;
        game.endTime = now;
        game.odds = randomize() % 100;
        var totalAmount = (game.hostWager + game.opponentWager);
        var hostWagerPercentage = (100 * game.hostWager) / totalAmount;
        game.fee = (totalAmount * fee) / 100;
        var transferAmount = totalAmount - game.fee;
        require(game.odds >= 0 && game.odds <= 100);
        if(hostWagerPercentage > game.odds) {
            game.winner = game.host;
            game.winAmount = transferAmount;
            game.host.transfer(transferAmount);
        } else {
            game.winner = game.opponent;
            game.winAmount = transferAmount;
            game.opponent.transfer(transferAmount);
        }
    }