
I'm slowly making progress on Forge version 2. Right now it has 11 classes, 102 methods, 117 lines of comments and 280 lines of code. There are a high number of comments because I am trying to be very thorough for myself and for whoever else that may read and update my code in the future. (And yes, the title of this article references Star Wars Episode IV, you know the GOOD "Star Wars".)
Counting the total number of lines of code (loc) for a project gives you a rough estimation on how big and complex the project is. The loc for any project can be calculated many different ways. I wrote my own little program that only counted "real" lines of code. I defined a "real" line of code to be
1. Not a comment.
2. Not whitespace.
3. Not a bracket {}, since I put brackets on separate lines.
Basically the code for version 2 just generates all of the phases for both players. While this seems trivial it is not. Each player's turn has approximately 28 phases which are listed below.
The phase array is a two-dimensional array of Strings. Index 0 is the active player (the player who's turn it is), index 1 is the player who has priority (can cast a card or activate an ability), and index 2 is the phase name. In order to generate the computer's phases I just swap the Human and Computer players, which are just Strings.
Some of these "phases" are technically steps but it doesn't matter because the mana pool empties at the end of every phase and step. Forge version 1 and 2 have the phases "Declare Blockers" and "After Declare Blockers". A few of these phases are "artificial" and don't officially exist such as "After Declare Blockers", which is when Forge lets players play cards. On a side note, I will have to make sure that the mana pool empties according to the rules and the "artificial" phases don't cause any problems.
Magic has million tiny details and technically during the untap and cleanup phases no player gets priority. For the untap and cleanup phases maybe I should use an empty string "" for the priority player.
final String Human = "Human";
final String Computer = "Computer";
private String humanTurn[][] =
{
//active player, priority player, phase name
//
{Human, Human, Constant.PhaseName.Untap},
{Human, Human , Constant.PhaseName.Upkeep},
{Human, Computer, Constant.PhaseName.Upkeep},
{Human, Human , Constant.PhaseName.Draw},
{Human, Computer, Constant.PhaseName.Draw},
{Human, Human , Constant.PhaseName.Main1},
{Human, Computer, Constant.PhaseName.Main1},
{Human, Human , Constant.PhaseName.Begin_Combat},
{Human, Computer, Constant.PhaseName.Begin_Combat},
{Human, Human, Constant.PhaseName.Attack},
{Human, Human , Constant.PhaseName.Attack_After},
{Human, Computer, Constant.PhaseName.Attack_After},
{Human, Computer, Constant.PhaseName.Block},
{Human, Human , Constant.PhaseName.Block_After},
{Human, Computer, Constant.PhaseName.Block_After},
{Human, Human , Constant.PhaseName.Combat_Damage},
{Human, Computer, Constant.PhaseName.Combat_Damage},
{Human, Human , Constant.PhaseName.End_Combat},
{Human, Computer, Constant.PhaseName.End_Combat},
{Human, Human , Constant.PhaseName.Main2},
{Human, Computer, Constant.PhaseName.Main2},
{Human, Human , Constant.PhaseName.At_EOT},
{Human, Computer, Constant.PhaseName.At_EOT},
{Human, Human , Constant.PhaseName.EOT},
{Human, Computer, Constant.PhaseName.EOT},
{Human, Human , Constant.PhaseName.Until_EOT},
{Human, Computer, Constant.PhaseName.Until_EOT},
{Human, Human, Constant.PhaseName.Cleanup}
};