import { world } from "@minecraft/server";
import { namespace } from "../Namespace";
import { explosionSpellEvent } from "./2. Explosion";
import { waterSpellEvent } from "./5. Water";
import { fireSpellEvent } from "./6. Fire";
import { poisonHurtSpellEvent } from "./8. Poison";
import { levitatingHurtSpellEvent } from "./10. Levitating";
import { fogSpellEvent } from "./12. Fog";
import { iceSpellEvent, iceHurtSpellEvent } from "./13. Ice";
import { stunHurtSpellEvent } from "./14. Stun";
import { spongeSpellEvent } from "./15. Sponge";
import { transformHurtSpellEvent } from "./20. Transform";

export function doSpellEvent(entityName, location, dimension) {
  const spellName = entityName.replace(`${namespace}:`,"").replace("_spell","");
  switch (spellName) {
    case ("spark"): {
      return;
    }
    case ("explosion"): {
      explosionSpellEvent(location, dimension);
      return;
    }
    case ("water"): {
      waterSpellEvent(location, dimension);
      return;
    }
    case ("fire"): {
      fireSpellEvent(location, dimension);
      return;
    }
    case ("fog"): {
      fogSpellEvent(location, dimension);
      return;
    }
    case ("ice"): {
      iceSpellEvent(location, dimension);
      return;
    }
    case ("sponge"): {
      spongeSpellEvent(location, dimension);
      return;
    }
    default: {
      return;
    }
  }
}

export function doHurtSpellEvent(entityName, hurtEntity) {
  const dimension = hurtEntity.dimension;
  const location = hurtEntity.location;
  const spellName = entityName.replace(`${namespace}:`,"").replace("_spell","");

  switch (spellName) {
    case ("spark"): {
      return;
    }
    case ("poison"): {
      poisonHurtSpellEvent(location, dimension);
      return;
    }
    case ("levitation"): {
      levitatingHurtSpellEvent(location, dimension);
      return;
    }
    case ("ice"): {
      iceHurtSpellEvent(location, dimension);
      return;
    }
    case ("stun"): {
      stunHurtSpellEvent(hurtEntity);
      return;
    }
    case ("transform"): {
      transformHurtSpellEvent(hurtEntity);
      return;
    }
  };
}