package net.cobem.grizzly.habbohotel.rooms.items.interactions;

import net.cobem.grizzly.Grizzly;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.games.football.BallInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.misc.RollerSkateInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.misc.WaterInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.randoms.DiceInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.randoms.VendingInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.randoms.WheelInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.roleplay.WorkoutMachineInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.wired.effects.WiredChangeFurniStateInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.wired.effects.WiredMoveAndRotateFurniInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.wired.effects.WiredShowUserMessageInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.wired.effects.WiredTransportUserInteraction;
import net.cobem.grizzly.habbohotel.rooms.items.interactions.wired.triggers.*;
import net.cobem.grizzly.habbohotel.sessions.Session;
import net.cobem.grizzly.habbohotel.wired.WiredType;

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

public class InteractionHandler {
    public Map<String, Interaction> Interactions;

    public InteractionHandler() {
        Interactions = new HashMap<>();

        register();
    }

    private boolean register() {
        Interactions.put("dice", new DiceInteraction());
        Interactions.put("bed", new BedInteraction());
        Interactions.put("gate", new GateInteraction());
        Interactions.put("habbowheel", new WheelInteraction());
        Interactions.put("vendingmachine", new VendingInteraction());
        Interactions.put("teleport", new TeleportInteraction());
        Interactions.put("water", new WaterInteraction());
        Interactions.put("rollerskate", new RollerSkateInteraction());
        Interactions.put("ball", new BallInteraction());
        Interactions.put("roller", new RollerInteraction());

        Interactions.put(WiredType.EFFECT_SENDALERT, new WiredShowUserMessageInteraction());
        Interactions.put(WiredType.EFFECT_CHANGEUSERPOSITION, new WiredTransportUserInteraction());
        Interactions.put(WiredType.EFFECT_CHANGEFURNISTATE, new WiredChangeFurniStateInteraction());
        Interactions.put(WiredType.EFFECT_CHANGEITEMPOSITION, new WiredMoveAndRotateFurniInteraction());

        Interactions.put(WiredType.TRIGGER_ENTERROOM, new WiredUserEnterRoomInteraction());
        Interactions.put(WiredType.TRIGGER_SAYMESSAGE, new WiredUserSaysKeyWordInteraction());
        Interactions.put(WiredType.TRIGGER_STANDONFURNI, new WiredUserWalksOnFurniInteraction());
        Interactions.put(WiredType.TRIGGER_STANDOFFFURNI, new WiredUserWalksOffFurniInteraction());
        Interactions.put(WiredType.TRIGGER_CHANGEFURNISTATE, new WiredToggleStateInteraction());

        if (Grizzly.roleplayEnabled()) {
            Interactions.put("workout_machine", new WorkoutMachineInteraction());
        }
        return true;
    }

    public boolean onPlace(String Interaction, Session Session, Object Item) {
        if (!Interactions.containsKey(Interaction)) {
            return false;
        }

        Interactions.get(Interaction).onPlace(Session, Item);

        return true;
    }

    public boolean onRemove(String Interaction, Session Session, Object Item) {
        if (!Interactions.containsKey(Interaction)) {
            return false;
        }

        Interactions.get(Interaction).onRemove(Session, Item);

        return true;
    }

    public boolean onTrigger(String Interaction, Session Session, Object Item, int Request) {
        if (!Interactions.containsKey(Interaction)) {
            return false;
        }

        Interactions.get(Interaction).onTrigger(Session, Item, Request);

        return true;
    }

    public boolean onCycle(String Interaction, Object Item) {
        if (!Interactions.containsKey(Interaction)) {
            return false;
        }

        Interactions.get(Interaction).onCycle(Item);

        return true;
    }
}
