package org.keyscience.SingletonPattern;

import java.util.HashSet;

public class User {

    private static User instance;

    private long userID;

    private String name;


    private String email;
    private String bio;
    private int points;
    private String rank;

    public long getUserID() {
        return userID;
    }

    private HashSet<Integer> completedQuests;

    private User(long userID, String name, String email, String bio, int points, String rank, HashSet<Integer> completedQuests) {
        this.userID = userID;
        this.name = name;
        this.email = email;
        this.bio = bio;
        this.points = points;
        this.rank = rank;
        this.completedQuests = completedQuests;
    }

    public static User getInstance(long userID, String name, String email, String bio, int points, String rank, HashSet<Integer> completedQuests) {
        if (instance == null) {
            instance = new User(userID, name, email, bio, points, rank, completedQuests);
        }
        return instance;
    }

    public static User getInstance() {
        return instance;
    }

    public void addCompletedQuest(int id) {
        completedQuests.add(id);
    }

    public boolean contains(int id) {
        return completedQuests.contains(id);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBio() {
        return bio;
    }

    public void setBio(String bio) {
        this.bio = bio;
    }

    public int getPoints() {
        return points;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    public String getRank() {
        return rank;
    }

    public void setRank(String rank) {
        this.rank = rank;
    }

    public String getEmail() {
        return email;
    }

    public static void removeUserInstance() {
        instance = null;
    }

    public int getTotalCompletedQuests() {
        return completedQuests.size();
    }

}
