AllAbilities.h stores the code for most hardcoded abilities:
http://code.google.com/p/wagic/source/b ... bilities.hMTGAbilitiy.cpp currently has a part of the parser, as well as the method that creates the Abilities according to the card id. Most of the time, this creates an object defined in AllAbilities.h and adds it to the list of Abilities in the game, but for instants and sorceries, it generally does some random stuff without bothering to create a new Ability and add it to the game.
Look especially for AbilityFactory::magicText and AbilityFactory::addAbilities
http://code.google.com/p/wagic/source/b ... bility.cppTargetChooser.cpp contains the parser for targets, and creates TargetChooser objects, which are the ones that help the application decide what target is valid or not. Look in particular for the class TargetChooserFactory
http://code.google.com/p/wagic/source/b ... hooser.cppWhen you add new hardcoded cards, you can ask yourself the following question:
- Is there another hardcoded card that does something similar ?
If so, should I simply copy/paste its code (generally the answer is NO), or try to create a new general class that can handle both cases (usually better) ? If I create a global class, how easy is it (and how interesting for users is it) to allow it to be manipulated through the parser and _cards.dat ?
If there is no similar hardcoded card, why is that ? The answer is generally that a deeper change in the code is required for these cards to work. An exemple is alternate costs (sacrifice, etc..) that require not only to code the card abilities themselves, but to code the associated GUI...
Here is the code for mind twist (MTGAbility.cpp).
- Code: Select all
case 1167: //Mind Twist
{
int xCost = spell->cost->getConvertedCost() - 1;
for (int i = 0; i < xCost; i++){
game->opponent()->game->discardRandom(game->opponent()->game->hand);
}
break;
}