import { TB } from "../../config/data/schema";
import { TD } from "../../App";
import GRoleBase from "../base/role/GRoleBase";

//角色工具类
export class GRoleUtil{

    //获取存活的玩家 如果不存活则返回 null
    static get<T extends GRoleBase<{}>>(player:T):() => T{
        if(!player) return null;
        return ():T => {
            if(player)
                return player.get();
            return null;
        }
    }

    //通过Id 获取 GRole
    static getGRole(id:number):TB.TbGRole{
        let info:TB.TbGRole;
        if(!(info = TD.TbGRole.get(id))) return null;
        return info
    }

    static getGRoles(ids:number[]):TB.TbGRole[]{
        return ids.map(id => GRoleUtil.getGRole(id));
    }

}


