package com.openosrs.client.api.types;

public class NPC {
    private final int index;
    private final int id;
    private final String name;
    private final Position position;
    private final int hitpoints;
    private final int maxHitpoints;
    private final int combatLevel;
    private final int animationId;
    private final boolean inCombat;
    private final String overheadText;

    public NPC(int index, int id, String name, Position position,
               int hitpoints, int maxHitpoints, int combatLevel,
               int animationId, boolean inCombat, String overheadText) {
        this.index = index;
        this.id = id;
        this.name = name;
        this.position = position;
        this.hitpoints = hitpoints;
        this.maxHitpoints = maxHitpoints;
        this.combatLevel = combatLevel;
        this.animationId = animationId;
        this.inCombat = inCombat;
        this.overheadText = overheadText;
    }

    public int getIndex() { return index; }
    public int getId() { return id; }
    public String getName() { return name; }
    public Position getPosition() { return position; }
    public int getHitpoints() { return hitpoints; }
    public int getMaxHitpoints() { return maxHitpoints; }
    public int getCombatLevel() { return combatLevel; }
    public int getAnimationId() { return animationId; }
    public boolean isInCombat() { return inCombat; }
    public String getOverheadText() { return overheadText; }

    public double distanceToPlayer(Position playerPos) {
        return position.distanceTo(playerPos);
    }

    public boolean isInteractable() {
        // NPCs with -1 ID are typically not interactable
        return id != -1;
    }

    @Override
    public String toString() {
        return String.format("NPC[%d] %s (%d) at %s", index, name, id, position);
    }
}
