fix and test Combo Attack

This commit is contained in:
xenohedron 2025-06-02 23:26:30 -04:00
parent 2ab7381b05
commit e1d082d776
2 changed files with 95 additions and 8 deletions

View file

@ -55,20 +55,21 @@ class ComboAttackEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
if (source.getTargets().size() < 2 || source.getTargets().get(0).getTargets().size() < 2) {
if (source.getTargets().size() < 2) {
return false;
}
Permanent permanent1 = game.getPermanent(source.getTargets().get(0).getTargets().get(0));
Permanent permanent2 = game.getPermanent(source.getTargets().get(0).getTargets().get(1));
Permanent permanent3 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent3 == null) {
return false;
}
if (permanent1 != null) {
permanent3.damage(permanent1.getPower().getValue(), permanent1.getId(), source, game, false, true);
}
if (permanent2 != null) {
permanent3.damage(permanent2.getPower().getValue(), permanent2.getId(), source, game, false, true);
// You cant cast Combo Attack without targeting two creatures your team controls.
// If one of those creatures is an illegal target as Combo Attack resolves,
// the other will still deal damage equal to its power. (2018-06-08)
for (UUID id : source.getTargets().get(0).getTargets()) {
Permanent permanent = game.getPermanent(id);
if (permanent != null) {
permanent3.damage(permanent.getPower().getValue(), permanent.getId(), source, game);
}
}
return true;
}

View file

@ -0,0 +1,86 @@
package org.mage.test.cards.single.bbd;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class ComboAttackTest extends CardTestPlayerBase {
/**
* {@link mage.cards.c.ComboAttack Combo Attack} {2}{G}
* Sorcery
* Two target creatures your team controls each deal damage equal to their power to target creature
*/
private static final String combo = "Combo Attack";
@Test
public void test_Normal() {
addCard(Zone.HAND, playerA, combo, 1);
addCard(Zone.BATTLEFIELD, playerA, "Memnite", 1);
addCard(Zone.BATTLEFIELD, playerA, "Runeclaw Bear", 1);
addCard(Zone.BATTLEFIELD, playerB, "Fortress Crab", 1);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, combo, "Memnite^Runeclaw Bear^Fortress Crab");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, combo, 1);
assertDamageReceived(playerB, "Fortress Crab", 3);
}
@Test
public void test_IllegalFirst() {
addCard(Zone.HAND, playerA, combo, 1);
addCard(Zone.BATTLEFIELD, playerA, "Memnite", 1);
addCard(Zone.BATTLEFIELD, playerA, "Runeclaw Bear", 1);
addCard(Zone.BATTLEFIELD, playerB, "Fortress Crab", 1);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.HAND, playerB, "Unsummon");
addCard(Zone.BATTLEFIELD, playerB, "Island");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, combo, "Memnite^Runeclaw Bear^Fortress Crab");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Unsummon", "Memnite", combo);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, combo, 1);
assertGraveyardCount(playerB, "Unsummon", 1);
assertHandCount(playerA, "Memnite", 1);
assertDamageReceived(playerB, "Fortress Crab", 2);
}
@Test
public void test_IllegalSecond() {
addCard(Zone.HAND, playerA, combo, 1);
addCard(Zone.BATTLEFIELD, playerA, "Memnite", 1);
addCard(Zone.BATTLEFIELD, playerA, "Runeclaw Bear", 1);
addCard(Zone.BATTLEFIELD, playerB, "Fortress Crab", 1);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Zone.HAND, playerB, "Unsummon");
addCard(Zone.BATTLEFIELD, playerB, "Island");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, combo, "Memnite^Runeclaw Bear^Fortress Crab");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Unsummon", "Runeclaw Bear", combo);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, combo, 1);
assertGraveyardCount(playerB, "Unsummon", 1);
assertHandCount(playerA, "Runeclaw Bear", 1);
assertDamageReceived(playerB, "Fortress Crab", 1);
}
}