Fixed bug with preventing Melira from putting +1/+1 counters on creatures you control

This commit is contained in:
Dmitry Panin
2013-10-22 14:30:59 +04:00
parent f0977ebc04
commit 461eedd626
4 changed files with 62 additions and 20 deletions
+1
View File
@@ -233,6 +233,7 @@ control_magic3.txt
control_magic4.txt control_magic4.txt
corrupt.txt corrupt.txt
counsel_of_the_soratami.txt counsel_of_the_soratami.txt
countershroud.txt
counterspell.txt counterspell.txt
counterspell2.txt counterspell2.txt
counterspell3.txt counterspell3.txt
@@ -0,0 +1,36 @@
# Testing Melira, Sylvok Outcast (keyword "countershroud")
# Melira, Sylvok Outcast
# id=194274
# 2/2
# You can't get poison counters. Creatures you control can't have -1/-1 counters placed on them. Creatures your opponents control lose infect.
[INIT]
FIRSTMAIN
[PLAYER1]
inplay:194274,grizzly bears,Gavony Township
manapool:{2}{W}{G}
[PLAYER2]
[DO]
Gavony Township
choice 1
next
#combatbegins
next
#attackers
194274
grizzly bears
next
#blockers
next
#combatdamage
next
#combatend
[ASSERT]
COMBATEND
[PLAYER1]
inplay:194274,grizzly bears,Gavony Township
manapool:{0}
[PLAYER2]
life:14
[END]
+4 -2
View File
@@ -42,13 +42,15 @@ protected:
MTGAbility * source; MTGAbility * source;
MTGCardInstance * cardSource; MTGCardInstance * cardSource;
MTGCardInstance * cardTarget; MTGCardInstance * cardTarget;
TargetChooser * TargetingCards; TargetChooser * tc;
Counter * counter; Counter * counter;
public: public:
RECountersPrevention(MTGAbility * _source,MTGCardInstance * cardSource = NULL,MTGCardInstance * cardTarget = NULL,TargetChooser * tc = NULL,Counter * counter = NULL); RECountersPrevention(MTGAbility * _source, MTGCardInstance * cardSource = NULL,
MTGCardInstance * cardTarget = NULL, TargetChooser * tc = NULL, Counter * counter = NULL);
WEvent * replace(WEvent *e); WEvent * replace(WEvent *e);
~RECountersPrevention(); ~RECountersPrevention();
}; };
class REDrawReplacement: public ReplacementEffect class REDrawReplacement: public ReplacementEffect
{ {
protected: protected:
+13 -10
View File
@@ -49,8 +49,9 @@ REDamagePrevention::~REDamagePrevention()
SAFE_DELETE(tcTarget); SAFE_DELETE(tcTarget);
} }
//counters replacement effect/////////////////// //counters replacement effect///////////////////
RECountersPrevention::RECountersPrevention(MTGAbility * source,MTGCardInstance * cardSource,MTGCardInstance * cardTarget,TargetChooser * tc,Counter * counter) : RECountersPrevention::RECountersPrevention(MTGAbility * source, MTGCardInstance * cardSource,
source(source),cardSource(cardSource),cardTarget(cardTarget),TargetingCards(tc),counter(counter) MTGCardInstance * cardTarget, TargetChooser * tc, Counter * counter) :
source(source), cardSource(cardSource), cardTarget(cardTarget), tc(tc), counter(counter)
{ {
} }
@@ -59,23 +60,25 @@ RECountersPrevention::RECountersPrevention(MTGAbility * source,MTGCardInstance *
if (!event) return event; if (!event) return event;
WEventCounters * e = dynamic_cast<WEventCounters*> (event); WEventCounters * e = dynamic_cast<WEventCounters*> (event);
if (!e) return event; if (!e) return event;
if((MTGCardInstance*)e->targetCard) MTGCardInstance * target = e->targetCard;
if (target)
{ {
if((MTGCardInstance*)e->targetCard == cardSource && counter) if (target == cardSource || (tc && tc->canTarget(target)))
{ {
// counter == NULL means "any counter"
if (!counter)
return NULL;
if (e->power == counter->power && e->toughness == counter->toughness && e->name == counter->name) if (e->power == counter->power && e->toughness == counter->toughness && e->name == counter->name)
return event = NULL; return NULL;
} }
else if((MTGCardInstance*)e->targetCard == cardSource)
return event = NULL;
else if(TargetingCards && TargetingCards->canTarget((MTGCardInstance*)e->targetCard))
return event = NULL;
} }
return event; return event;
} }
RECountersPrevention::~RECountersPrevention() RECountersPrevention::~RECountersPrevention()
{ {
SAFE_DELETE(TargetingCards); SAFE_DELETE(tc);
} }
////--draw replacement--------------------- ////--draw replacement---------------------
REDrawReplacement::REDrawReplacement(MTGAbility * source, Player * Drawer, MTGAbility * replaceWith) : REDrawReplacement::REDrawReplacement(MTGAbility * source, Player * Drawer, MTGAbility * replaceWith) :