package gui.tw;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;

public class BlConfig {
    int  item_id;
    int gold_rate;
    int item_rate;

    String time_range;

    int stackableNum;


    public int getItem_id() {
        return item_id;
    }

    public void setItem_id(int item_id) {
        this.item_id = item_id;
    }

    public int getGold_rate() {
        return gold_rate;
    }

    public void setGold_rate(int gold_rate) {
        this.gold_rate = gold_rate;
    }

    public int getItem_rate() {
        return item_rate;
    }

    public void setItem_rate(int item_rate) {
        this.item_rate = item_rate;
    }

    public String getTime_range() {
        return time_range;
    }

    public void setTime_range(String time_range) {
        this.time_range = time_range;
    }

    public int getStackableNum() {
        return stackableNum;
    }

    public void setStackable(int stackable) {
        this.stackableNum = stackable;
    }


    public boolean isInTimeRange() {
        DateTime time = DateUtil.date();

        String[] range = time_range.split("-");
        if (range.length != 2) {
            throw new IllegalArgumentException("时间格式不正确，应为 HH:mm-HH:mm");
        }

        
        String endTimeStr = range[1];
        if ("24:00".equals(endTimeStr)) {
            endTimeStr = "00:00";
        }

        DateTime startTime = DateUtil.parseTimeToday(range[0]);
        DateTime endTime = DateUtil.parseTimeToday(endTimeStr);

        if ("24:00".equals(range[1])) {
            
            endTime = endTime.offset(DateField.DAY_OF_YEAR, 1); 
        }

        if (startTime.isBeforeOrEquals(endTime)) {
            
            return !time.isBefore(startTime) && !time.isAfter(endTime);
        } else {
            
            return !time.isBefore(startTime) || !time.isAfter(endTime);
        }
    }

}
