diff --git a/SettingsTemplate.yaml b/SettingsTemplate.yaml index e791d05..f673c6f 100644 --- a/SettingsTemplate.yaml +++ b/SettingsTemplate.yaml @@ -11,6 +11,11 @@ body: - German - Portuguese - Italian + - type: checkbox + attributes: + name: showMDRarity + label: Show Master Duel Rarity + defaultValue: "false" - type: textBlock attributes: description: >- diff --git a/package-lock.json b/package-lock.json index a7a7d21..0279c2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ygo-card-search", - "version": "1.1.1", + "version": "1.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ygo-card-search", - "version": "1.1.1", + "version": "1.1.3", "dependencies": { "node-fetch": "^3.3.2", "open": "9.1.0", diff --git a/package.json b/package.json index 5b4d528..b15e560 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ygo-card-search", - "version": "1.1.2", + "version": "1.1.3", "description": "Plugin for Flow Launcher that searches for Yu-Gi-Oh! cards on ygoprodeck.com", "main": "./src/main.js", "repository": { diff --git a/plugin.json b/plugin.json index 45fb575..392aa1e 100644 --- a/plugin.json +++ b/plugin.json @@ -4,7 +4,7 @@ "Name": "Yu-Gi-Oh! card search", "Description": "Searches for Yu-Gi-Oh! cards on ygoprodeck.com", "Author": "pivotiiii", - "Version": "1.1.2", + "Version": "1.1.3", "Language": "JavaScript", "Website": "https://github.com/pivotiiii/flow_launcher_ygo", "ExecuteFileName": "src\\main.js", diff --git a/src/main.js b/src/main.js index 656ae5a..5bf6bf4 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,13 @@ const cachePath = path.resolve(__dirname, "cache"); const maxResults = 5; const cacheImageDimensions = Math.floor(getCurrentResolution().height / 20); +const MDRaritiesMap = { + Common: "C", + Rare: "R", + "Super Rare": "SR", + "Ultra Rare": "UR", +}; + const {method, parameters, settings} = JSON.parse(process.argv[2]); if (method === "query") { @@ -39,8 +46,9 @@ async function getCards(query) { const [apiUrlQuery, apiUrlOptions] = parseQuery(query); let apiUrlLang = getLang(); const apiUrlNum = `&num=${maxResults}&offset=0`; + const apiUrlMisc = settings.showMDRarity === true ? "&misc=yes" : ""; - const apiUrl = apiUrlBase + apiUrlQuery + apiUrlOptions + apiUrlLang + apiUrlNum; + const apiUrl = apiUrlBase + apiUrlQuery + apiUrlOptions + apiUrlLang + apiUrlNum + apiUrlMisc; //console.log(apiUrl); const response = await fetch(apiUrl); @@ -53,6 +61,7 @@ async function getCards(query) { const cards = []; responseJson["data"].forEach(function (card) { + const saveMDRarity = settings.showMDRarity === true && "md_rarity" in card["misc_info"][0]; cards.push({ name: card["name"], type: card["type"], @@ -65,6 +74,7 @@ async function getCards(query) { url: card["ygoprodeck_url"], img: card["card_images"][0]["image_url_small"], id: card["id"], + md_rarity: saveMDRarity === true ? card["misc_info"][0]["md_rarity"] : undefined, }); }); @@ -106,6 +116,10 @@ function getCardResult(card, imagePath) { result.Subtitle = `${card.race} ${card.type}`; } + if (card.md_rarity !== undefined) { + result.Subtitle = `(${MDRaritiesMap[card.md_rarity] || "?"}) | ${result.Subtitle}`; + } + return result; }