From 385a48bb431c1338bff8fe9f5d8055670e536e9c Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sat, 2 Jul 2016 22:39:45 -0400 Subject: [PATCH] fixed a bug where {t}{s(creature|mybattlefield)} or similar cost were not allowed to select the source to pay for the cost. as long as the cost are not similar, the source is a valid target. {s}{s(creature|mybattlefield)} or {t}{t(creature)} or when the card states specifically that the source is not valid such as "{t},sacrifice another creature you control:draw a card" --- projects/mtg/src/ExtraCost.cpp | 39 ++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index b45732e70..6c67d138f 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -966,6 +966,7 @@ int Convoke::isPaymentSet() SAFE_DELETE(toReduce); return 1; } + SAFE_DELETE(toReduce); return 0; } @@ -1085,6 +1086,7 @@ int Delve::isPaymentSet() SAFE_DELETE(toReduce); return 1; } + SAFE_DELETE(toReduce); return 0; } @@ -1400,8 +1402,41 @@ int ExtraCosts::tryToSetPayment(MTGCardInstance * card) { for(size_t k = 0; k < costs.size(); k++) { - if(card == costs[k]->target) - return 0; + if (card == costs[k]->target) + { + //tapping or sacrificing a target to pay for its own cost + //is allowed, unless the source is already being tapped and contains a tap target + //or sacced and contains a sactarget + //cost like {t}{s(creature)} the source is allowed to be targeted for this + //if it is a creature. these cases below should be added whenever we a need + //for extra cost that have both a source and target version used on cards. + if (dynamic_cast(costs[k])) + { + for (size_t tapCheck = 0; tapCheck < costs.size(); tapCheck++) + { + if (dynamic_cast(costs[tapCheck])) + { + return 0;//{t}{t(creature)} + } + } + + } + else if (SacrificeCost * checking = dynamic_cast(costs[k])) + { + for (size_t sacCheck = 0; sacCheck < costs.size(); sacCheck++) + { + SacrificeCost * checking2 = dynamic_cast(costs[sacCheck]); + if (checking2) + if ((checking->tc != NULL && checking2->tc == NULL) + || (checking->tc == NULL && checking2->tc != NULL)) + { + return 0; //{s}{s(creature)} + } + } + } + else + return 0; + } } if (int result = costs[i]->setPayment(card)) {