forked from OpenNeo/impress-2020
Compare commits
No commits in common. "add-altStyleId" and "main" have entirely different histories.
add-altSty
...
main
2 changed files with 5 additions and 46 deletions
|
|
@ -33,12 +33,9 @@ const resolvers = {
|
|||
return null;
|
||||
}
|
||||
|
||||
const speciesId = customPetData.custom_pet.species_id;
|
||||
const baseColorId = customPetData.custom_pet.color_id;
|
||||
|
||||
const petType = await petTypeBySpeciesAndColorLoader.load({
|
||||
speciesId,
|
||||
colorId: baseColorId,
|
||||
speciesId: customPetData.custom_pet.species_id,
|
||||
colorId: customPetData.custom_pet.color_id,
|
||||
});
|
||||
const petStates = petType
|
||||
? await petStatesForPetTypeLoader.load(petType.id)
|
||||
|
|
@ -55,33 +52,8 @@ const resolvers = {
|
|||
.sort((a, b) => Number(a) - Number(b))
|
||||
.join(",");
|
||||
petState = petStates.find((ps) => ps.swfAssetIds === swfAssetIdsString);
|
||||
|
||||
// Neopets may omit these fields entirely; treat "missing" as null.
|
||||
const altStyleId = customPetData.custom_pet.alt_style;
|
||||
const altColorId = customPetData.custom_pet.alt_color;
|
||||
|
||||
if (petState) {
|
||||
return { id: petState.id, altStyleId, altColorId };
|
||||
}
|
||||
|
||||
// If that didn't work, and Neopets reported an alt color, try looking up
|
||||
// the same exact-assets pet state on the species+altColor pair.
|
||||
if (altColorId != null && altColorId !== baseColorId) {
|
||||
const altColorPetType = await petTypeBySpeciesAndColorLoader.load({
|
||||
speciesId,
|
||||
colorId: altColorId,
|
||||
});
|
||||
if (altColorPetType) {
|
||||
const altColorPetStates = await petStatesForPetTypeLoader.load(
|
||||
altColorPetType.id,
|
||||
);
|
||||
const altColorPetState = altColorPetStates.find(
|
||||
(ps) => ps.swfAssetIds === swfAssetIdsString,
|
||||
);
|
||||
if (altColorPetState) {
|
||||
return { id: altColorPetState.id, altStyleId, altColorId };
|
||||
}
|
||||
}
|
||||
return { id: petState.id };
|
||||
}
|
||||
|
||||
// Next, look for a pet state matching the same pose. (This can happen if
|
||||
|
|
@ -99,7 +71,7 @@ const resolvers = {
|
|||
`because it matches pose ${pose}. Actual pet state for these ` +
|
||||
`assets not found: ${swfAssetIdsString}`,
|
||||
);
|
||||
return { id: petState.id, altStyleId, altColorId };
|
||||
return { id: petState.id };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +85,7 @@ const resolvers = {
|
|||
`as an UNKNOWN fallback pose. Actual pet state for these ` +
|
||||
`assets not found: ${swfAssetIdsString}`,
|
||||
);
|
||||
return { id: petState.id, altStyleId, altColorId };
|
||||
return { id: petState.id };
|
||||
}
|
||||
|
||||
// If we still don't have a pet state, raise an error. (This can happen
|
||||
|
|
|
|||
|
|
@ -78,18 +78,6 @@ const typeDefs = gql`
|
|||
"""
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
The ID of the alt style used to render this appearance, if any.
|
||||
Null when this appearance is not using an alt style.
|
||||
"""
|
||||
altStyleId: ID
|
||||
|
||||
"""
|
||||
The ID of the alt color used to render this appearance, if any.
|
||||
Null when this appearance is not using an alt style.
|
||||
"""
|
||||
altColorId: ID
|
||||
|
||||
species: Species!
|
||||
color: Color!
|
||||
pose: Pose!
|
||||
|
|
@ -285,7 +273,6 @@ const resolvers = {
|
|||
},
|
||||
|
||||
PetAppearance: {
|
||||
altColorId: ({ altColorId }) => (altColorId),
|
||||
id: ({ id, altStyleId }) => {
|
||||
if (altStyleId != null) {
|
||||
return `${id}-with-alt-style-${altStyleId}`;
|
||||
|
|
|
|||
Loading…
Reference in a new issue