From 52fb40d543c1d0884b011c6f64d2699ba8b31661 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 4 Aug 2016 02:12:59 +0800 Subject: [PATCH] AACloner & AACopier TokenAndAbility if the token has andAbility, the cloner/copier also has that andAbility also... --- projects/mtg/include/AllAbilities.h | 2 ++ projects/mtg/include/MTGCardInstance.h | 1 + projects/mtg/src/AllAbilities.cpp | 28 ++++++++++++++++++++++++++ projects/mtg/src/MTGCardInstance.cpp | 1 + 4 files changed, 32 insertions(+) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index ca760653f..1e60a6932 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3692,6 +3692,8 @@ public: //andability if(andAbility) { + //backup andAbility for copier and cloner + spell->source->TokenAndAbility = andAbility->clone(); MTGAbility * andAbilityClone = andAbility->clone(); andAbilityClone->target = spell->source; if(andAbility->oneShot) diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index aad75beaa..cd18151a5 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -121,6 +121,7 @@ public: MTGGameZone * previousZone; MTGCardInstance * previous; MTGCardInstance * next; + MTGAbility * TokenAndAbility; int doDamageTest; bool skipDamageTestOnce; int summoningSickness; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index a18f28b0f..667396db5 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1503,6 +1503,20 @@ int AACopier::resolve() source->basicAbilities.reset(); source->getManaCost()->resetCosts(); } + if(_target->TokenAndAbility) + {//the source copied a token with andAbility + MTGAbility * andAbilityClone = _target->TokenAndAbility->clone(); + andAbilityClone->target = source; + if(_target->TokenAndAbility->oneShot) + { + andAbilityClone->resolve(); + SAFE_DELETE(andAbilityClone); + } + else + { + andAbilityClone->addToGame(); + } + } return 1; } return 0; @@ -3971,6 +3985,20 @@ int AACloner::resolve() if(_target->model->data->basicAbilities[k]) spell->source->basicAbilities[k] = _target->model->data->basicAbilities[k]; } + if(_target->TokenAndAbility) + {//the source copied a token with andAbility + MTGAbility * andAbilityClone = _target->TokenAndAbility->clone(); + andAbilityClone->target = spell->source; + if(_target->TokenAndAbility->oneShot) + { + andAbilityClone->resolve(); + SAFE_DELETE(andAbilityClone); + } + else + { + andAbilityClone->addToGame(); + } + } delete spell; } return 1; diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 1c0e85162..fdb37698d 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -265,6 +265,7 @@ void MTGCardInstance::initMTGCI() previousZone = NULL; previous = NULL; next = NULL; + TokenAndAbility = NULL; lastController = NULL; regenerateTokens = 0; blocked = false;