mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
fix and test Combo Attack
This commit is contained in:
parent
2ab7381b05
commit
e1d082d776
2 changed files with 95 additions and 8 deletions
|
|
@ -55,20 +55,21 @@ class ComboAttackEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
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;
|
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());
|
Permanent permanent3 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||||
if (permanent3 == null) {
|
if (permanent3 == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (permanent1 != null) {
|
// You can’t cast Combo Attack without targeting two creatures your team controls.
|
||||||
permanent3.damage(permanent1.getPower().getValue(), permanent1.getId(), source, game, false, true);
|
// 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);
|
||||||
}
|
}
|
||||||
if (permanent2 != null) {
|
|
||||||
permanent3.damage(permanent2.getPower().getValue(), permanent2.getId(), source, game, false, true);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue