package com.ycwl.basic.puzzle.fill;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * 拼图元素填充结果
 *
 * @author Claude
 * @since 2025-01-20
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FillResult {

    /**
     * 是否匹配到规则
     */
    private boolean ruleMatched;

    /**
     * 匹配的规则名称（如果有）
     */
    private String matchedRuleName;

    /**
     * 填充的数据
     */
    @Builder.Default
    private Map<String, String> dynamicData = new HashMap<>();

    /**
     * 成功填充的元素数量
     */
    private int filledCount;

    /**
     * 创建空结果（未匹配）
     */
    public static FillResult noMatch() {
        return FillResult.builder()
                .ruleMatched(false)
                .dynamicData(new HashMap<>())
                .filledCount(0)
                .build();
    }

    /**
     * 创建匹配成功的结果
     */
    public static FillResult matched(String ruleName, Map<String, String> data, int count) {
        return FillResult.builder()
                .ruleMatched(true)
                .matchedRuleName(ruleName)
                .dynamicData(data)
                .filledCount(count)
                .build();
    }
}
