Closed dylanpiera closed 1 year ago
Would you like to share how to run the importer you wrote about? Then I would start looking into things.
a little progress
The following snippet
shows there are 273 slugs in species for which no item with a name exists that resolves to the slug in there
async function getFixes() {
const nonptr = ["Fangame Insurgence Dex", "Fangame Uranium Dex", "Fangame Sage Dex", ""];
const stuff = ["abilities", "feats", "items", "species", "moves", "capabilities", "effects", "poke-edges"]
const freshDic = {}
const oldDic = {}
for (const cat of stuff) {
freshDic[cat] = {}
oldDic[cat] = {}
const items = await game.packs.get(`ptu.${cat}`).getDocuments();
for (const item of items) {
freshSlug = CONFIG.PTU.util.sluggify(item.name)
freshDic[cat][freshSlug] = item
oldDic[cat][item.slug] = item
}
}
const changeProposals = {}
const emptyChangeProposals = () => {
return {
abilities: {
basic: [],
advanced: [],
high: []
},
capabilities: {
other: []
},
evolutions: [],
moves: {
egg: [],
level: [],
machine: [],
tutor: [],
}
}
}
const notInOld = []
const notInFresh = []
let fixed = 0
const fanMons = (await game.packs.get(`ptu.species`).getDocuments()).filter(sp => nonptr.includes(sp.system?.source?.value))
for (const mon of fanMons) {
const cp = emptyChangeProposals()
//abilities
for (const tier of ["basic", "advanced", "high"]) {
for (const ab of mon.system.abilities[tier]) {
if (!ab.uuid) {
const oldP = oldDic["abilities"][ab.slug];
if (oldP){
cp.abilities[tier].push(oldP)
fixed += 1;
continue
}
notInOld.push({monN: mon.name, whatN: ab.slug, cat:"abilities", mon: mon})
const freshP = freshDic["abilities"][ab.slug];
if (freshP){
cp.abilities[tier].push(oldP)
fixed += 1;
continue
}
notInFresh.push({monN: mon.name, whatN: ab.slug, cat:"abilities", mon: mon})
}
}
}
//moves
for (const src of ["egg", "level", "machine", "tutor"]) {
for (const move of mon.system.moves[src]) {
if (!move.uuid) {
const oldP = oldDic["moves"][move.slug];
if (oldP){
cp.moves[src].push(oldP)
fixed += 1;
continue
}
notInOld.push({monN: mon.name, whatN: move.slug, cat:"moves", mon: mon})
const freshP = freshDic["moves"][move.slug];
if (freshP){
cp.moves[src].push(oldP)
fixed += 1;
continue
}
notInFresh.push({monN: mon.name, whatN: move.slug, cat:"moves", mon: mon})
}
}
}
// other capabilities
for (const cap of mon.system.capabilities.other) {
if (!cap.uuid) {
const oldP = oldDic["capabilities"][cap.slug];
if (oldP){
cp.capabilities.other.push(oldP)
fixed += 1;
continue
}
notInOld.push({monN: mon.name, whatN: cap.slug, cat:"capabilities", mon: mon})
const freshP = freshDic["capabilities"][cap.slug];
if (freshP){
cp.capabilities.other.push(oldP)
fixed += 1;
continue
}
notInFresh.push({monN: mon.name, whatN: cap.slug, cat:"capabilities", mon: mon})
}
}
// evolutions
for (const evo of mon.system.evolutions) {
if (!evo.uuid) {
const oldP = oldDic["species"][evo.slug];
if (oldP){
cp.evolutions.push(oldP)
fixed += 1;
continue
}
notInOld.push({monN: mon.name, whatN: evo.slug, cat:"species", mon: mon})
const freshP = freshDic["species"][evo.slug];
if (freshP){
cp.evolutions.push(oldP)
fixed += 1;
continue
}
notInFresh.push({monN: mon.name, whatN: evo.slug, cat:"species", mon: mon})
}
}
changeProposals[mon.uuid] = cp
}
console.log(fixed)
console.warn(notInOld)
console.error(notInFresh)
return changeProposals
}
//((await getBadlySlugged()).map(x => x.name) //deltaRos = fromUuidSync("Compendium.ptu.species.Item.H7siLUqPoZEiaFIu") await getFixes();
Pimped the thing before. This should come in handy in the future
Creates three dicts with potential fixes, what is not found using preexisting slug and what is not found using fresh slugs of item names.
async function getFixes() {
const nonPtrSources = ["Fangame Insurgence Dex", "Fangame Uranium Dex", "Fangame Sage Dex", ""];
const itemTypes = ["abilities", "feats", "items", "species", "moves", "capabilities", "effects", "poke-edges"]
const freshDic = {}
const oldDic = {}
for (const cat of itemTypes) {
freshDic[cat] = {}
oldDic[cat] = {}
const items = await game.packs.get(`ptu.${cat}`).getDocuments();
for (const item of items) {
const freshSlug = CONFIG.PTU.util.sluggify(item.name)
freshDic[cat][freshSlug] = item
oldDic[cat][item.slug] = item
}
}
const changeProposals = {}
const notInOld = {}
const notInFresh = {}
let fixed = 0
const fanMons = (await game.packs.get(`ptu.species`).getDocuments()).filter(sp => ! nonPtrSources.includes(sp.system?.source?.value))
for (const mon of fanMons) {
const prevFixed = fixed;
const cp = {};
const cpO = {};
const cpF = {};
//abilities
for (const tier of ["basic", "advanced", "high"]) {
for (const ab of mon.system.abilities[tier]) {
if (!ab.uuid) {
const oldP = oldDic["abilities"][ab.slug];
if (oldP) {
if(!cp[`${tier}Abilities`])
cp[`${tier}Abilities`] = []
cp[`${tier}Abilities`].push(oldP)
fixed += 1;
continue
}
if(!cpO[`${tier}Abilities`])
cpO[`${tier}Abilities`] = []
cpO[`${tier}Abilities`].push(ab.slug)
const freshP = freshDic["abilities"][ab.slug];
if (freshP) {
if(!cp[`${tier}Abilities`])
cp[`${tier}Abilities`] = []
cp[`${tier}Abilities`].push(freshP)
fixed += 1;
continue
}
if(!cpF[`${tier}Abilities`])
cpF[`${tier}Abilities`] = []
cpF[`${tier}Abilities`].push(ab.slug)
}
}
}
//moves
for (const src of ["egg", "level", "machine", "tutor"]) {
for (const move of mon.system.moves[src]) {
if (!move.uuid) {
const oldP = oldDic["moves"][move.slug];
if (oldP) {
if(!cp[`${src}Moves`])
cp[`${src}Moves`] = []
cp[`${src}Moves`].push(oldP)
fixed += 1;
continue
}
if(!cpO[`${src}Moves`])
cpO[`${src}Moves`] = []
cpO[`${src}Moves`].push(move.slug)
const freshP = freshDic["moves"][move.slug];
if (freshP) {
if(!cp[`${src}Moves`])
cp[`${src}Moves`] = []
cp[`${src}Moves`].push(freshP)
fixed += 1;
continue
}
if(!cpF[`${src}Moves`])
cpF[`${src}Moves`] = []
cpF[`${src}Moves`].push(move.slug)
}
}
}
// other capabilities
for (const cap of mon.system.capabilities.other) {
if (!cap.uuid) {
if (cap.slug.startsWith("mountable-"))
continue
const oldP = oldDic["capabilities"][cap.slug];
if (oldP) {
if(!cp.capabilities)
cp.capabilities = []
cp.capabilities.push(oldP)
fixed += 1;
continue
}
if(!cpO.capabilities)
cpO.capabilities = []
cpO.capabilities.push(cap.slug)
const freshP = freshDic["capabilities"][cap.slug];
if (freshP) {
if(!cp.capabilities)
cp.capabilities = []
cp.capabilities.push(freshP)
fixed += 1;
continue
}
if(!cpF.capabilities)
cpF.capabilities = []
cpF.capabilities.push(cap.slug)
}
}
// evolutions
for (const evo of mon.system.evolutions) {
if (!evo.uuid) {
const oldP = oldDic["species"][evo.slug];
if (oldP) {
if(!cp.evolutions)
cp.evolutions = []
cp.evolutions.push(oldP)
fixed += 1;
continue
}
if(!cpO.evolutions)
cpO.evolutions = []
cpO.evolutions.push(evo.slug)
const freshP = freshDic["species"][evo.slug];
if (freshP) {
if(!cp.evolutions)
cp.evolutions = []
cp.evolutions.push(freshP)
fixed += 1;
continue
}
if(!cpF.evolutions)
cpF.evolutions = []
cpF.evolutions.push(evo.slug)
}
}
const id = mon.name
if (Object.keys(cp).length > 0)
changeProposals[id] = cp
if (Object.keys(cpO).length > 0)
notInOld[id] = cpO
if (Object.keys(cpF).length > 0)
notInFresh[id] = cpF
}
console.warn(notInOld)
console.error(notInFresh)
return changeProposals
}
await getFixes();
Current (4.0.3) issues not fixable through my script so far <.<
broken_fandex.json broken_ptrdex.json
And here 37 species with 46 errors such that you can map a unlinked item in the species through looking up its slug.
newest version of check for mangled species
async function getFixes() {
const nonPtrSources = ["Fangame Insurgence Dex", "Fangame Uranium Dex", "Fangame Sage Dex", ""];
const itemTypes = ["abilities", "feats", "items", "species", "moves", "capabilities", "effects", "poke-edges"]
const freshDic = {}
const oldDic = {}
for (const cat of itemTypes) {
freshDic[cat] = {}
oldDic[cat] = {}
const items = await game.packs.get(`ptu.${cat}`).getDocuments();
for (const item of items) {
const freshSlug = CONFIG.PTU.util.sluggify(item.name)
freshDic[cat][freshSlug] = item
oldDic[cat][item.slug] = item
}
}
const changeProposals = {}
const notInOld = {}
const notInFresh = {}
const allScrewed = {}
let fixed = 0
const fanMons = (await game.packs.get(`ptu.species`).getDocuments())//.filter(sp => nonPtrSources.includes(sp.system?.source?.value))
for (const mon of fanMons) {
const prevFixed = fixed;
const cp = {};
const cpO = {};
const cpF = {};
const screwed = {};
//abilities
for (const tier of ["basic", "advanced", "high"]) {
for (const ab of mon.system.abilities[tier]) {
if (!ab.uuid) {
if(!screwed[`${tier}Abilities`])
screwed[`${tier}Abilities`] = []
screwed[`${tier}Abilities`].push(ab.slug)
const oldP = oldDic["abilities"][ab.slug];
if (oldP) {
if(!cp[`${tier}Abilities`])
cp[`${tier}Abilities`] = []
cp[`${tier}Abilities`].push(oldP)
fixed += 1;
continue
}
if(!cpO[`${tier}Abilities`])
cpO[`${tier}Abilities`] = []
cpO[`${tier}Abilities`].push(ab.slug)
const freshP = freshDic["abilities"][ab.slug];
if (freshP) {
if(!cp[`${tier}Abilities`])
cp[`${tier}Abilities`] = []
cp[`${tier}Abilities`].push(freshP)
fixed += 1;
continue
}
if(!cpF[`${tier}Abilities`])
cpF[`${tier}Abilities`] = []
cpF[`${tier}Abilities`].push(ab.slug)
}
}
}
//moves
for (const src of ["egg", "level", "machine", "tutor"]) {
for (const move of mon.system.moves[src]) {
if (!move.uuid) {
if(!screwed[`${src}Moves`])
screwed[`${src}Moves`] = []
screwed[`${src}Moves`].push(move.slug)
const oldP = oldDic["moves"][move.slug];
if (oldP) {
if(!cp[`${src}Moves`])
cp[`${src}Moves`] = []
cp[`${src}Moves`].push(oldP)
fixed += 1;
continue
}
if(!cpO[`${src}Moves`])
cpO[`${src}Moves`] = []
cpO[`${src}Moves`].push(move.slug)
const freshP = freshDic["moves"][move.slug];
if (freshP) {
if(!cp[`${src}Moves`])
cp[`${src}Moves`] = []
cp[`${src}Moves`].push(freshP)
fixed += 1;
continue
}
if(!cpF[`${src}Moves`])
cpF[`${src}Moves`] = []
cpF[`${src}Moves`].push(move.slug)
}
}
}
// other capabilities
for (const cap of mon.system.capabilities.other) {
if (!cap.uuid) {
if (cap.slug.startsWith("mountable-"))
continue
if(!screwed.capabilities)
screwed.capabilities = []
screwed.capabilities.push(cap.slug)
const oldP = oldDic["capabilities"][cap.slug];
if (oldP) {
if(!cp.capabilities)
cp.capabilities = []
cp.capabilities.push(oldP)
fixed += 1;
continue
}
if(!cpO.capabilities)
cpO.capabilities = []
cpO.capabilities.push(cap.slug)
const freshP = freshDic["capabilities"][cap.slug];
if (freshP) {
if(!cp.capabilities)
cp.capabilities = []
cp.capabilities.push(freshP)
fixed += 1;
continue
}
if(!cpF.capabilities)
cpF.capabilities = []
cpF.capabilities.push(cap.slug)
}
}
// evolutions
for (const evo of mon.system.evolutions) {
if (!evo.uuid) {
if(!screwed.evolutions)
screwed.evolutions = []
screwed.evolutions.push(evo.slug)
const oldP = oldDic["species"][evo.slug];
if (oldP) {
if(!cp.evolutions)
cp.evolutions = []
cp.evolutions.push(oldP)
fixed += 1;
continue
}
if(!cpO.evolutions)
cpO.evolutions = []
cpO.evolutions.push(evo.slug)
const freshP = freshDic["species"][evo.slug];
if (freshP) {
if(!cp.evolutions)
cp.evolutions = []
cp.evolutions.push(freshP)
fixed += 1;
continue
}
if(!cpF.evolutions)
cpF.evolutions = []
cpF.evolutions.push(evo.slug)
}
}
const id = mon.name
if (Object.keys(screwed).length > 0)
allScrewed[id] = screwed
if (Object.keys(cp).length > 0)
changeProposals[id] = cp
if (Object.keys(cpO).length > 0)
notInOld[id] = cpO
if (Object.keys(cpF).length > 0)
notInFresh[id] = cpF
}
console.log(fixed)
console.warn(notInOld)
console.error(notInFresh)
return allScrewed
}
JSON.stringify(await getFixes());
Currently all fangame species have fully broken links in them.
I decided to try to run the automated importer just for Abilities and already noticed a ton of abilities are incorrect / not present
For now this fix is paused until someone has time to go through all of these and add the missing entries.