import { ARMOR_SETS, hasSet, safeAddEffect, setTag,E } from "./armors_index.js";

function hasNearbyLumimoth(player, radius = 32) {
  const dim = player.dimension;
  const loc = player.location;
  const ents = dim.getEntities({ location: loc, maxDistance: radius, families: ["lumimoth"] });
  return ents.length > 0;
}

export function viritumSet(player, eqIds) {
  const viritum = hasSet(eqIds, ARMOR_SETS.viritum);
  setTag(player, "buff2", viritum);

  if (!viritum) return;

  safeAddEffect(player, E.resistance, 0);

  if (hasNearbyLumimoth(player, 32)) {
    safeAddEffect(player, E.resistance, 2);
  }
}
