Thursday, September 13, 2007

Programming Planeswalkers

Wizards has been hyping planeswalkers more than the new 2008 Chevrolet Mustang (I’m pretty sure Chevrolet doesn’t make Mustangs but I just needed a snappy analogy.) In short planeswalkers come into play with loyalty counters. These counters are used to pay for the abilities on the planeswalker. One ability can be played each turn, otherwise the planeswalkers would be insane.

So far each planeswalker has one ability that adds counters to itself. Planeswalkers can be attacked, so during combat you can attack either your opponent or his planeswalker. Blocking works like normal, you can block creatures that are attacking you or your planeswalker. If a planeswalker receives any damage, then remove a counter. When all the counters are removed, put it in the graveyard. See here for the complete list of rules.

So far Liliana Vess and Garruk Wildspeaker are programmed into MTG Forge. I had some code named “Combat” that handled combat, attacking and blocking, so I just had to add a 2nd copy of the Combat code that handles creatures that are attacking/blocking the planeswalker. It probably took me 30 minutes to understand my previous rewritten combat code to figure out that it would work for planeswalker combat also. Actually I had to change one whole line so the code would work for both types of combat.

The planeswalker abilities were harder to program and each planeswalker takes up about 200 lines of code. This is the first time MTG Forge has had an ability that effectively costs 0, so I had do some fancy pants programming. The code is pretty hacked together but it works.


Restricting the abilities to once per turn also added to the messy parts of the code, but thankfully it works. The computer AI for Liliana Vess is approximately 10 lines and I was a little surprised it was that easy, thank goodness for good software design. All in all adding the extra combat and Vess and Garruk probably took around 10 hours.

1 comment:

  1. Will try it out this weekend. Thanks for another release!

    ReplyDelete

Note: Only a member of this blog may post a comment.