* Fix the damage assignment interface to take Deathtouch into account.
* This addresses issue 32.
This commit is contained in:
jean.chalard
2009-12-16 15:29:44 +00:00
parent 28a5b3f490
commit aefc5f7b6e
+5 -3
View File
@@ -34,10 +34,8 @@ GuiCombat::~GuiCombat()
} }
for (inner_iterator it = attackers.begin(); it != attackers.end(); ++it) for (inner_iterator it = attackers.begin(); it != attackers.end(); ++it)
{
delete (*it); delete (*it);
} }
}
template <typename T> template <typename T>
static inline void repos(typename vector<T*>::iterator begin, typename vector<T*>::iterator end, signed size = -1) static inline void repos(typename vector<T*>::iterator begin, typename vector<T*>::iterator end, signed size = -1)
@@ -97,6 +95,7 @@ void GuiCombat::autoaffectDamage(AttackerDamaged* attacker, CombatStep step)
{ {
(*it)->clearDamage(); (*it)->clearDamage();
unsigned actual_damage = MIN(damage, (unsigned)MAX((*it)->card->toughness, 0)); unsigned actual_damage = MIN(damage, (unsigned)MAX((*it)->card->toughness, 0));
if (attacker->card->has(Constants::DEATHTOUCH) && actual_damage > 1) actual_damage = 1;
(*it)->addDamage(actual_damage, attacker); (*it)->addDamage(actual_damage, attacker);
attacker->addDamage((*it)->card->stepPower(step), *it); attacker->addDamage((*it)->card->stepPower(step), *it);
damage -= actual_damage; damage -= actual_damage;
@@ -118,7 +117,7 @@ void GuiCombat::removeOne(DefenserDamaged* blocker, CombatStep step)
{ {
blocker->addDamage(-1, activeAtk); blocker->addDamage(-1, activeAtk);
for (vector<DamagerDamaged*>::iterator it = activeAtk->blockers.begin(); it != activeAtk->blockers.end(); ++it) for (vector<DamagerDamaged*>::iterator it = activeAtk->blockers.begin(); it != activeAtk->blockers.end(); ++it)
if (!(*it)->hasLethalDamage()) { (*it)->addDamage(1, activeAtk); return; } if (activeAtk->card->has(Constants::DEATHTOUCH) ? ((*it)->sumDamages() < 1) : (!(*it)->hasLethalDamage())) { (*it)->addDamage(1, activeAtk); return; }
if (!activeAtk->card->has(Constants::TRAMPLE) && activeAtk->blockers.size() > 0) activeAtk->blockers.back()->addDamage(1, activeAtk); if (!activeAtk->card->has(Constants::TRAMPLE) && activeAtk->blockers.size() > 0) activeAtk->blockers.back()->addDamage(1, activeAtk);
} }
@@ -155,6 +154,9 @@ bool GuiCombat::CheckUserInput(u32 key)
signed now = active->sumDamages(); signed now = active->sumDamages();
damage -= now; damage -= now;
if (damage > 0) addOne(active, step); if (damage > 0) addOne(active, step);
else
if (activeAtk->card->has(Constants::DEATHTOUCH))
for (; now >= 1; --now) removeOne(active, step);
else else
for (now -= active->card->toughness; now >= 0; --now) removeOne(active, step); for (now -= active->card->toughness; now >= 0; --now) removeOne(active, step);
} }