function rollSelectedDice(die) {
    // set last Roll ID
    currentRollId = "roll_" + Date.now();
    let thisRollId = currentRollId;
    //play sound
    playRollSound();
    //reset total
    total = 0;
    $("#total-value").text("?").animateRotate(720, 1000, "swing");
    //reset all dice to their natural max value
    resetDieValues();
    // roll this and all active dice
    let toRoll = die ? (die.hasClass("active") ? $("#table .active").add(die) : die) : $("#table .active");
    toRoll.each(function(){
        let currentDie = $(this);
        currentDie.find(".rotatable > .die-value").first().text("?");
        currentDie.children(".rotatable").first().animateRotate(
            720,
            1000,
            "swing",
            function() {
                if (thisRollId !== currentRollId) return;
                let result = Math.floor(Math.random() * parseInt(currentDie.attr("data-type"))) + 1;
                total += parseInt(result);
                currentDie.find(".rotatable > .die-value").first().text(result);
                $("#total-value").text(total);
            }
        );
    });
}
// fnc to call when rolling all selected dice
fnc to call when rolling all selected dice
fnc to call when rolling all selected dice
function rollSelectedDice(die) {
    currentRollId = "roll_" + Date.now();
    let thisRollId = currentRollId;
    playRollSound();
    total = 0;
    $("#total-value").text("?").animateRotate(720, 1000, "swing");
    resetDieValues();
    let toRoll = die ? (die.hasClass("active") ? $("#table .active").add(die) : die) : $("#table .active");
    toRoll.each(function(){
        let currentDie = $(this);
        currentDie.find(".rotatable > .die-value").first().text("?");
        currentDie.children(".rotatable").first().animateRotate(
            720,
            1000,
            "swing",
            function() {
                if (thisRollId !== currentRollId) return;
                let result = Math.floor(Math.random() * parseInt(currentDie.attr("data-type"))) + 1;
                total += parseInt(result);
                currentDie.find(".rotatable > .die-value").first().text(result);
                $("#total-value").text(total);
            }
        );
    });
}
function rollSelectedDice ( die ) { currentRollId = "roll_" + Date . now ( ) ; let thisRollId = currentRollId ; playRollSound ( ) ; total = 0 ; $ ( "#total-value" ) . text ( "?" ) . animateRotate ( 720 , 1000 , "swing" ) ; resetDieValues ( ) ; let toRoll = die ? ( die . hasClass ( "active" ) ? $ ( "#table .active" ) . add ( die ) : die ) : $ ( "#table .active" ) ; toRoll . each ( function ( ) { let currentDie = $ ( this ) ; currentDie . find ( ".rotatable > .die-value" ) . first ( ) . text ( "?" ) ; currentDie . children ( ".rotatable" ) . first ( ) . animateRotate ( 720 , 1000 , "swing" , function ( ) { if ( thisRollId !== currentRollId ) return ; let result = Math . floor ( Math . random ( ) * parseInt ( currentDie . attr ( "data-type" ) ) ) + 1 ; total += parseInt ( result ) ; currentDie . find ( ".rotatable > .die-value" ) . first ( ) . text ( result ) ; $ ( "#total-value" ) . text ( total ) ; } ) ; } ) ; }
fnc to call when rolling all selected dice
fnc to call when rolling all selected dice
// set last Roll ID //play sound //reset total //reset all dice to their natural max value // roll this and all active dice