diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index c84186626..e11a8ab14 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -84,13 +84,17 @@ public: } else if (s.find("type:") != string::npos) { - size_t begins = s.find(":"); - string theType = s.substr(begins + 1); - size_t zoned = theType.find("|"); + size_t begins = s.find("type:"); + string theType = s.substr(begins + 5); + size_t zoned = theType.find(":"); if(zoned == string::npos) { theType.append("|mybattlefield"); } + else + { + replace(theType.begin(), theType.end(), ':', '|'); + } TargetChooserFactory tf; TargetChooser * tc = tf.createTargetChooser(theType.c_str(),NULL); GameObserver * game = game->GetInstance(); @@ -4089,7 +4093,8 @@ public: int currentage; AUpkeep(int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, int _tap = 0, int restrictions = 0, int _phase = - Constants::MTG_PHASE_UPKEEP, int _once = 0,bool Cumulative = false); + Constants::MTG_PHASE_UPKEEP, int _once = 0,bool Cumulative = false); + int receiveEvent(WEvent * event); void Update(float dt); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int resolve(); diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index bbe9e9206..37b138f2d 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2921,6 +2921,21 @@ AUpkeep::AUpkeep(int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _co aType = MTGAbility::UPCOST; } + int AUpkeep::receiveEvent(WEvent * event) + { + if (WEventPhaseChange* pe = dynamic_cast(event)) + { + if (Constants::MTG_PHASE_DRAW == pe->to->id) + { + if (source->controller() == game->currentPlayer && once < 2 && paidThisTurn < 1) + { + ability->resolve(); + } + } + } + return 1; + } + void AUpkeep::Update(float dt) { // once: 0 means always go off, 1 means go off only once, 2 means go off only once and already has. @@ -2944,10 +2959,6 @@ void AUpkeep::Update(float dt) if(currentage) paidThisTurn -= currentage; } - else if (newPhase == phase + 1 && paidThisTurn < 1) - { - ability->resolve(); - } if (newPhase == phase + 1 && once) once = 2; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 43cb3b578..d38796db6 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1136,18 +1136,20 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG if (found != string::npos) { SAFE_DELETE(tc); - string s1 = s.substr(0, found); - string s2 = s.substr(found + 2); + vector multiEffects = split(s,'&'); MultiAbility * multi = NEW MultiAbility(id, card, target, NULL, NULL); - MTGAbility * a1 = parseMagicLine(s1, id, spell, card, activated); - MTGAbility * a2 = parseMagicLine(s2, id, spell, card, activated); - multi->Add(a1); - multi->Add(a2); + for(unsigned int i = 0;i < multiEffects.size();i++) + { + if(!multiEffects[i].empty()) + { + MTGAbility * addAbility = parseMagicLine(multiEffects[i], id, spell, card, activated); + multi->Add(addAbility); + } + } multi->oneShot = 1; return multi; } - //rather dirty way to stop thises and lords from conflicting with each other. size_t lord = string::npos; for (size_t j = 0; j < kLordKeywordsCount; ++j)