My ui skills (and still are) limited and I didn’t know how to show a tapped card. At the time cards on the battlefield were displayed only as colored boxes, which you can see if Forge cannot find the card picture. My solution was to stick the word “tapped” inside of the colored box. In a way it was very ugly but at least the user wouldn’t confuse tapped and untapped cards.
After I got a basic ui working, I knew that I needed a strategy to handle the mouse and it was going to be a pain in the neck. How was I supposed to restrict targeting possibilities for cards like Terror – no black or artifact creatures or Assissinate – destroy target tapped creature? And how do I combine the card code and the mouse code? Thankfully I found the state pattern. At first the state pattern was a little hard to understand (grok) but after writing some simple code and running it, everything made perfect sense.
(I wondered how other Magic programs handled the mouse and did they also use the state pattern? More than likely they didn’t but I have no idea how to handle the mouse without using the state pattern. You can read more about the state pattern and how I applied it to the mouse here, here and here.)
After I got a basic user interface and mouse working, I added the phases which only consisted of a message stating the phase name. Just clicking the OK button and watching Forge cycle through the phases was very exciting even though the program didn’t actually do anything yet. After that I worked on the card class and the “card detail window” which is on the right side and shows all of the card information. (Ideally the card picture would be created on-the-fly like Magic Online and would have all of correct text information like if your creature was pumped up with Giant Growth.)
Even though the user could see all of the card information, without seeing the actual card picture the user interface was especially bland. Since I couldn’t display the card picture on the battlefield because I didn’t know how, I had the bright idea to show the card picture in a panel by itself. While this was only a small step, it really made Forge seem like a real program.
Tanks for reading,
--Actually I did know how to resize the card pictures and put them on the battlefield but I couldn’t figure out how to rotate them. Thankfully, after a few months somebody sent me a nifty one line fix.
--I tried to use as many design patterns as I could. “End of turn” effects used the command pattern. The quest data was saved using the memento pattern. My advice is to always save data as primitives (ints, Strings) instead of saving whole objects. That way when you want to change how your data is saved, you can easily read the primitives versus trying to read an older version of an object.
--Forge is probably my 4th iteration at programming Magic. The first three projects collapsed because of fundamental archetecture problems.