package org.xyzh.achievement.checker.impl;

import org.springframework.stereotype.Component;
import org.xyzh.achievement.checker.AbstractAchievementChecker;
import org.xyzh.common.core.enums.AchievementConditionType;
import org.xyzh.common.core.enums.AchievementEventType;
import org.xyzh.common.core.event.AchievementEvent;

/**
 * @description 连续登录天数成就检测器
 * @filename ContinuousLoginChecker.java
 * @author yslg
 * @copyright xyzh
 * @since 2025-10-24
 */
@Component
public class ContinuousLoginChecker extends AbstractAchievementChecker {

    @Override
    protected AchievementConditionType getSupportedConditionType() {
        return AchievementConditionType.CONTINUOUS_LOGIN_DAYS;
    }

    @Override
    protected AchievementEventType[] getSupportedEventTypes() {
        return new AchievementEventType[]{
            AchievementEventType.CONTINUOUS_LOGIN,
            AchievementEventType.USER_LOGIN
        };
    }

    @Override
    public Integer calculateNewProgress(AchievementEvent event, Integer currentProgress) {
        // 对于连续登录，直接使用事件值（连续天数）
        return event.getEventValue() != null ? event.getEventValue() : currentProgress;
    }
}

