32 lines
743 B
TypeScript
Raw Normal View History

2023-12-13 19:33:57 +08:00
import { TB } from "../../config/data/schema";
2023-11-06 02:25:02 +08:00
import { TD } from "../../App";
2023-10-26 03:06:44 +08:00
import GRoleBase from "../base/role/GRoleBase";
//角色工具类
export class GRoleUtil{
//获取存活的玩家 如果不存活则返回 null
2023-12-11 10:42:36 +08:00
static get<T extends GRoleBase<{}>>(player:T):() => T{
2023-10-26 03:06:44 +08:00
if(!player) return null;
2023-11-01 02:01:35 +08:00
return ():T => {
2023-10-26 03:06:44 +08:00
if(player)
return player.get();
return null;
}
}
//通过Id 获取 GRole
2023-11-06 02:25:02 +08:00
static getGRole(id:number):TB.TbGRole{
let info:TB.TbGRole;
if(!(info = TD.TbGRole.get(id))) return null;
2023-10-30 02:34:11 +08:00
return info
2023-10-26 03:06:44 +08:00
}
2023-11-06 02:25:02 +08:00
static getGRoles(ids:number[]):TB.TbGRole[]{
2023-10-26 03:06:44 +08:00
return ids.map(id => GRoleUtil.getGRole(id));
}
}