package net.cobem.grizzly.communication.events.guild;

import net.cobem.grizzly.Grizzly;
import net.cobem.grizzly.communication.EventRequest;
import net.cobem.grizzly.communication.EventResponse;
import net.cobem.grizzly.communication.GameEvent;
import net.cobem.grizzly.communication.HeaderLibrary;
import net.cobem.grizzly.habbohotel.rooms.Room;
import net.cobem.grizzly.habbohotel.sessions.Session;

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

public class CreateGuildEvent implements GameEvent {
    @Override
    public void compose(Session Session, EventRequest Request) {
        Map<Integer, Room> UserRooms = new HashMap<Integer, Room>();//Grizzly.GrabHabboHotel().GrabRoomHandler().GrabUsersRooms(Session.GrabHabbo().ID);

        if (UserRooms.size() == 0) {
            UserRooms = Grizzly.getHabboHotel().getRooms().getByOwner(Session.getHabbo().getID(), true);
        }

        EventResponse Message = new EventResponse();

        Message.Initialize(HeaderLibrary.ShowGroupDialogEvent);
        Message.addInt(10);
        Message.addInt(UserRooms.size());

        for (Room Room : UserRooms.values()) {
            Message.addInt(Room.ID);
            Message.addString(Room.Title);
            Message.addBool(false);
        }

        Message.addInt(5);
        Message.addInt(10);
        Message.addInt(3);
        Message.addInt(4);
        Message.addInt(25);
        Message.addInt(17);
        Message.addInt(5);
        Message.addInt(25);
        Message.addInt(17);
        Message.addInt(3);
        Message.addInt(29);
        Message.addInt(11);
        Message.addInt(4);
        Message.addInt(0);
        Message.addInt(0);
        Message.addInt(0);

        Session.sendResponse(Message);
        Session.sendResponse(Grizzly.getHabboHotel().getGuilds().getGuildPieces().Serialize());
    }
}
