From 4dfacaa4091b7add84d9e45a52274ace56dcd45b Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Sun, 1 Apr 2012 17:39:41 +0000 Subject: [PATCH] untap target as cost. --- projects/mtg/include/ExtraCost.h | 9 +++++++ projects/mtg/src/ExtraCost.cpp | 43 ++++++++++++++++++++++++++++++++ projects/mtg/src/ManaCost.cpp | 7 +++++- 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/projects/mtg/include/ExtraCost.h b/projects/mtg/include/ExtraCost.h index c7e9b0b7a..432b01c63 100644 --- a/projects/mtg/include/ExtraCost.h +++ b/projects/mtg/include/ExtraCost.h @@ -173,6 +173,15 @@ public: virtual int doPay(); virtual TapTargetCost * clone() const; }; +//untap a target as cost +class UnTapTargetCost : public ExtraCost +{ +public: + UnTapTargetCost(TargetChooser *_tc = NULL); + virtual int isPaymentSet(); + virtual int doPay(); + virtual UnTapTargetCost * clone() const; +}; //exile as cost class ExileTargetCost : public ExtraCost diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 8d233828d..5ebf54b85 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -469,6 +469,49 @@ int TapTargetCost::doPay() return 0; } +//untap other as a cost +UnTapTargetCost * UnTapTargetCost::clone() const +{ + UnTapTargetCost * ec = NEW UnTapTargetCost(*this); + if (tc) + ec->tc = tc->clone(); + return ec; +} + +UnTapTargetCost::UnTapTargetCost(TargetChooser *_tc) + : ExtraCost("Untap Target", _tc) +{ +} + +int UnTapTargetCost::isPaymentSet() +{ + if (target && !target->isTapped()) + { + tc->removeTarget(target); + target->isExtraCostTarget = false; + target = NULL; + return 0; + } + if (target) + return 1; + return 0; +} + +int UnTapTargetCost::doPay() +{ + MTGCardInstance * _target = (MTGCardInstance *) target; + source->storedCard = target; + if (target) + { + _target->untap(); + target = NULL; + if (tc) + tc->initTargets(); + return 1; + } + return 0; +} + //exile as cost ExileTargetCost * ExileTargetCost::clone() const { diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 8b1736e7d..92f144559 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -159,10 +159,15 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan break; } case 'q': + if(value == "q") { manaCost->addExtraCost(NEW UnTapCost); - break; } + else + { + manaCost->addExtraCost(NEW UnTapTargetCost(tc)); + } + break; case 'c': //Counters or cycle { if(value == "chosencolor")