splatoon3api
Version:
A simple Method to get current and next Splatoon 3 maps, Salmonrun Schedules and Splatnet gear
71 lines (70 loc) • 3.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = parseSplatnetGear;
function parseSplatnetGear(json, translation) {
var _a;
let data = {};
const featuredBrand = json.data.gesotown.pickupBrand;
data.featuredBrand = {
name: translation.brands[featuredBrand.brand.id].name,
banner: featuredBrand.image.url,
usualPower: {
name: (_a = translation.powers[featuredBrand.brand.usualGearPower.__splatoon3ink_id]) === null || _a === void 0 ? void 0 : _a.name,
image: featuredBrand.brand.usualGearPower.image.url
},
saleEnd: featuredBrand.saleEndTime,
brandGears: []
};
featuredBrand.brandGears.forEach((gear) => {
var _a;
data.featuredBrand.brandGears.push({
name: translation.gear[gear.gear.__splatoon3ink_id].name,
type: translation.gearType[gear.gear.__typename],
image: gear.gear.image.url,
primaryGearPower: {
name: (_a = translation.powers[gear.gear.primaryGearPower.__splatoon3ink_id]) === null || _a === void 0 ? void 0 : _a.name,
image: gear.gear.primaryGearPower.image.url
},
additionalGearPowers: [],
price: gear.price,
saleEnd: gear.saleEndTime,
});
});
for (let i = 0; i < featuredBrand.brandGears.length; i++) {
featuredBrand.brandGears[i].gear.additionalGearPowers.forEach((power) => {
var _a;
data.featuredBrand.brandGears[i].additionalGearPowers.push({
name: (_a = translation.powers[power.__splatoon3ink_id]) === null || _a === void 0 ? void 0 : _a.name,
image: power.image.url
});
});
}
data.featuredBrand.brandGears.sort((a, b) => a.additionalGearPowers.length - b.additionalGearPowers.length);
data.limitedGear = json.data.gesotown.limitedGears.map((gearItem, index) => {
var _a, _b, _c;
return {
name: (_a = translation.gear[gearItem.gear.__splatoon3ink_id]) === null || _a === void 0 ? void 0 : _a.name,
type: translation.gearType[gearItem.gear.__typename],
image: gearItem.gear.image.url,
primaryGearPower: {
name: (_b = translation.powers[gearItem.gear.primaryGearPower.__splatoon3ink_id]) === null || _b === void 0 ? void 0 : _b.name,
image: gearItem.gear.primaryGearPower.image.url
},
additionalGearPowers: gearItem.gear.additionalGearPowers.map((power) => {
var _a;
return ({
name: (_a = translation.powers[power.__splatoon3ink_id]) === null || _a === void 0 ? void 0 : _a.name,
image: power.image.url
});
}),
price: gearItem.price,
saleEnd: gearItem.saleEndTime,
brand: {
name: (_c = translation.brands[gearItem.gear.brand.id]) === null || _c === void 0 ? void 0 : _c.name,
image: gearItem.gear.brand.image.url
}
};
});
return data;
}
;