@genshin-kit/core
Version:
An API wrapper for fetching player data of Genshin Impact from any servers.
36 lines • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCharacterIds = exports.getAllIds = void 0;
const tslib_1 = require("tslib");
const axios_1 = (0, tslib_1.__importDefault)(require("axios"));
async function getAllIds(lang = 'zh-cn') {
return (await axios_1.default.get(`https://webstatic.mihoyo.com/hk4e/gacha_info/cn_gf01/items/${lang}.json`)).data;
}
exports.getAllIds = getAllIds;
function filter(data, names) {
return data
.filter((i) => names.includes(i.item_type))
.map(({ item_id, item_type, name, rank_type }) => {
return {
item_id: String(Number(item_id) - 1000 + 10000000),
name,
item_type,
rank_type,
};
});
}
async function getCharacterIds(lang) {
const data = await getAllIds(lang);
const characters = filter(data, ['角色']);
return [
{
item_id: '10000007',
name: '旅行者',
item_type: '角色',
rank_type: '5',
},
...characters,
];
}
exports.getCharacterIds = getCharacterIds;
//# sourceMappingURL=getItemIds.js.map