function roll(uint16[] territories,uint16 team) 
    payable
    public
    {
        RequireHuman();
        require(isactive);
        
        require(team!=0);
        
        uint256 _rID = roundID;
        uint256 _now = block.timestamp;
        uint256 _roundstart = Rounds[_rID].roundstart;
        uint256 _trucetime = Rounds[_rID].trucetime;


        if (Rounds[_rID].teamXaddr[msg.sender]==0){ 
            Rounds[_rID].teamXaddr[msg.sender]=team;
        }
        else{
            require(Rounds[_rID].teamXaddr[msg.sender]==team); 
        }


        
        
        
        require(msg.value==Rounds[_rID].price ); 
        
        uint16 _maxroll = Rounds[_rID].maxroll;
        seed = uint256(keccak256(abi.encodePacked((seed^block.timestamp)))); 
        uint256 rolled = (seed % _maxroll)+1; 
        uint256 validrolls=0; 
        uint16[] memory territoriesconquered = new uint16[](_maxroll);
        
        if  (_roundstart+_trucetime<_now){
            for (uint i = 0 ; i<territories.length;i++){
                if (getownership(territories[i])==team){ 
                    continue;
                }
                if (hasteamadjacency(territories[i],team)){
                    territoriesconquered[validrolls]=territories[i];
                    setownership(territories[i],team); 
                    validrolls+=1;
                    if (validrolls==rolled){
                        break;
                    }
                }
            }
        }
        else{
            require(Rounds[_rID].validrollsXteam[team]<Rounds[_rID].maxextensiontruce); 
            for  (i = 0 ; i<territories.length;i++){
                if (getownership(territories[i])!=0){ 
                    continue;
                }
                if (hasteamadjacency(territories[i],team)){
                    territoriesconquered[validrolls]=territories[i];
                    setownership(territories[i],team); 
                    validrolls+=1;
                    if (validrolls==rolled){
                        break;
                    }
                }
            }
        }

        Rounds[_rID].validrollsXaddr[msg.sender]+=validrolls;
        Rounds[_rID].validrollsXteam[team]+=validrolls;
        
        uint256 refund;
        if (validrolls<rolled){
            refund = ((rolled-validrolls)*msg.value)/rolled;
        }
        Rounds[_rID].pot+=msg.value-refund;
        if (refund>0){
            msg.sender.transfer(refund);
        }
        
        
        
        emit onroll(
            nameXaddress[msg.sender],
            Rounds[_rID].nationnameXteam[team],
            rolled,
            team,
            territoriesconquered,
            msg.sender
            );
    }