function GetWin(uint _duelID) external {

        _duel storage duel = Duels[_duelID];

        require(duel.state == State.OnGoing);
        require(duel.creator == msg.sender || duel.responder == msg.sender);
        require(block.number > duel.blocknumber + 1);

        duel.state = State.Closed;
        uint duel_fee = 0;

        uint256 N = 1;
        if (block.timestamp > start) {
            N = (block.timestamp - start) / period + 1;
        }

        if (blockhash(duel.blocknumber) == 0 || (block.number - duel.blocknumber) > 256) {

            duel_fee = safePerc(duel.bet, fee);

            duel.creator.transfer(safeSub(duel.bet, duel_fee));
            duel.responder.transfer(safeSub(duel.bet, duel_fee));

            reward[N] = safeAdd(reward[N], safeMul(2, duel_fee));

            emit refundDuel(_duelID);
            duelWinner[_duelID] = address(0);

        } else {

            uint hash = uint(keccak256(abi.encodePacked(blockhash(duel.blocknumber + 1), duel.creator, duel.responder, duel.bet)));

            uint duel_bet_common = safeMul(2, duel.bet);
            duel_fee = safePerc(duel_bet_common, fee);

            uint _refFee = 0;
            uint sum = safeSub(duel_bet_common, duel_fee);

            address winner;

            if (hash % 2 == 0) {
                duel.creator.transfer(sum);
                winner = duel.creator;
                emit resultDuel(_duelID, duel.creator, sum);


            } else {
                duel.responder.transfer(sum);
                winner = duel.responder;
                emit resultDuel(_duelID, duel.responder, sum);
            }

            duelWinner[_duelID] = winner;
            
            if (RefAddr[winner] != address(0)) {
                _refFee = refUserFee;
                rewardAddr[RefAddr[winner]] = safeAdd(rewardAddr[RefAddr[winner]], safePerc(duel_fee, _refFee));
            }

            
            if (duel.refID != 0) {
                _refFee = safeSub(refGroupFee, _refFee);
                rewardGroup[RefGroup[duel.refID]] = safeAdd(rewardGroup[RefGroup[duel.refID]], safePerc(duel_fee, _refFee));
                reward[N] = safeAdd(reward[N], safeSub(duel_fee, safePerc(duel_fee, refGroupFee)));
            } else {
                reward[N] = safeAdd(reward[N], safeSub(duel_fee, safePerc(duel_fee, _refFee)));
            }
        }
    }