package gui.tw.rw;

import gui.Start;
import provider.MapleDataTool;
import server.life.MapleLifeFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import static cn.hutool.core.text.CharSequenceUtil.containsIgnoreCase;

public class XuanShangRenWu {

    int cid;

    String account;

    String name;

    int mobId;

    String mobName;

    int mobNum;

    int maxNum;

    public int getCid() {
        return cid;
    }

    public void setCid(int cid) {
        this.cid = cid;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMobId() {
        return mobId;
    }

    public void setMobId(int mobId) {
        this.setMobName(MapleDataTool.getString((this.getMobId() + "/name"), MapleLifeFactory.mobStringData, "未知怪物"));
        this.mobId = mobId;
    }

    public String getMobName() {
        return mobName;
    }

    public void setMobName(String mobNName) {
        this.mobName = mobNName;
    }

    public int getMobNum() {
        return mobNum;
    }

    public void setMobNum(int mobNum) {
        this.mobNum = mobNum;
    }

    public int getMaxNum() {
        return maxNum;
    }

    public void setMaxNum(int maxNum) {
        this.maxNum = maxNum;
    }


    public static List<XuanShangRenWu> fuzzySearch( String keyword) {
        List<XuanShangRenWu> list = new ArrayList<>(Start.xsRW.values());
        if (keyword == null || keyword.trim().isEmpty()) {
            return list; // 如果关键词为空，返回所有
        }
        String lowerKeyword = keyword.toLowerCase();

        return list.stream()
                .filter(item ->
                        containsIgnoreCase(String.valueOf(item.cid), lowerKeyword) ||
                                containsIgnoreCase(item.account, lowerKeyword) ||
                                containsIgnoreCase(item.name, lowerKeyword) ||
                                containsIgnoreCase(String.valueOf(item.mobId), lowerKeyword) ||
                                containsIgnoreCase(item.mobName, lowerKeyword) ||
                                containsIgnoreCase(String.valueOf(item.mobNum), lowerKeyword) ||
                                containsIgnoreCase(String.valueOf(item.maxNum), lowerKeyword)
                )
                .collect(Collectors.toList());
    }
}
