Slow and Steady
6/1/25
Greetings Foolish Ones!
Since my last update, I've looked further into how to acquire cards and validate them when adding them to my deck. Using ChatGPT, I learned that I can actually use an API from Scryfall (scryfall.com is my go to card search engine online). I'll admit, I needed chatGPT to show me how to call from the API and get back card data. But I try to use chatGPT as a learning tool, and I think that's something I want to go over in this entry. You've probably heard the term "Vibe Coding" floating around recently. The idea is that instead of manually coding, programmers simply ask an AI to build the code, and then work out any bugs the AI might have made. I think this is likely the way most programmers will code moving forward. However, I think it's important for people who are still learning to make sure we don't heavily rely on AI for our code. Similarly, those like myself who enjoy coding as a hobby or "art" should try (and fail a lot) before we ask AI to figure it out. Think of it like using a calculator. While you can easily punch in an equation and get an answer, it doesn't mean you actually understand what's going on under the hood. Don't rush to find answers, allow yourself to fail and use each failure as a learning opportunity.
Instead, if you are having trouble solving a problem, ask your AI bot if they can provide a solution and explain it step by step. For the case of the API, chatGPT gave me instructions on how to make an API call to Scryfall by providing a card name. I took that code and implemented it into my program. I removed my homemade card validator, and instead I have the new function print out the information it gathers from the API call, and allow the user to decide if that's the correct card to add to their decklist. I also learned about a new string function, "fuzzy". Using fuzzy in the API call allows the program to match the given name string with a similar string if it can't find an exact match. This means I can potentially find a card even if I don't remember the full name or correct spelling.
In between learning the API call and working on my main program, I also built two small programs to help make things look a little nicer. The first program allows you to input a string and a color, and prints out the string in that chosen color on the terminal. Down the line, I plan on implementing this by color coding cards based on their category. This should help the user visualize their deck by categories, and quickly find cards in those categories when making edits. In this case, I did not ask AI for the answer, but instead my good pal Google. Google brought me to a page that taught me about ANSI escape sequences. I'll post the link below. This is a great small project to learn about string concatenation (combining 2 or more strings together) and escape sequences.
ANSI COLOR CODESNext, I designed a program that takes an ASCII image, converts it into a string, and passes it through the color program to create a colored logo. This program is then called in the main deckbuilder program at the start. What I like about making these smaller programs (some might call them modules) is that they can be implemented in future projects as well. It's like building your own small library of functions that you can take along on your coding adventures. They're great to work on when you get stuck on your bigger project, and give a nice sense of accomplishment that can help you push through when you're unmotivated.
I'll provide the source code for all 3 programs. At this point, my deck builder can now create a deck txt file, add cards to a list, and then save that list to the deck txt file. My next task is to load an existing deck into the program, as well as allow the user to edit a deck so they can remove cards. Once that is done, I'll move on to adding card categories, and running statistics such as average mana cost and number of card types. But until then...