added {unattach} cost

this can also be used for "equipped creature has unattach and blah" cards using 
auto=teach(creature) {unattach}:blah

also corrected a long standing guiupdating issue. a long long time ago a replace was removed from GuiPlay::Update in hopes to increase performance no amount of performance increase is worth having cards not updating thier position after an event recieve happens. this means curse will finally go to the correctly choosen players battlefield, equipment will no longer just linger after its target dies, auras won't stay on battlefield after a card is exiled. ect. no preformance decrease noticed, if anyone else notices one let me know.
This commit is contained in:
omegablast2002@yahoo.com
2013-01-05 03:05:53 +00:00
parent 2fa626b80e
commit 4960969640
4 changed files with 70 additions and 2 deletions

View File

@@ -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
{

View File

@@ -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<AEquip*> (a);
if (eq && eq->source == _source)
{
((AEquip*)a)->unequip();
}
}
return 1;
}
return 0;
}
//Tap cost
TapCost * TapCost::clone() const

View File

@@ -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<WEventCardChangeType*> (e))
Replace();
Replace();
return 0;
}

View File

@@ -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];