From 6b8ff80ca70a900c96842f9f250e62f933763a51 Mon Sep 17 00:00:00 2001 From: Suitangi Uil Date: Mon, 12 Aug 2024 18:06:18 -0700 Subject: [PATCH] Added TCGPlayer URL --- README.md | 15 +++++++++++---- scripts/index.js | 37 ++++++++++++++++++++++++------------- styles/index.css | 14 ++++++++++++++ 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index e74dd4a..5636191 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ A Magic: The Gathering card art letter guessing game similar to Hangman. With da [![Page Deployment](https://github.com/suitangi/Befuddle/actions/workflows/static.yml/badge.svg)](https://github.com/suitangi/Befuddle/actions/workflows/static.yml) -# Updating Befuddle -Run `node ./maintenance/update.js` from the root directory of the repo +© Ignatius Liu, 2024 -The script accepts the following flags: +# Updating Befuddle +Run `node ./maintenance/update.js` from the root directory of the repo. The script accepts the following flags: - `-nd` or `-nodownload`: Skips downloading the bulk data from Scryfall - `-daily`: Adds 50 days to the Daily mode -Then commit the changes. +Then commit/push the changes. # Todo: @@ -33,8 +33,15 @@ Then commit the changes. - For beta testing and for helping conceptualize the idea, the one an only [G-Jayakar](https://github.com/G-Jayakar). - Beta testing and pro bug finder Ksax. +# Disclaimer and Credits +Portions of Befuddle are unofficial Fan Content permitted under the Wizards of the Coast Fan Content Policy. The literal and graphical information presented on this site about Magic: The Gathering, including card images, the mana symbols, is copyright Wizards of the Coast, LLC, a subsidiary of Hasbro, Inc. Befuddle is not produced by, endorsed by, supported by, or affiliated with Wizards of the Coast. + +- Card Data and Images: [Scryfall](https://scryfall.com/) +- Font: [Wizards of the Coast](https://company.wizards.com/en) + # Changelog ``` +8/12/2024: Card update; added TCGPlayer URL to Free Mode 7/31/2024: Trimmed card database; accents are no longer free and will correspond to letters 7/29/2024: Routine card update; a couple more new Dailies; added maintenance 6/3/2024: Routine card update; new Dailies diff --git a/scripts/index.js b/scripts/index.js index 7cd4090..acfd526 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -1,5 +1,7 @@ const canVibrate = window.navigator.vibrate; -const befuddleAppVersion = "2024.7.31"; +const befuddleAppVersion = "2024.8.12"; +const tcgSVG = ''; + //Helper: Get Query function getParameterByName(name, url) { @@ -12,17 +14,6 @@ function getParameterByName(name, url) { return decodeURIComponent(results[2].replace(/\+/g, ' ')); } -//helper (mostly to clear listeners) -function recreateNode(el, withChildren) { - if (withChildren) { - el.parentNode.replaceChild(el.cloneNode(true), el); - } else { - var newEl = el.cloneNode(false); - while (el.hasChildNodes()) newEl.appendChild(el.firstChild); - el.parentNode.replaceChild(newEl, el); - } -} - //function to request random card data from scryfall api function requestCard(id) { @@ -123,6 +114,11 @@ function loadCard(data) { window.mtgCard.name = data['name']; window.mtgCard.colors = data['colors']; + if (window.game.mode == 'free') { + window.mtgCard.tcgLink = + decodeURIComponent(data['purchase_uris']['tcgplayer'].split('u=')[1]) + + '&sharedid=&irpid=5664169&irgwc=1&utm_source=impact&utm_medium=affiliate&utm_campaign=Suitangi'; + } if (multiFace.includes(window.mtgCard['layout'])) { window.mtgCard.card_faces = []; @@ -448,6 +444,13 @@ function gameLostFree() { typeAnimated: true, closeIcon: true, buttons: { + tcg: { + text: `${tcgSVG}`, + btnClass: 'tcg-btn', + action: function() { + window.open(window.mtgCard.tcgLink, '_blank').focus(); + } + }, link: { text: "Share", btnClass: 'btn-green', @@ -709,6 +712,13 @@ function gameWinFree() { typeAnimated: true, closeIcon: true, buttons: { + tcg: { + text: `${tcgSVG}`, + btnClass: 'tcg-btn', + action: function() { + window.open(window.mtgCard.tcgLink, '_blank').focus(); + } + }, link: { text: "Share", btnClass: 'btn-green', @@ -1707,7 +1717,8 @@ function loadGame() { window.dailyList = data; dailyCard(data); }) - .catch(function() { + .catch(function(e) { + console.log(e); console.error('Could not fetch daily card list'); }); } else { //no need to re-fetch diff --git a/styles/index.css b/styles/index.css index 39f8c6f..2cdf488 100644 --- a/styles/index.css +++ b/styles/index.css @@ -617,6 +617,20 @@ body { font-size: 17px; } +.tcg-btn { + background-color: #20247a !important; + padding: 1px 9px !important; +} + +.tcg-btn:hover { + background-color: #191b43 !important; +} + +.tcg-svg { + width: 29px; + transform: translateY(3px); +} + .kofi-btn { position: absolute; background: none !important;