package com.couple.loveapp;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * PointsInfo - Model يحمل معلومات النقاط والمستويات للمستخدم
 */
public class PointsInfo {
    private int level;
    private int currentXp;
    private int xpForNextLevel;
    private int xpProgress;
    private int xpNeeded;
    private double progressPercentage;
    private int lovePoints;
    private boolean canClaimDaily;
    
    // Constructor من JSON
    public PointsInfo(JSONObject json) throws JSONException {
        this.level = json.optInt("level", 1);
        this.currentXp = json.optInt("current_xp", 0);
        this.xpForNextLevel = json.optInt("xp_for_next_level", 100);
        this.xpProgress = json.optInt("xp_progress", 0);
        this.xpNeeded = json.optInt("xp_needed", 100);
        this.progressPercentage = json.optDouble("progress_percentage", 0.0);
        this.lovePoints = json.optInt("love_points", 0);
        this.canClaimDaily = json.optBoolean("can_claim_daily", true);
    }
    
    // Constructor فارغ
    public PointsInfo() {
        this.level = 1;
        this.currentXp = 0;
        this.xpForNextLevel = 100;
        this.xpProgress = 0;
        this.xpNeeded = 100;
        this.progressPercentage = 0.0;
        this.lovePoints = 0;
        this.canClaimDaily = true;
    }
    
    // Getters
    public int getLevel() {
        return level;
    }
    
    public int getCurrentXp() {
        return currentXp;
    }
    
    public int getXpForNextLevel() {
        return xpForNextLevel;
    }
    
    public int getXpProgress() {
        return xpProgress;
    }
    
    public int getXpNeeded() {
        return xpNeeded;
    }
    
    public double getProgressPercentage() {
        return progressPercentage;
    }
    
    public int getLovePoints() {
        return lovePoints;
    }
    
    public boolean canClaimDaily() {
        return canClaimDaily;
    }
    
    // Setters (للتحديثات المحلية)
    public void setLevel(int level) {
        this.level = level;
    }
    
    public void setCurrentXp(int currentXp) {
        this.currentXp = currentXp;
    }
    
    public void setLovePoints(int lovePoints) {
        this.lovePoints = lovePoints;
    }
    
    public void setCanClaimDaily(boolean canClaimDaily) {
        this.canClaimDaily = canClaimDaily;
    }
    
    @Override
    public String toString() {
        return "PointsInfo{" +
                "level=" + level +
                ", currentXp=" + currentXp +
                ", xpForNextLevel=" + xpForNextLevel +
                ", xpProgress=" + xpProgress +
                ", xpNeeded=" + xpNeeded +
                ", progressPercentage=" + progressPercentage +
                ", lovePoints=" + lovePoints +
                ", canClaimDaily=" + canClaimDaily +
                '}';
    }
}