Magic: The Gathering Using a Common Windows Application

     I am a Magic player. I wasn't playing that long, only about two years. It is the best card game out there in my opinion.

The drawback: It can get terribly expensive.

     You buy a pack of fifteen cards for about three dollars in hopes of getting cards that you need to build your deck. Or you spend about 100 dollars or more to buy a complete set, but you only get one of each card in the set. That leaves you to buy the other two or three copies of the card to make your deck. On top of that, the individual cards can cost a lot. Some are cheap, maybe ten or twenty cents. Others cost over 1,000 dollars!

Some people will spend a ridiculous amount of money for a good deck. I have friends who have paid over 100 dollars or more for a single deck.

 

Fools.

 

     Being pretty good with computer programming does't make me smart, but it sure does save me money on Magic cards. Don't get me wrong, of course I still buy Magic cards and enjoy playing with others that don't have my program. But at the same rate, there is no way I'm going to spend huge chunks of my paycheck just to beat some fifteen year old kid in a game of Magic. I could play online, but then I might as well buy cards, since that can become increasingly expensive as well. Preposterous.

My solution: Create a program that simulates a Magic game.

The program: Microsoft Excel.

     That was not a typo. Normal, plain, sometimes boring Microsoft Excel. With some formulas and some VBA code, this program came to fruition. I will give a brief description along the lines of how it was done. I will not give all the details for a number of reasons, one being that it can't be legal. On the other hand, I am sure that the savvy Excel users can figure it out anyway.

The story: One day, while I was at work developing an Excel application, I happened to click and drag a picture into my spreadsheet on accident (I always have multiple windows open). One of my coworkers happened to be in my office and said, "if you did that with a lot of cards, I bet you could make a program to play Magic in Excel".

      I immediately took to the idea. We both compiled the cards that we wanted to use in a game. We needed a way to draw cards at random.

The formulas: =INDEX(C2:C80,RANDBETWEEN(1,(COUNTA(C2:C80)),1)

                     =COUNTA(OFFSET($A,0,0,COUNTA($A2:$A95),1))

The A and C columns contained card numbers and the name of the card, respectiveley. The formulas randomly selects a card. VBA code then deletes that card from the "deck", renumbers the cards, and its ready to go again with another click of the "Draw Card" button. The decks never have to be shuffled, since cards are randomly picked.

     The actual picture of the card then shows up in the respective player's "Hand" zone. Besides actually holding the cards, all of the mechanics of an actual Magic game is there. There are key stroke for tapping and untapping, and other more complicated aspects of the game like attaching equipment or enchantment cards to creatures. These more complicated aspects took some complicated code; and the first few bugs consisted of cards going into the correct hands and the correct creature coming into play. As for keeping each players hand concealed, we use my dual monitor setup and position the Excel page and the monitors such that each player cannot see the other's hand.

     This project took about a week. But now I have unlimited access to any Magic card I want. I can build limitless decks with any cards I want. All for free. Though, again, this can't be legal.

     The program works and looks great, but it does take a little away from actually playing the game. Some things you just can't do. For instance, some cards say "Each player plays with the top card of his deck revealed".  This can't be done because all cards are randomized with the drawing of a card. Also, removing an entire deck from the game is just not possible without blowing serious holes in the framework of the programming.

     But, even with its faults, its great for a quick game of Magic on our lunch break and an awesome testament to the power of Microsoft Excel. If anyone wants more information, you can contact me, but I won't give all the information on how it was done.