genshin-manager
Version:
<div align="center"> <p> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https://img.shields.io/npm/v/genshin-manager.svg?maxAge=3600" alt="npm version" /></a> <a href="https://www.npmjs.com/package/genshin-manager"><img src="https:
110 lines (109 loc) • 5.42 kB
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DailyFarming = void 0;
const Client_1 = require("../client/Client");
const OutOfRangeError_1 = require("../errors/OutOfRangeError");
const CharacterInfo_1 = require("../models/character/CharacterInfo");
const CharacterSkill_1 = require("../models/character/CharacterSkill");
const CharacterSkillAscension_1 = require("../models/character/CharacterSkillAscension");
const Weapon_1 = require("../models/weapon/Weapon");
const WeaponAscension_1 = require("../models/weapon/WeaponAscension");
/**
* Class of materials available on specified days of the week
*/
class DailyFarming {
/**
* Create a DailyFarming
* @description 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
* @param dayOfWeek day-of-week (0-6)
*/
constructor(dayOfWeek) {
/**
* Domains
*/
this.domains = [];
if (dayOfWeek < 0 || dayOfWeek > 6)
throw new OutOfRangeError_1.OutOfRangeError('dayOfWeek', dayOfWeek, 0, 6);
this.dayOfWeek = dayOfWeek;
const rewardDateIndex = dayOfWeek === 0 ? 3 : (dayOfWeek - 1) % 3;
const dungeons = Object.values(Client_1.Client._getCachedExcelBinOutputByName('DungeonEntryExcelConfigData'));
const skillDomains = dungeons.filter((d) => d.type === 'DUNGEN_ENTRY_TYPE_AVATAR_TALENT');
const weaponDomains = dungeons.filter((d) => d.type === 'DUNGEN_ENTRY_TYPE_WEAPON_PROMOTE');
for (let i = 0; i < (dayOfWeek === 0 ? 3 : 1); i++) {
;
[...weaponDomains, ...skillDomains].forEach((domain) => {
const materialIds = domain.descriptionCycleRewardList[dayOfWeek === 0 ? i : rewardDateIndex];
const nameTextId = Object.keys(_a.replaceTextMapIdMap).includes(String(domain.dungeonEntryId))
? _a.replaceTextMapIdMap[domain.dungeonEntryId]
: `UI_DUNGEON_ENTRY_${domain.dungeonEntryId}`;
const manualTextJson = Client_1.Client._getJsonFromCachedExcelBinOutput('ManualTextMapConfigData', nameTextId);
this.domains.push({
name: Client_1.Client._cachedTextMap.get(String(manualTextJson.textMapContentTextMapHash)) || '',
description: Client_1.Client._cachedTextMap.get(String(domain.descTextMapHash)) || '',
materialIds: materialIds,
characterInfos: this.getCharacterInfoByMaterialIds(materialIds),
weaponIds: this.getWeaponIdsByMaterialIds(materialIds),
});
});
}
this.talentBookIds = skillDomains.flatMap((d) => d.descriptionCycleRewardList[rewardDateIndex]);
this.weaponMaterialIds = weaponDomains.flatMap((d) => d.descriptionCycleRewardList[rewardDateIndex]);
}
getCharacterInfoByMaterialIds(materialIds) {
const result = [];
const skillIds = new Set();
CharacterSkill_1.CharacterSkill.allSkillIds.forEach((skillId) => {
for (let skillLevel = 1; skillLevel <= 10; skillLevel++) {
const skillAscension = new CharacterSkillAscension_1.CharacterSkillAscension(skillId, skillLevel);
const costMaterialIds = skillAscension.costItems.map((item) => item.id);
if (costMaterialIds.some((id) => materialIds.includes(id)))
skillIds.add(skillId);
}
});
CharacterInfo_1.CharacterInfo.allCharacterIds.forEach((characterId) => {
if ([10000005, 10000007].includes(characterId)) {
CharacterInfo_1.CharacterInfo.getTravelerSkillDepotIds(characterId).forEach((skillDepotId) => {
const character = new CharacterInfo_1.CharacterInfo(characterId, skillDepotId);
if (character.skillOrder.some((skillId) => skillIds.has(skillId)))
result.push(character);
});
}
else {
const character = new CharacterInfo_1.CharacterInfo(characterId);
if (character.skillOrder.some((skillId) => skillIds.has(skillId)))
result.push(character);
}
});
return result;
}
getWeaponIdsByMaterialIds(materialIds) {
const result = new Set();
Weapon_1.Weapon.allWeaponIds.forEach((weaponId) => {
const maxPromoteLevel = WeaponAscension_1.WeaponAscension.getMaxPromoteLevelByWeaponId(weaponId);
for (let promoteLevel = 1; promoteLevel <= maxPromoteLevel; promoteLevel++) {
const weapon = new WeaponAscension_1.WeaponAscension(weaponId, promoteLevel);
const costMaterialIds = weapon.costItems.map((item) => item.id);
if (costMaterialIds.some((id) => materialIds.includes(id))) {
result.add(weaponId);
break;
}
}
});
return Array.from(result);
}
}
exports.DailyFarming = DailyFarming;
_a = DailyFarming;
/**
* Map of dungeon entry ID and text map ID
*/
DailyFarming.replaceTextMapIdMap = {
50: 'UI_DUNGEON_ENTRY_37',
135: 'UI_DUNGEON_ENTRY_52',
44: 'UI_DUNGEON_ENTRY_29',
131: 'UI_DUNGEON_ENTRY_46',
};
(() => {
Client_1.Client._addExcelBinOutputKeyFromClassPrototype(_a.prototype);
})();