import React from "react"; import { Box, VStack } from "@chakra-ui/react"; import { WarningTwoIcon } from "@chakra-ui/icons"; import { FaBug } from "react-icons/fa"; import { GlitchBadgeLayout, layerUsesHTML5 } from "../components/HTML5Badge"; function OutfitKnownGlitchesBadge({ appearance }) { const glitchMessages = []; const { petAppearance, items } = appearance; // Look for UC/Invisible/etc incompatibilities that we hid, that we should // just mark Incompatible someday instead. // // HACK: Most of this logic is copy-pasted from `useOutfitAppearance`. const petOccupiedZoneIds = new Set( petAppearance?.layers.map((l) => l.zone.id) ); const petRestrictedZoneIds = new Set( petAppearance?.restrictedZones.map((z) => z.id) ); const petOccupiedOrRestrictedZoneIds = new Set([ ...petOccupiedZoneIds, ...petRestrictedZoneIds, ]); for (const item of items) { const itemHasZoneRestrictedByPet = item.appearance.layers.some( (layer) => layer.bodyId !== "0" && petOccupiedOrRestrictedZoneIds.has(layer.zone.id) ); if (itemHasZoneRestrictedByPet) { glitchMessages.push( {item.name} isn't actually compatible with this special pet. We're still showing the old behavior, which is to hide the item. Fixing this is in our todo list, sorry for the confusing UI! ); } } // Look for items with the OFFICIAL_SWF_IS_INCORRECT glitch. for (const item of items) { const itemHasBrokenOnNeopetsDotCom = item.appearance.layers.some((l) => (l.knownGlitches || []).includes("OFFICIAL_SWF_IS_INCORRECT") ); const itemHasBrokenUnconvertedLayers = item.appearance.layers.some( (l) => (l.knownGlitches || []).includes("OFFICIAL_SWF_IS_INCORRECT") && !layerUsesHTML5(l) ); if (itemHasBrokenOnNeopetsDotCom) { glitchMessages.push( {itemHasBrokenUnconvertedLayers ? ( <> We're aware of a glitch affecting the art for {item.name}. Last time we checked, this glitch affected its appearance on Neopets.com, too. Hopefully this will be fixed once it's converted to HTML5! ) : ( <> We're aware of a previous glitch affecting the art for{" "} {item.name}, but it might have been resolved during HTML5 conversion. Please use the feedback form on the homepage to let us know if it looks right, or still looks wrong! Thank you! )} ); } } // Look for items with the OFFICIAL_SVG_IS_INCORRECT glitch. for (const item of items) { const itemHasOfficialSvgIsIncorrect = item.appearance.layers.some((l) => (l.knownGlitches || []).includes("OFFICIAL_SVG_IS_INCORRECT") ); if (itemHasOfficialSvgIsIncorrect) { glitchMessages.push( There's a glitch in the art for {item.name} that prevents us from showing the full-scale SVG version of the image. Instead, we're showing a PNG, which might look a bit blurry on larger screens. ); } } // Look for items with the OFFICIAL_BODY_ID_IS_INCORRECT glitch. for (const item of items) { const itemHasOfficialBodyIdIsIncorrect = item.appearance.layers.some((l) => (l.knownGlitches || []).includes("OFFICIAL_BODY_ID_IS_INCORRECT") ); if (itemHasOfficialBodyIdIsIncorrect) { glitchMessages.push( Last we checked, {item.name} actually is compatible with this pet, even though it seems like it shouldn't be. But TNT might change this at any time, so be careful! ); } } // Look for Dyeworks items that aren't converted yet. for (const item of items) { const itemIsDyeworks = item.name.includes("Dyeworks"); const itemIsConverted = item.appearance.layers.every(layerUsesHTML5); if (itemIsDyeworks && !itemIsConverted) { glitchMessages.push( {item.name} isn't converted to HTML5 yet, and our Classic DTI code often shows old Dyeworks items in the wrong color. Once it's converted, we'll display it correctly! ); } } // Check whether the pet is Invisible. If so, we'll show a blanket warning. if (petAppearance?.color?.id === "38") { glitchMessages.push( // NOTE: This message assumes that the current pet appearance is the // best canonical one, but it's _possible_ to view Glitched // appearances even if we _do_ have a better one saved... but // only the Support UI ever takes you there. Invisible pets are affected by a number of glitches, including faces sometimes being visible on-site, and errors in the HTML5 conversion. If this pose looks incorrect, you can try another by clicking the emoji face to the right. But be aware that Neopets.com might look different! ); } // Check whether the pet appearance is marked as Glitched. if (petAppearance?.isGlitched) { glitchMessages.push( // NOTE: This message assumes that the current pet appearance is the // best canonical one, but it's _possible_ to view Glitched // appearances even if we _do_ have a better one saved... but // only the Support UI ever takes you there. We know that the art for this pet is incorrect, but we still haven't seen a correct model for this pose yet. Once someone models the correct data, we'll use that instead. For now, you could also try switching to another pose, by clicking the emoji face to the right! ); } // Check whether the pet has OFFICIAL_SVG_IS_INCORRECT. const petLayers = petAppearance?.layers || []; for (const layer of petLayers) { const layerHasOfficialSvgIsIncorrect = (layer.knownGlitches || []).includes( "OFFICIAL_SVG_IS_INCORRECT" ); if (layerHasOfficialSvgIsIncorrect) { glitchMessages.push( There's a glitch in the art for this pet's {layer.zone.label}{" "} zone that prevents us from showing the full-scale SVG version of the image. Instead, we're showing a PNG, which might look a bit blurry on larger screens. ); } } if (glitchMessages.length === 0) { return null; } return ( Known glitches {glitchMessages} } > ); } export default OutfitKnownGlitchesBadge;