package com.ff.base.enums;


import java.util.Optional;
import java.util.stream.Stream;

/**
 * jili游戏类型
 *
 * @author shi
 * @date 2024/10/22
 */
public enum JILIGameType {

    ELECTRON(1, 1,"电子"),
    CHESS(2, 2,"棋牌"),
    GAME_HALL(3, 3,"游戏大厅"),
    CATCH_FISH(5, 4,"捕鱼"),
    MACHINE(8, 5,"押分机 (含宾果)")

    ;

    private final Integer code;
    private final Integer systemCode;
    private final String info;
    JILIGameType(Integer code,Integer systemCode, String info)
    {
        this.code = code;
        this.systemCode = systemCode;
        this.info = info;
    }

    public Integer getCode()
    {
        return code;
    }

    public Integer getSystemCode()
    {
        return systemCode;
    }
    public String getInfo()
    {
        return info;
    }
    /**
     * 按代码查找系统
     *
     * @param code 代码
     * @return {@link String }
     */
    public static Integer findSystemByCode(Integer code) {
        Optional<Integer> system = Stream.of(JILIGameType.values())
                .filter(gameType -> gameType.getCode().equals(code))
                .map(JILIGameType::getSystemCode)
                .findFirst();
        return system.orElse(null);
    }

    /**
     * 按代码查找信息
     *
     * @param code 代码
     * @return {@link String }
     */
    public static String findInfoByCode(Integer code) {
        Optional<String> system = Stream.of(JILIGameType.values())
                .filter(gameType -> gameType.getCode().equals(code))
                .map(JILIGameType::getInfo)
                .findFirst();
        return system.orElse(null);
    }
}
