<commit_before>package io.luna.game.model.def;

import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
import io.luna.game.model.mobile.Npc;

/**
 * A cached definition that describes specific combat properties for {@link Npc}s.
 *
 * @author lare96 <http://github.org/lare96>
 */
public final class NpcCombatDefinition {

    /**
     * The attack skill index in the {@code skills} list.
     */
    public static final int ATTACK = 0;

    /**
     * The strength skill index in the {@code skills} list.
     */
    public static final int STRENGTH = 1;

    /**
     * The defence skill index in the {@code skills} list.
     */
    public static final int DEFENCE = 2;

    /**
     * The ranged skill index in the {@code skills} list.
     */
    public static final int RANGED = 3;

    /**
     * The magic skill index in the {@code skills} list.
     */
    public static final int MAGIC = 4;

    /**
     * The stab attack bonus in the {@code bonuses} list.
     */
    public static final int STAB_ATTACK = 0;

    /**
     * The slash attack bonus in the {@code bonuses} list.
     */
    public static final int SLASH_ATTACK = 1;

    /**
     * The crush attack bonus in the {@code bonuses} list.
     */
    public static final int CRUSH_ATTACK = 2;

    /**
     * The magic attack bonus in the {@code bonuses} list.
     */
    public static final int MAGIC_ATTACK = 3;

    /**
     * The ranged attack bonus in the {@code bonuses} list.
     */
    public static final int RANGED_ATTACK = 4;

    /**
     * The stab defence bonus in the {@code bonuses} list.
     */
    public static final int STAB_DEFENCE = 5;

    /**
     * The slash defence bonus in the {@code bonuses} list.
     */
    public static final int SLASH_DEFENCE = 6;

    /**
     * The crush defence bonus in the {@code bonuses} list.
     */
    public static final int CRUSH_DEFENCE = 7;

    /**
     * The magic defence bonus in the {@code bonuses} list.
     */
    public static final int MAGIC_DEFENCE = 8;

    /**
     * The ranged defence bonus in the {@code bonuses} list.
     */
    public static final int RANGED_DEFENCE = 9;

    /**
     * An array of the cached {@code NpcCombatDefinition}s.
     */
    public static final NpcCombatDefinition[] DEFINITIONS = new NpcCombatDefinition[8152];

    /**
     * The default {@link NpcCombatDefinition} used when none in {@code DEFINITIONS} can be assigned to an {@code Npc}.
     */
    public static final NpcCombatDefinition DEFAULT = new NpcCombatDefinition(-1, 8, false, false, -1, -1, -1, -1, -1, -1,
        -1, new int[5], new int[10]);

    /**
     * Retrieves a cached {@link NpcCombatDefinition} by its {@code id}.
     *
     * @param id The identifier to retrieve the {@code NpcCombatDefinition}.
     * @return The {@code NpcCombatDefinition} instance.
     */
    public static NpcCombatDefinition getDefinition(int id) {
        NpcCombatDefinition def = DEFINITIONS[id];
        return def == null ? DEFAULT : def;
    }

    /**
     * The id of the {@code Npc} this definition is for.
     */
    private final int id;

    /**
     * The amount of ticks it takes to respawn.
     */
    private final int respawnTicks;

    /**
     * If the {@code Npc} is aggressive.
     */
    private final boolean aggressive;

    /**
     * If the {@code Npc} is poisonous.
     */
    private final boolean poisonous;

    /**
     * The combat level of the {@code Npc}.
     */
    private final int combatLevel;

    /**
     * The hitpoint amount of the {@code Npc}.<commit_msg>Use map instead of array to hold definitions, to conserve memory<commit_after>package io.luna.game.model.def;

import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
import io.luna.game.model.mobile.Npc;

import java.util.HashMap;
import java.util.Map;

/**
 * A cached definition that describes specific combat properties for {@link Npc}s.
 *
 * @author lare96 <http://github.org/lare96>
 */
public final class NpcCombatDefinition {

    /**
     * The attack skill index in the {@code skills} list.
     */
    public static final int ATTACK = 0;

    /**
     * The strength skill index in the {@code skills} list.
     */
    public static final int STRENGTH = 1;

    /**
     * The defence skill index in the {@code skills} list.
     */
    public static final int DEFENCE = 2;

    /**
     * The ranged skill index in the {@code skills} list.
     */
    public static final int RANGED = 3;

    /**
     * The magic skill index in the {@code skills} list.
     */
    public static final int MAGIC = 4;

    /**
     * The stab attack bonus in the {@code bonuses} list.
     */
    public static final int STAB_ATTACK = 0;

    /**
     * The slash attack bonus in the {@code bonuses} list.
     */
    public static final int SLASH_ATTACK = 1;

    /**
     * The crush attack bonus in the {@code bonuses} list.
     */
    public static final int CRUSH_ATTACK = 2;

    /**
     * The magic attack bonus in the {@code bonuses} list.
     */
    public static final int MAGIC_ATTACK = 3;

    /**
     * The ranged attack bonus in the {@code bonuses} list.
     */
    public static final int RANGED_ATTACK = 4;

    /**
     * The stab defence bonus in the {@code bonuses} list.
     */
    public static final int STAB_DEFENCE = 5;

    /**
     * The slash defence bonus in the {@code bonuses} list.
     */
    public static final int SLASH_DEFENCE = 6;

    /**
     * The crush defence bonus in the {@code bonuses} list.
     */
    public static final int CRUSH_DEFENCE = 7;

    /**
     * The magic defence bonus in the {@code bonuses} list.
     */
    public static final int MAGIC_DEFENCE = 8;

    /**
     * The ranged defence bonus in the {@code bonuses} list.
     */
    public static final int RANGED_DEFENCE = 9;

    /**
     * A {@link Map} of the cached {@code NpcCombatDefinition}s.
     */
    public static final Map<Integer, NpcCombatDefinition> DEFINITIONS = new HashMap<>();

    /**
     * The default {@link NpcCombatDefinition} used when none in {@code DEFINITIONS} can be assigned to an {@code Npc}.
     */
    public static final NpcCombatDefinition DEFAULT = new NpcCombatDefinition(-1, 8, false, false, -1, -1, -1, -1, -1, -1,
        -1, new int[5], new int[10]);

    /**
     * Retrieves a cached {@link NpcCombatDefinition} by its {@code id}.
     *
     * @param id The identifier to retrieve the {@code NpcCombatDefinition}.
     * @return The {@code NpcCombatDefinition} instance.
     */
    public static NpcCombatDefinition getDefinition(int id) {
        return DEFINITIONS.getOrDefault(id, DEFAULT);
    }

    /**
     * The id of the {@code Npc} this definition is for.
     */
    private final int id;

    /**
     * The amount of ticks it takes to respawn.
     */
    private final int respawnTicks;

    /**
     * If the {@code Npc} is aggressive.
     */
    private final boolean aggressive;

    /**
     * If the {@code Npc} is poisonous.
     */
    private final boolean poisonous;

    /**
     * The combat level of the {@code Npc}.
     */
    private final int combatLevel;

    /**
     * The hitpoint amount of the {@code Npc}.
{'fraction_non_alphanumeric': 0.10758792578233177, 'fraction_numerical': 0.009138742730545555, 'mean_word_length': 2.25653742110009, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3401149', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2121, 'n_words': 816}