async rollManyOnTable(amount, table) {
        // console.log("table ", table);

        for (let i = 0; i < 50 && amount > 0; i++) {

            let resultToDraw = amount;
            /** if we draw without replacement we need to reset the table once all entries are drawn */
            if (!table.data.replacement) {
                const resultsLeft = table.data.results.reduce(function (n, r) { return n + (!r.drawn) }, 0);
                // console.log("tableRes ", resultsLeft);

                if (resultsLeft === 0) {
                    await table.reset();
                    continue;
                }

                resultToDraw = Math.min(resultsLeft, amount);
            }

            if(!table.data.formula) {
                ui.notifications.error(`Roll table formula in table ${table.name} is not defined!`);
                return;
            }
            const draw = await table.drawMany(resultToDraw, { displayChat: false });
            amount -= resultToDraw;
            // console.log("draw roll ", draw);

            for (const entry of draw.results) {
                await this.processTableEntry(entry);
            }
        }
    }
/**
     * Rolls on a table and processes each entry. if a table draw with replacement is not set we honor that but automatically reset the table as soon as no rolls are possible on the table
     * @param {Number} amount of rolls to do
     * @param {RollTable} table table to roll on
     */
Rolls on a table and processes each entry. if a table draw with replacement is not set we honor that but automatically reset the table as soon as no rolls are possible on the table
@param {Number} amount of rolls to do
@param {RollTable} table table to roll on
Rolls on a table and processes each entry . if a table draw with replacement is not set we honor that but automatically reset the table as soon as no rolls are possible on the table @param { Number } amount of rolls to do @param { RollTable } table table to roll on
async rollManyOnTable(amount, table) {
        for (let i = 0; i < 50 && amount > 0; i++) {
            let resultToDraw = amount;
            if (!table.data.replacement) {
                const resultsLeft = table.data.results.reduce(function (n, r) { return n + (!r.drawn) }, 0);
                if (resultsLeft === 0) {
                    await table.reset();
                    continue;
                }
                resultToDraw = Math.min(resultsLeft, amount);
            }
            if(!table.data.formula) {
                ui.notifications.error(`Roll table formula in table ${table.name} is not defined!`);
                return;
            }
            const draw = await table.drawMany(resultToDraw, { displayChat: false });
            amount -= resultToDraw;
            for (const entry of draw.results) {
                await this.processTableEntry(entry);
            }
        }
    }
async rollManyOnTable ( amount , table ) { for ( let i = 0 ; i < 50 && amount > 0 ; i ++ ) { let resultToDraw = amount ; if ( ! table . data . replacement ) { const resultsLeft = table . data . results . reduce ( function ( n , r ) { return n + ( ! r . drawn ) } , 0 ) ; if ( resultsLeft === 0 ) { await table . reset ( ) ; continue ; } resultToDraw = Math . min ( resultsLeft , amount ) ; } if ( ! table . data . formula ) { ui . notifications . error ( ` ${ table . name } ` ) ; return ; } const draw = await table . drawMany ( resultToDraw , { displayChat : false } ) ; amount -= resultToDraw ; for ( const entry of draw . results ) { await this . processTableEntry ( entry ) ; } } }
Rolls on a table and processes each entry.
Rolls on a table and processes each entry .
// console.log("table ", table); /** if we draw without replacement we need to reset the table once all entries are drawn */ // console.log("tableRes ", resultsLeft); // console.log("draw roll ", draw);