- Adding equipments. They work like auras, except you have to add an "auto={cost}:equip" line. See Behemoth sledge in ARB for an example. Please test a lot before committing, thanks :)
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-12-10 13:44:05 +00:00
parent 86ad1ef8c7
commit ca35754273
12 changed files with 298 additions and 25 deletions

View File

@@ -945,6 +945,76 @@ class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{
};
class AEquip:public TargetAbility{
public:
vector<MTGAbility *> currentAbilities;
AEquip(int _id, MTGCardInstance * _source, ManaCost * _cost=NULL, int doTap=0, int myturnOnly = 1):TargetAbility(_id,_source,NULL,_cost,myturnOnly,doTap){
}
int unequip(){
source->target = NULL;
for (size_t i = 0; i < currentAbilities.size(); ++i){
MTGAbility * a = currentAbilities[i];
if(dynamic_cast<AEquip *>(a)){
SAFE_DELETE(a);
continue;
}
GameObserver::GetInstance()->removeObserver(currentAbilities[i]);
}
currentAbilities.clear();
return 1;
}
int equip(MTGCardInstance * equipped){
source->target = equipped;
AbilityFactory af;
af.getAbilities(&currentAbilities,NULL,source);
for (size_t i = 0; i < currentAbilities.size(); ++i){
MTGAbility * a = currentAbilities[i];
if(dynamic_cast<AEquip *>(a)) continue;
a->addToGame();
}
return 1;
}
int resolve(){
MTGCardInstance * mTarget = tc->getNextCardTarget();
if (!mTarget) return 0;
if (mTarget == source) return 0;
unequip();
equip(mTarget);
return 1;
}
const char * getMenuText(){
return "Equip";
}
int testDestroy(){
if (source->target && !game->isInPlay(source->target))
unequip();
return TargetAbility::testDestroy();
}
int destroy(){
unequip();
return TargetAbility::destroy();
}
AEquip * clone() const{
AEquip * a = NEW AEquip(*this);
a->isClone = 1;
return a;
}
};
/*Gives life each time a spell matching CardDescriptor's criteria are match . Optionnal manacost*/
class ASpellCastLife:public MTGAbility{

View File

@@ -203,6 +203,7 @@ class AbilityFactory{
int parsePowerToughness(string s, int *power, int *toughness);
TriggeredAbility * parseTrigger(string s, int id, Spell * spell, MTGCardInstance *card, Targetable * target);
public:
int getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCardInstance * card = NULL, int id = 0);
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0);
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);