Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const names = [...$$('#all_buildings_list .castle_build_div_outside .castle_build_name_inside')].map(
- (el) => el.innerText
- );
- const levelsForGold = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) =>
- el.querySelector(
- '.castle_cost .castle_cost_line:not(:has( img[src*="diamonds"] )) .castle_amount_icon:has(img[src*="attr_level"])'
- )
- )
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const levelsForDiamonds = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) =>
- el.querySelector(
- '.castle_cost .castle_cost_line:has( img[src*="diamonds"] ) .castle_amount_icon:has(img[src*="attr_level"])'
- )
- )
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsGold = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="gold"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsOre = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="ore"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsWood = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="wood"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsMercury = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="mercury"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsSulfur = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="sulfur"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsCrystals = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="crystals"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsGems = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="gems"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const costsDiamonds = [...$$('#all_buildings_list .castle_build_div_outside')]
- .map((el) => el.querySelector('.castle_cost .castle_amount_icon:has(img[src*="diamonds"])'))
- .map((el) => el?.innerText || '')
- .map((str) => str.replaceAll(',', ''))
- .map(Number);
- const buildings = names.map((name, i) => {
- const result = {
- name,
- purchaseForGoldAndResources: {
- priceGold: costsGold[i],
- minRequiredLevelForGold: levelsForGold[i],
- },
- race: 'KNIGHT',
- };
- if (costsWood[i] || costsOre[i] || costsMercury[i] || costsSulfur[i] || costsCrystals[i] || costsGems[i]) {
- result.purchaseForGoldAndResources.priceResources = {};
- if (costsWood[i]) result.purchaseForGoldAndResources.priceResources.WOOD = costsWood[i];
- if (costsOre[i]) result.purchaseForGoldAndResources.priceResources.ORE = costsOre[i];
- if (costsMercury[i]) result.purchaseForGoldAndResources.priceResources.MERCURY = costsMercury[i];
- if (costsSulfur[i]) result.purchaseForGoldAndResources.priceResources.SULFUR = costsSulfur[i];
- if (costsCrystals[i]) result.purchaseForGoldAndResources.priceResources.CRYSTAL = costsCrystals[i];
- if (costsGems[i]) result.purchaseForGoldAndResources.priceResources.GEMS = costsGems[i];
- }
- if (costsDiamonds[i]) {
- result.purchaseForDiamonds = {
- priceDiamonds: costsDiamonds[i],
- minRequiredLevelForDiamonds: levelsForDiamonds[i],
- };
- }
- return result;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement