Combat is essential to Magic (and most card games) and blocking is part of combat.
Forge uses the method CombatUtil.canBlock(Card attacker, Card blocker) to determine if a creature can block. The canBlock() method returns true if the blocker can block and false if it can’t. (All classes ending in “Util” are composed of global, public, static methods and “Util” stands for “utility”.)
In the beginning canBlock() only checked for flying and fear but now the method has grown to 250 lines (including whitespace). You can view the canBlock() method here. Landwalk was one of the first code snippets that was submitted. (Probably by Rob Cashwalker or DennisBergkamp.) I was impressed that landwalk could be implemented and that canBlock() was able to be modified by an outside coder.
While canBlock() is long it isn’t too hard to understand because each code segment does its test and returns false if the blocker cannot block. Each of the “if” code segments are separate and do not interact.
Here are some of the conditions that canBlock() tests for:
CARD can block only creatures with flying
CARD can't be blocked by creatures with flying
CARD can't be blocked except by creatures with flying
CARD can't be blocked by white creatures
CARD can't be blocked by Walls
CARD can block creatures with shadow as though they didn't have shadow
CARD can't block creatures with power X or greater
CARD can't block creatures with power X or less
Each of the above conditions is a string (characters that you can see) and each card holds any number of strings (which internally are called keywords). The great thing is that Forge uses the text file cards.txt to create basic creatures that have one or more of the above keywords. Forge can even create instants and activated abilities by using special “scripting” keywords. I plan to talk more about scripting in a week or two. (For more info you can view cards.txt here.)
Here are two examples that don't require any extra Java coding.
Live long and prosper,
I wasn't aware of the proliferate keyword. The card picture above is from the set "Duel Decks: Elspeth vs. Tezzeret".
Proliferate means "You choose any number of permanents and/or players with counters on them, then give each another counter of a kind already there."