JSFiddle - React, Tailwind, and code Playground

JavaScript

let html = {
    btn: document.createElement('button'),
    log: document.createElement('div'),
};

function solodungeon() {
    html.btn.innerHTML = 'Delve';
    html.btn.addEventListener('click', delve);

    document.querySelector('body').appendChild(html.btn);
    document.querySelector('body').appendChild(html.log);
}

function delve() { 
    let hp = 12;
    let dmg = 1;
    let room = 0;
    
    while (hp > 0) {
        room++;
        logme('Going into room No. ' + room + '...', html.log);
        switch (roll(6)) {
            case 1:
            case 2:
            case 3:
                logme('... damn an enemy!', html.log);
                hp = fight(hp, dmg);
                dmg = 1;
                break;
            case 4:
                logme('... yay a small potion!', html.log);
                if (hp < 12) {
                    hp += 5;
                }
                if (hp > 12 ) {
                    hp = 12;
                }
                break;
            case 5:
                logme('... yay a large potion!', html.log);
                hp = 12;
                break;
            case 6:
                logme('... yay a power-up!', html.log);
                dmg++;
                break;
        }

        logme('My health is ' + hp + '. The damage is ' + dmg + '.', html.log);
        
    }

    logme('You died. You got into room No. ' + room + '!', html.log);
}

function fight(hp, dmg) {
    let enemy = 5;
    let rnd = 0;

    while (hp > 0 && enemy > 0) {
        rnd++;
        console.warn('Round ' + rnd + ':');
        let result = roll(6) - roll(4);

        console.warn('- result: ' + result);

        if (result > 0) {
            enemy -= (result + dmg);
        }
        else {
            hp += result;
        }
        console.warn('Hero: ' + hp + 'HP / Enemy: ' + enemy + 'HP'); 
    }
    if (hp > 0) {
        console.log('I won!');
    }
    else {
        console.log('I lost!');
    }
    return hp;
}

function...