package net.cobem.grizzly.habbohotel.guild;

import net.cobem.grizzly.Grizzly;
import net.cobem.grizzly.habbohotel.rooms.Room;
import net.cobem.grizzly.habbohotel.sessions.Session;
import net.cobem.grizzly.habbohotel.users.User;
import net.cobem.grizzly.habbohotel.users.UserDAO;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

public class Guild {
    private int ID;
    private int Owner;
    private int Room;

    private int First_Color;
    private int Second_Color;

    private int Base;
    private int Base_Color;

    private String States;

    private String Title;
    private String Description;

    private Date Creation_Date;

    public Guild(ResultSet Set) {
        Creation_Date = new Date();

        this.FillClass(Set);
    }

    public Guild(int ID) {
        FillClass(Grizzly.getStorage().query("SELECT * FROM server_guilds WHERE id = '" + ID + "'").getRow());
    }

    private boolean FillClass(ResultSet Set) {
        try {
            this.ID = Set.getInt("id");
            this.Owner = Set.getInt("owner");
            this.Room = Set.getInt("room");

            this.First_Color = Set.getInt("first_color");
            this.Second_Color = Set.getInt("second_color");

            this.Base = Set.getInt("base");
            this.Base_Color = Set.getInt("base_color");

            this.States = Set.getString("states");

            this.Title = Set.getString("title");
            this.Description = Set.getString("Description");

            this.Creation_Date.setTime(Set.getLong("creation_date"));
        } catch (SQLException E) {
            Grizzly.write(E.getMessage());
        }
        return true;
    }

    public int getID() {
        return ID;
    }

    public int getOwner() {
        return Owner;
    }

    public User getRealOwner() {
        return UserDAO.generateUser(Owner);
    }

    public Session getOwnerSession() {
        return Grizzly.getHabboHotel().getSessions().getByID(Owner);
    }

    public int getRoom() {
        return Room;
    }

    public Room getRealRoom() {
        return Grizzly.getHabboHotel().getRooms().getByID(Room);
    }

    public int getFirstColor() {
        return First_Color;
    }

    public int getSecondColor() {
        return Second_Color;
    }

    public int getBase() {
        return Base;
    }

    public int getBaseColor() {
        return Base_Color;
    }

    public String getTitle() {
        return Title;
    }

    public String getDescription() {
        return Description;
    }

    public String getStates() {
        return States;
    }

    public Date getCreationDate() {
        return Creation_Date;
    }

    /* public String getImage()
    {
        List<Integer> mStates = new ArrayList<>();

        for(String)
        return Grizzly.getHabboHotel().getGuilds().getImage(Base, First_Color, new ArrayList<new Integer(States.split(","))>());
    }  */
}
