Fix issue 563 (double strike VS regenerate)

-- also made "blocked" variable a private.
This commit is contained in:
wagic.the.homebrew
2011-10-10 12:29:52 +00:00
parent 9b2654997e
commit f0964d9af8
8 changed files with 14 additions and 10 deletions

View File

@@ -259,6 +259,7 @@ divergent_growth.txt
doomed_necromancer.txt
double_strike_i145.txt
double_strike2_i145.txt
double_strike_vs_regen_i563.txt
dragon_broodmother_i491.txt
dragon_fodder.txt
dragon_fodder2.txt

View File

@@ -19,8 +19,6 @@ Drudge skeletons
next
#damage first strike
next
#damage
next
#end of combat
[ASSERT]
COMBATEND

View File

@@ -458,7 +458,7 @@ public:
{
if (!notblocked->card->didattacked)
return 0;
if (notblocked->card->blocked)
if (notblocked->card->isBlocked())
return 0;
if (!tc->canTarget(notblocked->card))
return 0;
@@ -470,7 +470,7 @@ public:
{
if (!attackblocked->card->didattacked)
return 0;
if (!attackblocked->card->blocked)
if (!attackblocked->card->isBlocked())
return 0;
if (fromTc && !fromTc->canTarget(attackblocked->opponent))
return 0;

View File

@@ -30,6 +30,8 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable
#endif
{
private:
bool blocked; //Blocked this turn or not?
protected:
int untapping;
int nb_damages;
@@ -128,7 +130,7 @@ public:
//dangerranking is a hint to Ai which creatures are the ones it should be targetting for effects.
int DangerRanking();
//Combat
bool blocked; //Blocked this turn or not?
bool isBlocked() {return blocked;}; //Blocked this turn or not?
MTGCardInstance * defenser;
list<MTGCardInstance *>blockers;
int attacker;

View File

@@ -503,7 +503,7 @@ ExtraCost("Select unblocked attacker", _tc)
int Ninja::isPaymentSet()
{
if (target && ((target->isAttacker() && target->blocked) ||
if (target && ((target->isAttacker() && target->isBlocked()) ||
target->isAttacker() < 1 ||
target->getObserver()->getCurrentGamePhase() != Constants::MTG_PHASE_COMBATBLOCKERS))
{

View File

@@ -429,7 +429,7 @@ int GuiCombat::resolve() // Returns the number of damage objects dealt this turn
dmg -= (*q)->sumDamages();
}
if (dmg > 0 && ((!attacker->blocked) || attacker->has(Constants::TRAMPLE)))
if (dmg > 0 && ((!attacker->isBlocked()) || attacker->has(Constants::TRAMPLE)))
stack->Add(NEW Damage(observer, (*it)->card, observer->opponent(), dmg, DAMAGE_COMBAT));
for (vector<Damage>::iterator d = (*it)->damages.begin(); d != (*it)->damages.end(); ++d)
stack->Add(NEW Damage(*d));

View File

@@ -791,7 +791,10 @@ int MTGCardInstance::getDefenserRank(MTGCardInstance * blocker)
int MTGCardInstance::removeBlocker(MTGCardInstance * blocker)
{
blockers.remove(blocker);
if (!blockers.size())
// Blockers can be removed "manually" (by the blocking player) at the Blockers step,
// Or "automatically" in the damage phase, when they die and regenerate (see http://code.google.com/p/wagic/issues/detail?id=563 )
// In the second case, we still want the card to be marked as "blocked" this turn
if (!blockers.size() && observer->currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS)
{
blocked = false;
}

View File

@@ -1355,12 +1355,12 @@ int MTGCombatTriggersRule::receiveEvent(WEvent *e)
for (int i = 0; i < z->nb_cards; i++)
{
MTGCardInstance * card = z->cards[i];
if (card && card->isAttacker() && !card->blocked)
if (card && card->isAttacker() && !card->isBlocked())
{
card->eventattackednotblocked();
card->notblocked = 1;
}
if (card && card->isAttacker() && card->blocked)
if (card && card->isAttacker() && card->isBlocked())
{
MTGCardInstance * opponent = card->getNextOpponent();