<commit_before>function drawAdventure(character) {
    var adventurer = character.adventurer;
    var context = mainContext;
    var cameraX = character.cameraX;
    context.clearRect(0, 0, mainCanvas.width, mainCanvas.height);
    var background = ifdefor(character.area.background, backgrounds.field);
    var cloudX = cameraX + character.time * .5;
    var fullDrawingWidth = Math.ceil(mainCanvas.width / 64) * 64 + 64;
    background.forEach(function(section) {
        var source = section.source;
        var y = ifdefor(section.y, 0);
        var height = ifdefor(section.height, 240 - y);
        var width = ifdefor(section.width, 64);
        var parallax = ifdefor(section.parallax, 1);
        var spacing = ifdefor(section.spacing, 1);
        var velocity = ifdefor(section.velocity, 0);
        var alpha = ifdefor(section.alpha, 1);
        context.globalAlpha = alpha;
        for (var i = 0; i <= fullDrawingWidth; i += 64 * spacing) {
            var x = (fullDrawingWidth + (i - (cameraX - character.time * velocity) * parallax) % fullDrawingWidth) % fullDrawingWidth - 64;
            context.drawImage(source.image, source.x, source.y, source.width, source.height,
                                  x, y, width, height);
        }
        context.globalAlpha = 1;
    });
    character.objects.forEach(function (object, index) {
        object.draw(context, object.x - cameraX, 240 - 128);
    });
    character.enemies.forEach(function (actor, index) {
        drawActor(character, actor, 1 + character.enemies.length - index)
    });
    drawActor(character, adventurer, 0);
    character.allies.forEach(function (actor, index) {
        if (actor == adventurer) return;
        drawActor(character, actor, -index)
    });
    // Draw text popups such as damage dealt, item points gained, and so on.
    context.fillStyle = 'red';
    for (var i = 0; i < character.treasurePopups.length; i++) {
        character.treasurePopups[i].draw(character);
    }
    for (var i = 0; i < character.projectiles.length; i++) {
        character.projectiles[i].draw(character);
    }
    for (var i = 0; i < character.effects.length; i++) {
        character.effects[i].draw(character);
    }
    for (var i = 0; i < character.textPopups.length; i++) {
        var textPopup = character.textPopups[i];
        context.fillStyle = ifdefor(textPopup.color, "red");
        context.font = ifdefor(textPopup.font, "20px sans-serif");
        context.textAlign = 'center'
        context.fillText(textPopup.value, textPopup.x - cameraX, textPopup.y);
    }
    drawMinimap(character);
}
function drawActor(character, actor, index) {
    mainContext.save();
    if (actor.isDead) {
        actor.animationTime = actor.timeOfDeath;
        mainContext.globalAlpha = 1 - (actor.time - actor.timeOfDeath);
    }
    if (actor.personCanvas) drawAdventurer(character, actor, index);
    else if (actor.image) drawMonster(character, actor, index);
    else {
        console.log("Unable to draw actor was neither monster nor adventurer?");
        console.log(actor);
    }
    mainContext.restore();
}
function drawMonster(character, monster, index) {
    var cameraX = character.cameraX;
    var context = mainContext;
    var fps = ifdefor(monster.base.fpsMultiplier, 1) * 3 * monster.speed / 100;
    var source = monster.base.source;
    var frame = Math.floor(monster.animationTime * fps) % source.frames;
    if (monster.pull) {
        frame = 0;
    }
    context.save();
    if (monster.cloaked) {
        context.globalAlpha = .2;
    }
    monster.left = monster.x - cameraX;
    monster.top = 240 - ifdefor(source.height, 64) * 2 - 72 - ifdefor(source.y, 0) * 2 - 2 * index;
    monster.width = source.width * 2;
    monster.height = ifdefor(source.height, 64) * 2;
    context.translate(monster.left + monster.width / 2, 0);
    if ((source.flipped && monster.direction < 0) || (!source.flipped && monster.direction > 0)) {
        context.scale(-1, 1);
    }
    context.drawImage(monster.image, frame * source.width + source.offset, 0 , source.width, ifdefor(source.height, 64),
                      -monster.width / 2, monster.top, monster.width, monster.height);
    context.restore();
    // Uncomment to draw a reference of the character to show where left side of monster should be
    // context.drawImage(character.personCanvas, 0 * 32, 0 , 32, 64, monster.x - cameraX, 240 - 128 - 72, 64, 128);
    //context.fillRect(monster.x - cameraX, 240 - 128 - 72, 64, 128);
    // life bar
    if (monster.isDead) return;
    drawBar(context, monster.x - cameraX + source.width - 32, 240 - 128 - 36 - 2 * index - ifdefor(source.y, 0) * 2, 64, 4, 'white', monster.color, monster.health / monster.maxHealth);<commit_msg>Add more useful error message, now that I figured out what happened.<commit_after>function drawAdventure(character) {
    var adventurer = character.adventurer;
    var context = mainContext;
    var cameraX = character.cameraX;
    context.clearRect(0, 0, mainCanvas.width, mainCanvas.height);
    var background = ifdefor(character.area.background, backgrounds.field);
    var cloudX = cameraX + character.time * .5;
    var fullDrawingWidth = Math.ceil(mainCanvas.width / 64) * 64 + 64;
    background.forEach(function(section) {
        var source = section.source;
        var y = ifdefor(section.y, 0);
        var height = ifdefor(section.height, 240 - y);
        var width = ifdefor(section.width, 64);
        var parallax = ifdefor(section.parallax, 1);
        var spacing = ifdefor(section.spacing, 1);
        var velocity = ifdefor(section.velocity, 0);
        var alpha = ifdefor(section.alpha, 1);
        context.globalAlpha = alpha;
        for (var i = 0; i <= fullDrawingWidth; i += 64 * spacing) {
            var x = (fullDrawingWidth + (i - (cameraX - character.time * velocity) * parallax) % fullDrawingWidth) % fullDrawingWidth - 64;
            context.drawImage(source.image, source.x, source.y, source.width, source.height,
                                  x, y, width, height);
        }
        context.globalAlpha = 1;
    });
    character.objects.forEach(function (object, index) {
        object.draw(context, object.x - cameraX, 240 - 128);
    });
    character.enemies.forEach(function (actor, index) {
        drawActor(character, actor, 1 + character.enemies.length - index)
    });
    drawActor(character, adventurer, 0);
    character.allies.forEach(function (actor, index) {
        if (actor == adventurer) return;
        drawActor(character, actor, -index)
    });
    // Draw text popups such as damage dealt, item points gained, and so on.
    context.fillStyle = 'red';
    for (var i = 0; i < character.treasurePopups.length; i++) {
        character.treasurePopups[i].draw(character);
    }
    for (var i = 0; i < character.projectiles.length; i++) {
        character.projectiles[i].draw(character);
    }
    for (var i = 0; i < character.effects.length; i++) {
        character.effects[i].draw(character);
    }
    for (var i = 0; i < character.textPopups.length; i++) {
        var textPopup = character.textPopups[i];
        context.fillStyle = ifdefor(textPopup.color, "red");
        context.font = ifdefor(textPopup.font, "20px sans-serif");
        context.textAlign = 'center'
        context.fillText(textPopup.value, textPopup.x - cameraX, textPopup.y);
    }
    drawMinimap(character);
}
function drawActor(character, actor, index) {
    mainContext.save();
    if (actor.isDead) {
        actor.animationTime = actor.timeOfDeath;
        mainContext.globalAlpha = 1 - (actor.time - actor.timeOfDeath);
    }
    if (actor.personCanvas) drawAdventurer(character, actor, index);
    else drawMonster(character, actor, index);
    mainContext.restore();
}
function drawMonster(character, monster, index) {
    if (!monster.image) {
        console.log("Found monster without an image. Last time this happened was because the -enchanged/-imbued version of the image was not being created at load time.");
        console.log(monster);
        return;
    }
    var cameraX = character.cameraX;
    var context = mainContext;
    var fps = ifdefor(monster.base.fpsMultiplier, 1) * 3 * monster.speed / 100;
    var source = monster.base.source;
    var frame = Math.floor(monster.animationTime * fps) % source.frames;
    if (monster.pull) {
        frame = 0;
    }
    context.save();
    if (monster.cloaked) {
        context.globalAlpha = .2;
    }
    monster.left = monster.x - cameraX;
    monster.top = 240 - ifdefor(source.height, 64) * 2 - 72 - ifdefor(source.y, 0) * 2 - 2 * index;
    monster.width = source.width * 2;
    monster.height = ifdefor(source.height, 64) * 2;
    context.translate(monster.left + monster.width / 2, 0);
    if ((source.flipped && monster.direction < 0) || (!source.flipped && monster.direction > 0)) {
        context.scale(-1, 1);
    }
    context.drawImage(monster.image, frame * source.width + source.offset, 0 , source.width, ifdefor(source.height, 64),
                      -monster.width / 2, monster.top, monster.width, monster.height);
    context.restore();
    // Uncomment to draw a reference of the character to show where left side of monster should be
    // context.drawImage(character.personCanvas, 0 * 32, 0 , 32, 64, monster.x - cameraX, 240 - 128 - 72, 64, 128);
    //context.fillRect(monster.x - cameraX, 240 - 128 - 72, 64, 128);
    // life bar
    if (monster.isDead) return;
    drawBar(context, monster.x - cameraX + source.width - 32, 240 - 128 - 36 - 2 * index - ifdefor(source.y, 0) * 2, 64, 4, 'white', monster.color, monster.health / monster.maxHealth);
{'fraction_non_alphanumeric': 0.13086830078936434, 'fraction_numerical': 0.02534275031159119, 'mean_word_length': 2.7539961013645224, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5063818', 'n_tokens_mistral': 3206, 'n_tokens_neox': 2966, 'n_words': 759}