<commit_before><?

// -- START BATTLE ACTION -- //

// Define the battle's turn counter and start at 0
$this_battle->counters['battle_turn'] = 0;
$this_battle->update_session();

// Check if there are any field hazards to place beneath this robot
if (!empty($this_battle->battle_field_base['values']['hazards'])){

    // Loop through field hazards and create any battle attachments
    $player_sides = array('left', 'right');
    $player_bench_sizes = array('left' => $this_player->counters['robots_total'], 'right' => $target_player->counters['robots_total']);
    $max_bench_size = max($this_player->counters['robots_total'], $target_player->counters['robots_total']);
    foreach ($this_battle->battle_field_base['values']['hazards'] AS $hazard_token => $hazard_value){
        if (empty($hazard_value)){ continue; }
        $method_name = 'get_static_'.$hazard_token;
        if (!method_exists('rpg_ability', $method_name)){ $method_name = preg_replace('/ies$/i', 'y', $method_name); }
        if (!method_exists('rpg_ability', $method_name)){ $method_name = preg_replace('/s$/i', '', $method_name); }
        if (!method_exists('rpg_ability', $method_name)){ continue; }
        foreach ($player_sides AS $player_side){
            if ($hazard_value != 'both' // not [both]
                && $hazard_value != $player_side // not [left/right]
                && $hazard_value != $player_side.'-active' && $hazard_value != $player_side.'-bench' // not [left/right]-[active/bench]
                ){ continue; } // doesn't match any criteria, so skip this player side
            $bench_size = $player_bench_sizes[$player_side];
            $hazards_added = 0;
            $hazards_to_add = $bench_size == 1 ? 1 : $bench_size;
            for ($key = -1; $key < $max_bench_size; $key++){
                if ($key == 0){ continue; }
                elseif ($key == -1 && $hazard_value == ($player_side.'-bench')){ continue; } // skip if active but bench-only
                elseif ($key != -1 && $hazard_value == ($player_side.'-active')){ continue; } // skip of bench but active-only
                if ($hazards_added >= $hazards_to_add){ break; }
                if ($key == -1){  $static_key = $player_side.'-active';  }
                else { $static_key = $player_side.'-bench-'.$key; }
                $existing = !empty($this_battle->battle_attachments[$static_key]) ? count($this_battle->battle_attachments[$static_key]) : 0;
                $hazard_info = call_user_func('rpg_ability::'.$method_name, $static_key, 99, $existing);
                $this_battle->battle_attachments[$static_key][$hazard_info['attachment_token']] = $hazard_info;<commit_msg>Fixed bug w/ amount of benched hazards sometimes<commit_after><?

// -- START BATTLE ACTION -- //

// Define the battle's turn counter and start at 0
$this_battle->counters['battle_turn'] = 0;
$this_battle->update_session();

// Check if there are any field hazards to place beneath this robot
if (!empty($this_battle->battle_field_base['values']['hazards'])){

    // Loop through field hazards and create any battle attachments
    $player_sides = array('left', 'right');
    $player_bench_sizes = array('left' => $this_player->counters['robots_total'], 'right' => $target_player->counters['robots_total']);
    $max_bench_size = max($this_player->counters['robots_total'], $target_player->counters['robots_total']);
    foreach ($this_battle->battle_field_base['values']['hazards'] AS $hazard_token => $hazard_value){
        if (empty($hazard_value)){ continue; }
        $method_name = 'get_static_'.$hazard_token;
        if (!method_exists('rpg_ability', $method_name)){ $method_name = preg_replace('/ies$/i', 'y', $method_name); }
        if (!method_exists('rpg_ability', $method_name)){ $method_name = preg_replace('/s$/i', '', $method_name); }
        if (!method_exists('rpg_ability', $method_name)){ continue; }
        foreach ($player_sides AS $player_side){
            if ($hazard_value != 'both' // not [both]
                && $hazard_value != $player_side // not [left/right]
                && $hazard_value != $player_side.'-active' && $hazard_value != $player_side.'-bench' // not [left/right]-[active/bench]
                ){ continue; } // doesn't match any criteria, so skip this player side
            $bench_size = $player_bench_sizes[$player_side];
            $hazards_added = 0;
            $hazards_to_add = $bench_size == 1 ? 1 : $bench_size;
            if ($hazard_value == $player_side.'-bench'){ $hazards_to_add -= 1; }
            for ($key = -1; $key < $max_bench_size; $key++){
                if ($key == 0){ continue; }
                elseif ($key == -1 && $hazard_value == ($player_side.'-bench')){ continue; } // skip if active but bench-only
                elseif ($key != -1 && $hazard_value == ($player_side.'-active')){ continue; } // skip of bench but active-only
                if ($hazards_added >= $hazards_to_add){ break; }
                if ($key == -1){  $static_key = $player_side.'-active';  }
                else { $static_key = $player_side.'-bench-'.$key; }
                $existing = !empty($this_battle->battle_attachments[$static_key]) ? count($this_battle->battle_attachments[$static_key]) : 0;
                $hazard_info = call_user_func('rpg_ability::'.$method_name, $static_key, 99, $existing);
                $this_battle->battle_attachments[$static_key][$hazard_info['attachment_token']] = $hazard_info;
{'fraction_non_alphanumeric': 0.1685619955979457, 'fraction_numerical': 0.004952311078503301, 'mean_word_length': 3.2205882352941178, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '1171005', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1704, 'n_words': 351}