Fix stat import
This commit is contained in:
@ -116,7 +116,7 @@ async function __findItem(itemName, itemType, location = null) {
|
||||
})
|
||||
if (pack) {
|
||||
await pack.getIndex().then(index => itemList = index);
|
||||
let searchResult = itemList.find(t => (t.translated && t.type == itemType && (t.originalName.toLowerCase() == toSearch || s.originalName.toLowerCase().split("(")[0].trim() == toSearch)) || (t.type == itemType && (t.name.toLowerCase() == toSearch || t.name.toLowerCase().split("(")[0].trim() == toSearch)));
|
||||
let searchResult = itemList.find(t => (t.translated && t.type == itemType && (t.flags?.babele?.originalName.toLowerCase() == toSearch || s.flags?.babele?.originalName.toLowerCase().split("(")[0].trim() == toSearch)) || (t.type == itemType && (t.name.toLowerCase() == toSearch || t.name.toLowerCase().split("(")[0].trim() == toSearch)));
|
||||
if (searchResult) {
|
||||
let item = await pack.getDocument(searchResult._id)
|
||||
return item.toObject()
|
||||
@ -127,8 +127,8 @@ async function __findItem(itemName, itemType, location = null) {
|
||||
// If all else fails, search each pack
|
||||
for (let p of game.wfrp4e.tags.getPacksWithTag(itemType)) {
|
||||
await p.getIndex().then(index => itemList = index);
|
||||
console.log("Seatch", itemType, toSearch);
|
||||
let searchResult = itemList.find(t => (t.translated && t.type == itemType && (t.originalName.toLowerCase() == toSearch || s.originalName.toLowerCase().split("(")[0].trim() == toSearch)) || (t.type == itemType && (t.name.toLowerCase() == toSearch || t.name.toLowerCase().split("(")[0].trim() == toSearch)));
|
||||
console.log("Seatch", itemType, toSearch, itemList);
|
||||
let searchResult = itemList.find(t => (t.translated && t.type == itemType && (t.flags?.babele?.originalName.toLowerCase() == toSearch || t.flags?.babele?.originalName.toLowerCase().split("(")[0].trim() == toSearch)) || (t.type == itemType && (t.name.toLowerCase() == toSearch || t.name.toLowerCase().split("(")[0].trim() == toSearch)));
|
||||
if (searchResult) {
|
||||
let item = await p.getDocument(searchResult._id)
|
||||
return item.toObject()
|
||||
@ -153,10 +153,10 @@ async function __findSkill(skillName, value = undefined) {
|
||||
for (let pack of packs) {
|
||||
let skillList = await pack.getIndex();
|
||||
// Search for specific skill (won't find unlisted specializations)
|
||||
let searchResult = skillList.find(s => (s.type == "skill" && s.translated && s.originalName.toLowerCase() == toSearch) || (s.type == "skill" && s.name.toLowerCase() == toSearch));
|
||||
let searchResult = skillList.find(s => (s.type == "skill" && s.translated && s.flags?.babele?.originalName.toLowerCase() == toSearch) || (s.type == "skill" && s.name.toLowerCase() == toSearch));
|
||||
if (!searchResult) {
|
||||
let toSearchClean = toSearch.split("(")[0].trim();
|
||||
searchResult = skillList.find(s => (s.type == "skill" && s.translated && s.originalName.toLowerCase().split("(")[0].trim() == toSearchClean) ||
|
||||
searchResult = skillList.find(s => (s.type == "skill" && s.translated && s.flags?.babele?.originalName.toLowerCase().split("(")[0].trim() == toSearchClean) ||
|
||||
(s.type == "skill" && s.name.toLowerCase().split("(")[0].trim() == toSearchClean));
|
||||
}
|
||||
if (searchResult) {
|
||||
@ -198,10 +198,10 @@ async function __findTalent(talentName) {
|
||||
for (let pack of packs) {
|
||||
let talentList = await pack.getIndex();
|
||||
// Search for specific talent (won't find unlisted specializations)
|
||||
let searchResult = talentList.find(s => (s.type == "talent" && s.translated && s.originalName.toLowerCase() == toSearch) || (s.type == "talent" && s.name.toLowerCase() == toSearch));
|
||||
let searchResult = talentList.find(s => (s.type == "talent" && s.translated && s.flags?.babele?.originalName.toLowerCase() == toSearch) || (s.type == "talent" && s.name.toLowerCase() == toSearch));
|
||||
if (!searchResult) {
|
||||
let toSearchClean = toSearch.split("(")[0].trim();
|
||||
searchResult = talentList.find(s => (s.type == "talent" && s.translated && s.originalName.toLowerCase().split("(")[0].trim() == toSearchClean) ||
|
||||
searchResult = talentList.find(s => (s.type == "talent" && s.translated && s.flags?.babele?.originalName.toLowerCase().split("(")[0].trim() == toSearchClean) ||
|
||||
(s.type == "talent" && s.name.toLowerCase().split("(")[0].trim() == toSearchClean));
|
||||
}
|
||||
if (searchResult) {
|
||||
@ -272,9 +272,10 @@ export default async function statParserFR(statString, type = "npc") {
|
||||
|
||||
// Extract the name
|
||||
let res1 = XRegExp.exec(statString, reg1)
|
||||
console.log("REG", res1)
|
||||
let pnjStr = statString.substring(0, res1.index)
|
||||
console.log("REG", res1, pnjStr, res)
|
||||
let nameRes = XRegExp.exec(pnjStr, regName)
|
||||
console.log("REG", nameRes, regName)
|
||||
//console.log(nameRes)
|
||||
if (nameRes.tiers && nameRes.tiers.length > 0 && hasProperty(model, "details.status.value")) {
|
||||
let regTiers = XRegExp("(?<name>[A-Za-z]*)\\s+(?<level>[0-9]*)");
|
||||
|
Reference in New Issue
Block a user