From 5a3493c0c95a0980223ebbf250cf134d902b6bec Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Tue, 28 Feb 2017 16:19:59 +0800 Subject: [PATCH] update spelltargettype --- projects/mtg/src/AllAbilities.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 3a73ba7d4..99236b420 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -8046,10 +8046,25 @@ void AACastCard::Update(float dt) toCheck = theNamedCard; if(toCheck && toCheck->spellTargetType.size()) { + string backupST = toCheck->spellTargetType; + if((toCheck->spellTargetType == "opponent") && (toCheck->owner != source->controller())) + toCheck->spellTargetType = "controller"; + else if((toCheck->spellTargetType.find("|opponent") != string::npos) && (toCheck->owner != source->controller())) + { + string replaceMe = backupST; + toCheck->spellTargetType = cReplaceString(replaceMe, "|opponent", "|my"); + } + //Since we control the card to cast, if the card should target an opponent, + //direct it to source ability controller->opponent + //example card is Bribery, if we cast it targeting from opponent's library, + //we should target the source ability controller->opponent + TargetChooserFactory tcf(game); TargetChooser * stc = tcf.createTargetChooser(toCheck->spellTargetType,toCheck); if (!stc->validTargetsExist()||toCheck->isToken) { + toCheck->spellTargetType = backupST; + processed = true; this->forceDestroy = 1; return;