diff --git a/projects/mtg/include/ExtraCost.h b/projects/mtg/include/ExtraCost.h index 432b01c63..c0db8f3f4 100644 --- a/projects/mtg/include/ExtraCost.h +++ b/projects/mtg/include/ExtraCost.h @@ -142,6 +142,17 @@ public: virtual int doPay(); }; +//unattach cost +class unattachCost : public ExtraCost +{ +public: + unattachCost(MTGCardInstance * realSource = NULL); + MTGCardInstance * rSource; + virtual int isPaymentSet(); + virtual int canPay(); + virtual int doPay(); + virtual unattachCost * clone() const; +}; //tap cost class TapCost : public ExtraCost { diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 2cb204bce..07912812d 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -6,6 +6,7 @@ #include "Translate.h" #include "Player.h" #include "Counters.h" +#include "AllAbilities.h" SUPPORT_OBJECT_ANALYTICS(ExtraCost) @@ -329,6 +330,7 @@ int MillCost::doPay() return 0; } + MillExileCost::MillExileCost(TargetChooser *_tc) : MillCost(_tc) { @@ -352,6 +354,54 @@ int MillExileCost::doPay() } return 0; } +//unattach cost + +unattachCost * unattachCost::clone() const +{ + unattachCost * ec = NEW unattachCost(*this); + return ec; +} + +unattachCost::unattachCost(MTGCardInstance * realSource) + : ExtraCost("Unattach"),rSource(realSource) +{ +} + +int unattachCost::isPaymentSet() +{ + if (rSource && !rSource->target) + { + return 0; + } + return 1; +} + +int unattachCost::canPay() +{ + return isPaymentSet(); +} + +int unattachCost::doPay() +{ + MTGCardInstance * _source = (MTGCardInstance *) source; + if(_source != rSource) + _source = rSource;//for debugging purposes I let it set what it thinks is the source. + if (_source) + { + GameObserver * game = _source->getObserver(); + for (size_t i = 1; i < game->mLayers->actionLayer()->mObjects.size(); i++) + { + MTGAbility * a = ((MTGAbility *) game->mLayers->actionLayer()->mObjects[i]); + AEquip * eq = dynamic_cast (a); + if (eq && eq->source == _source) + { + ((AEquip*)a)->unequip(); + } + } + return 1; + } + return 0; +} //Tap cost TapCost * TapCost::clone() const diff --git a/projects/mtg/src/GuiPlay.cpp b/projects/mtg/src/GuiPlay.cpp index ffd00a833..471f96735 100644 --- a/projects/mtg/src/GuiPlay.cpp +++ b/projects/mtg/src/GuiPlay.cpp @@ -284,6 +284,7 @@ void GuiPlay::Render() battleField.Render(); for (iterator it = cards.begin(); it != cards.end(); ++it) + { if ((*it)->card->isLand()) { if (observer->players[0] == (*it)->card->controller()) @@ -318,7 +319,7 @@ void GuiPlay::Render() opponentPlaneswalker.Render(*it, cards.begin(), end_spells); } } - + } } void GuiPlay::Update(float dt) { @@ -404,6 +405,7 @@ int GuiPlay::receiveEventPlus(WEvent * e) } else if (dynamic_cast (e)) Replace(); + Replace(); return 0; } diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index c0596278d..388d8d73b 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -229,8 +229,13 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan } break; } - default: //uncolored cost and hybrid costs + default: //uncolored cost and hybrid costs and special cost { + if(value == "unattach") + { + manaCost->addExtraCost(NEW unattachCost(c)); + break; + } int intvalue = atoi(value.c_str()); int colors[2]; int values[2];