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:
@@ -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){
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../include/GameObserver.h"
|
||||
#include "../include/Subtypes.h"
|
||||
#include "../include/Counters.h"
|
||||
|
||||
#include "../include/WEvent.h"
|
||||
|
||||
|
||||
TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInstance * card, MTGAbility * ability){
|
||||
@@ -29,6 +29,16 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
s=s.substr(6);
|
||||
}
|
||||
|
||||
found = s.find("trigger");
|
||||
if (found == 0){
|
||||
if (s.length() > 7 && s.find("[") == 7) {
|
||||
string s1 = s.substr(7,s.find("]"));
|
||||
if (s1.find("to") != string::npos) return NEW TriggerTargetChooser(WEvent::TARGET_TO);
|
||||
if (s1.find("from") != string::npos) return NEW TriggerTargetChooser(WEvent::TARGET_FROM);
|
||||
}
|
||||
return NEW TriggerTargetChooser(1);
|
||||
}
|
||||
|
||||
found = s.find("player");
|
||||
if (found != string::npos){
|
||||
int maxtargets = 1;
|
||||
@@ -761,3 +771,22 @@ bool DamageTargetChooser::canTarget(Targetable * target){
|
||||
DamageTargetChooser * a = NEW DamageTargetChooser(*this);
|
||||
return a;
|
||||
}
|
||||
|
||||
TriggerTargetChooser::TriggerTargetChooser(int _triggerTarget){
|
||||
triggerTarget = _triggerTarget;
|
||||
target = NULL;
|
||||
}
|
||||
|
||||
bool TriggerTargetChooser::targetsZone(MTGGameZone * z){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TriggerTargetChooser::canTarget(Targetable * _target){
|
||||
if (_target == target) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
TriggerTargetChooser * TriggerTargetChooser::clone() const{
|
||||
TriggerTargetChooser * a = NEW TriggerTargetChooser(*this);
|
||||
return a;
|
||||
}
|
||||
@@ -30,6 +30,30 @@ WEventEmptyManaPool::WEventEmptyManaPool(ManaPool * source) : WEvent(), source(s
|
||||
|
||||
WEventCombatStepChange::WEventCombatStepChange(CombatStep step) : WEvent(), step(step) {};
|
||||
|
||||
Targetable * WEventDamage::getTarget(int target) {
|
||||
switch (target) {
|
||||
case TARGET_TO :
|
||||
return damage->target;
|
||||
case TARGET_FROM :
|
||||
return damage->source;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int WEventDamage::getValue() {
|
||||
return damage->damage;
|
||||
}
|
||||
|
||||
Targetable * WEventZoneChange::getTarget(int target) {
|
||||
if (target) return card;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardTap::getTarget(int target){
|
||||
if (target) return card;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::ostream& WEvent::toString(std::ostream& out) const
|
||||
{
|
||||
return out << "EVENT";
|
||||
|
||||
Reference in New Issue
Block a user