added ability to have triggered abilities target based on the event that triggered, bramblewood paragon, graft, etc.

use "trigger" inside target code of triggered ability.
does not work with @each and @next.
@damaged can use trigger[to] and trigger[from] to specify the target or source of the damage, respectively.

Adds cards:
Aether Flash
Bramblewood Paragon
In the Web of War
Juniper Order Ranger
Mortuary
Primal Forcemage
Fungus Sliver
Simic Initiate

as well as a test file for feral hydra, missing from my last commit.
and daily build.
This commit is contained in:
salmelo16
2010-04-03 23:50:39 +00:00
parent b9d82a55c7
commit 9cf4c7587b
17 changed files with 376 additions and 42 deletions
+32 -8
View File
@@ -223,7 +223,7 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a){
}
//Parses a string and returns the corresponding MTGAbility object
// Returns NULL if parsing failed
//Returns NULL if parsing failed
//Beware, Spell CAN be null when the function is called by the AI trying to analyze the effects of a given card
MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated, int forceUEOT, MTGGameZone * dest){
size_t found;
@@ -1805,6 +1805,10 @@ ostream& MTGAbility::toString(ostream& out) const
<< " ; source : " << source;
}
NestedAbility::NestedAbility(MTGAbility * _ability){
ability = _ability;
}
//
ActivatedAbility::ActivatedAbility(int id, MTGCardInstance * card, ManaCost * _cost, int restrictions,int tap):MTGAbility(id,card), restrictions(restrictions), needsTapping(tap){
@@ -1893,14 +1897,12 @@ ostream& ActivatedAbility::toString(ostream& out) const
}
TargetAbility::TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost, int _playerturnonly,int tap):ActivatedAbility(id, card,_cost,_playerturnonly, tap){
TargetAbility::TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost, int _playerturnonly,int tap):ActivatedAbility(id, card,_cost,_playerturnonly, tap), NestedAbility(NULL){
tc = _tc;
ability = NULL;
}
TargetAbility::TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost, int _playerturnonly,int tap):ActivatedAbility(id, card,_cost,_playerturnonly, tap){
TargetAbility::TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost, int _playerturnonly,int tap):ActivatedAbility(id, card,_cost,_playerturnonly, tap), NestedAbility(NULL){
tc = NULL;
ability = NULL;
}
@@ -2187,10 +2189,9 @@ TriggerNextPhase* TriggerNextPhase::clone() const{
return a;
}
GenericTriggeredAbility::GenericTriggeredAbility(int id, MTGCardInstance * _source, TriggeredAbility * _t, MTGAbility * a , MTGAbility * dc, Targetable * _target ): TriggeredAbility(id, _source,_target){
GenericTriggeredAbility::GenericTriggeredAbility(int id, MTGCardInstance * _source, TriggeredAbility * _t, MTGAbility * a , MTGAbility * dc, Targetable * _target ): TriggeredAbility(id, _source,_target), NestedAbility(a){
if (!target) target = source;
t = _t;
ability = a;
destroyCondition = dc;
t->source = source;
@@ -2209,7 +2210,30 @@ int GenericTriggeredAbility::trigger(){
int GenericTriggeredAbility::triggerOnEvent(WEvent * e){
return t->triggerOnEvent(e);
if (t->triggerOnEvent(e)) {
setTriggerTargets(e,ability);
return 1;
}
return 0;
}
void GenericTriggeredAbility::setTriggerTargets(WEvent * e,MTGAbility * a){
TriggerTargetChooser * ttc = dynamic_cast<TriggerTargetChooser *>(a->tc);
if (ttc) {
a->target = e->getTarget(ttc->triggerTarget);
ttc->target = e->getTarget(ttc->triggerTarget);
}
NestedAbility * na = dynamic_cast<NestedAbility *>(a);
if (na) setTriggerTargets(e,na->ability);
MultiAbility * ma = dynamic_cast<MultiAbility *>(a);
if (ma) {
for (int i = 0; i < ma->abilities.size(); i++) {
setTriggerTargets(e,ma->abilities[i]);
}
}
}
void GenericTriggeredAbility::Update(float dt){