<commit_before>var baseNumberOfSurvivors;
var actualNumberOfSurvivors;
var zombieDecksToUse;
var zombieDeck = [];
var spawnZonesToUseForBalance = [];

function setGame(baseNumberOfSurvivorsToUse, actualNumberOfSurvivorsToUse, useBlackPlagueDeck){
    baseNumberOfSurvivors = baseNumberOfSurvivorsToUse;
    actualNumberOfSurvivors = actualNumberOfSurvivorsToUse;
    zombieDecksToUse = 0;
    if(useBlackPlagueDeck){
        zombieDecksToUse = zombieDecksToUse | ZombieDeckEnum.blackPlague;
    }
}

function spawnZombies(numberOfSpawnZones){
    let spawnZones = [];
    let spawnZoneIndex = 0;
    let remainingSpawns = numberOfSpawnZones;
    let extraSpawns = 0;
    let nextExtraSpawns = 0;
    for(let i = 0; i < numberOfSpawnZones; i++){
        if(checkSpawnZoneForBalance()){
            spawnZones[i] = [];
        }else{
            spawnZones[i] = null;
            remainingSpawns--;
        }
    }
    while(remainingSpawns > 0){
        if(spawnZones[spawnZoneIndex] != null){
            remainingSpawns--;
            let card = drawZombieCard();
            spawnZones[spawnZoneIndex].push(card);
            switch(card.spawnType){
                case SpawnTypeEnum.doubleSpawn:
                    remainingSpawns++;
                    nextExtraSpawns++;
                    break;
                case SpawnTypeEnum.necromancerSpawn:
                    remainingSpawns++;
                    extraSpawns++;
                    break;
            }
            if(extraSpawns > 0){
                //stay in the same spawn zone
                extraSpawns--;
            }else{
                //move to next spawn zone
                spawnZoneIndex = getNextSpawnZoneIndex(spawnZoneIndex, numberOfSpawnZones);
                if(nextExtraSpawns > 0){
                    //mark an extra spawn next zone (to spawn twice) if there are still remaining spawns beyond the extra spawn itself
                    //in case the last zone was already reached, only one spawn (the extra spawn) will take place in first zone again
                    if(remainingSpawns > 1){
                        extraSpawns = nextExtraSpawns;
                    }
                    nextExtraSpawns = 0;
                }
            }
        }else{
            spawnZoneIndex = getNextSpawnZoneIndex(spawnZoneIndex, numberOfSpawnZones);
        }
    }<commit_msg>Handle error on spawn with no deck selected<commit_after>var baseNumberOfSurvivors;
var actualNumberOfSurvivors;
var zombieDecksToUse;
var zombieDeck = [];
var spawnZonesToUseForBalance = [];

function setGame(baseNumberOfSurvivorsToUse, actualNumberOfSurvivorsToUse, useBlackPlagueDeck){
    baseNumberOfSurvivors = baseNumberOfSurvivorsToUse;
    actualNumberOfSurvivors = actualNumberOfSurvivorsToUse;
    zombieDecksToUse = 0;
    if(useBlackPlagueDeck){
        zombieDecksToUse = zombieDecksToUse | ZombieDeckEnum.blackPlague;
    }
}

function spawnZombies(numberOfSpawnZones){
    let spawnZones = [];
    let spawnZoneIndex = 0;
    let remainingSpawns = numberOfSpawnZones;
    let extraSpawns = 0;
    let nextExtraSpawns = 0;
    for(let i = 0; i < numberOfSpawnZones; i++){
        if(checkSpawnZoneForBalance()){
            spawnZones[i] = [];
        }else{
            spawnZones[i] = null;
            remainingSpawns--;
        }
    }
    while(remainingSpawns > 0){
        if(spawnZones[spawnZoneIndex] != null){
            remainingSpawns--;
            let card = drawZombieCard();
            if(card != null){
                spawnZones[spawnZoneIndex].push(card);
                switch(card.spawnType){
                    case SpawnTypeEnum.doubleSpawn:
                        remainingSpawns++;
                        nextExtraSpawns++;
                        break;
                    case SpawnTypeEnum.necromancerSpawn:
                        remainingSpawns++;
                        extraSpawns++;
                        break;
                }
                if(extraSpawns > 0){
                    //stay in the same spawn zone
                    extraSpawns--;
                }else{
                    //move to next spawn zone
                    spawnZoneIndex = getNextSpawnZoneIndex(spawnZoneIndex, numberOfSpawnZones);
                    if(nextExtraSpawns > 0){
                        //mark an extra spawn next zone (to spawn twice) if there are still remaining spawns beyond the extra spawn itself
                        //in case the last zone was already reached, only one spawn (the extra spawn) will take place in first zone again
                        if(remainingSpawns > 1){
                            extraSpawns = nextExtraSpawns;
                        }
                        nextExtraSpawns = 0;
                    }
                }
            }else{
                break;
            }
        }else{
            spawnZoneIndex = getNextSpawnZoneIndex(spawnZoneIndex, numberOfSpawnZones);
        }
    }
{'fraction_non_alphanumeric': 0.073559048770657, 'fraction_numerical': 0.004030632809351068, 'mean_word_length': 1.709061135371179, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4347181', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1423, 'n_words': 297}