// scripts/armor/sets/weapon_combos.js
import { EquipmentSlot } from "@minecraft/server";
import { ARMOR_SETS, hasSet, safeAddEffect,E } from "./armors_index.js";

export function weaponCombos(player, eqIds) {
  const mh = eqIds[EquipmentSlot.Mainhand];

  const jade = hasSet(eqIds, ARMOR_SETS.jade);
  const diamond = hasSet(eqIds, ARMOR_SETS.diamond);
  const netherite = hasSet(eqIds, ARMOR_SETS.netherite);
  const tungsten = hasSet(eqIds, ARMOR_SETS.tungsten);
  const silver = hasSet(eqIds, ARMOR_SETS.silver);
  const cobalt = hasSet(eqIds, ARMOR_SETS.cobalt);
  const gold = hasSet(eqIds, ARMOR_SETS.gold);
  const iron = hasSet(eqIds, ARMOR_SETS.iron);

  if (jade && mh === "dungeon:jade_sword") safeAddEffect(player, E.strength, 0);

  if (diamond) {
    if (mh === "minecraft:diamond_spear" || mh === "minecraft:diamond_sword") safeAddEffect(player, E.strength, 0);
    if (mh === "minecraft:diamond_pickaxe" || mh === "minecraft:diamond_shovel" || mh === "minecraft:diamond_hoe" || mh === "minecraft:diamond_axe")
      safeAddEffect(player, E.haste, 0);
    if (mh === "minecraft:diamond_axe") safeAddEffect(player, E.strength, 0);
  }

  if (netherite) {
    if (mh === "minecraft:netherite_spear" || mh === "minecraft:netherite_sword") safeAddEffect(player, E.strength, 0);
    if (mh === "minecraft:netherite_pickaxe" || mh === "minecraft:netherite_shovel" || mh === "minecraft:netherite_hoe" || mh === "minecraft:netherite_axe")
      safeAddEffect(player, E.haste, 0);
    if (mh === "minecraft:netherite_axe") safeAddEffect(player, E.strength, 0);
  }

  if (tungsten) {
    if (mh === "dungeon:tungsten_sword") safeAddEffect(player, E.strength, 0);
    if (mh === "dungeon:tungsten_shovel" || mh === "dungeon:tungsten_hoe") safeAddEffect(player, E.haste, 0);
    if (mh === "dungeon:tungsten_battleaxe") {
      safeAddEffect(player, E.strength, 1);
      safeAddEffect(player, E.haste, 0);
    }
  }

  if (silver) {
    if (mh === "dungeon:silver_sword") safeAddEffect(player, E.strength, 0);
    if (mh === "dungeon:silver_shovel" || mh === "dungeon:silver_hoe") safeAddEffect(player, E.haste, 0);
    if (mh === "dungeon:silver_axe") {
      safeAddEffect(player, E.strength, 0);
      safeAddEffect(player, E.haste, 0);
    }
  }

  if (cobalt) {
    if (mh === "dungeon:cobalt_sword") safeAddEffect(player, E.strength, 0);
    if (mh === "dungeon:cobalt_hammer") safeAddEffect(player, E.haste, 1);
    if (mh === "dungeon:cobalt_shovel") safeAddEffect(player, E.haste, 0);
    if (mh === "dungeon:cobalt_axe") {
      safeAddEffect(player, E.strength, 0);
      safeAddEffect(player, E.haste, 0);
    }
    if (mh === "dungeon:cobalt_hoe") safeAddEffect(player, E.haste, 0);
  }

  if (gold) {
    if (mh === "minecraft:golden_spear" || mh === "minecraft:golden_sword") safeAddEffect(player, E.strength, 1);
    if (mh === "minecraft:golden_pickaxe" || mh === "minecraft:golden_shovel" || mh === "minecraft:golden_hoe" || mh === "minecraft:golden_axe")
      safeAddEffect(player, E.haste, 1);
    if (mh === "minecraft:golden_axe") safeAddEffect(player, E.strength, 1);
  }

  if (iron) {
    if (mh === "minecraft:iron_spear" || mh === "minecraft:iron_sword") safeAddEffect(player, E.strength, 0);
    if (mh === "minecraft:iron_pickaxe" || mh === "minecraft:iron_shovel") safeAddEffect(player, E.haste, 0);
    if (mh === "minecraft:iron_axe") {
      safeAddEffect(player, E.strength, 0);
      safeAddEffect(player, E.haste, 0);
    }
    if (mh === "minecraft:iron_hoe") safeAddEffect(player, E.haste, 0);
  }
}
