package com.tiedup.remake.client.state;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

/**
 * Client-side state for tracking active labor task progress.
 * Synchronized from server via PacketSyncLaborProgress.
 */
@OnlyIn(Dist.CLIENT)
public class ClientLaborState {

    private static boolean hasTask = false;
    private static String taskDescription = "";
    private static int progress = 0;
    private static int quota = 0;
    private static int valueEmeralds = 0;

    /**
     * Set the current labor task.
     *
     * @param description Task description (e.g., "Kill 8 Spiders")
     * @param currentProgress Current progress count
     * @param targetQuota Target quota to complete
     * @param value Task value in emeralds
     */
    public static void setTask(
        String description,
        int currentProgress,
        int targetQuota,
        int value
    ) {
        hasTask = true;
        taskDescription = description;
        progress = currentProgress;
        quota = targetQuota;
        valueEmeralds = value;
    }

    /**
     * Clear the current task (no active task).
     */
    public static void clearTask() {
        hasTask = false;
        taskDescription = "";
        progress = 0;
        quota = 0;
        valueEmeralds = 0;
    }

    /**
     * Check if there is an active labor task.
     */
    public static boolean hasActiveTask() {
        return hasTask;
    }

    /**
     * Get the task description.
     */
    public static String getTaskDescription() {
        return taskDescription;
    }

    /**
     * Get the current progress.
     */
    public static int getProgress() {
        return progress;
    }

    /**
     * Get the target quota.
     */
    public static int getQuota() {
        return quota;
    }

    /**
     * Get the task value in emeralds.
     */
    public static int getValueEmeralds() {
        return valueEmeralds;
    }

    /**
     * Get the progress as a float (0.0 to 1.0).
     */
    public static float getProgressFraction() {
        if (quota <= 0) return 0.0f;
        return Math.min(1.0f, (float) progress / quota);
    }

    /**
     * Get a formatted progress string (e.g., "5/10").
     */
    public static String getProgressString() {
        return progress + "/" + quota;
    }
}
