From 92d52a78be4293cf8b205a5a98accd90037faad3 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 27 Nov 2014 14:33:43 +0800 Subject: [PATCH] Update ExtraCost.cpp --- projects/mtg/src/ExtraCost.cpp | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 9abe359a1..37b398807 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -151,6 +151,44 @@ int LifeCost::doPay() return 1; } +//Specific life cost +SpecificLifeCost * SpecificLifeCost::clone() const +{ + SpecificLifeCost * ec = NEW SpecificLifeCost(*this); + if (tc) + ec->tc = tc->clone(); + return ec; +} + +SpecificLifeCost::SpecificLifeCost(TargetChooser *_tc, int slc) + : ExtraCost("Life", _tc), slc(slc) +{ +} + +int SpecificLifeCost::canPay() +{ + MTGCardInstance * _target = (MTGCardInstance *) target; + if(_target->controller()->life >= slc) + { + return 1; + } + return 0; +} + +int SpecificLifeCost::doPay() +{ + if (!target) + return 0; + + MTGCardInstance * _target = (MTGCardInstance *) target; + + _target->controller()->loseLife(slc); + target = NULL; + if (tc) + tc->initTargets(); + return 1; +} + //life or Mana cost LifeorManaCost * LifeorManaCost::clone() const {