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

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