* Fixed a problem if some of multiple targets can't be targeted during resolution (e.g. target got hexproof meanwhile) it was still targeted (e.g. it happens for INto the void).

This commit is contained in:
LevelX2 2013-12-07 15:51:10 +01:00
parent 8cf788e9cc
commit 80fc87a7f7
3 changed files with 96 additions and 15 deletions

View file

@ -61,23 +61,27 @@
</dependencies> </dependencies>
<build> <build>
<plugins> <pluginManagement>
<plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <version>2.16</version>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-resources-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<configuration> <artifactId>maven-compiler-plugin</artifactId>
<encoding>UTF-8</encoding> <version>3.1</version>
</configuration>
</plugin> </plugin>
</plugins> <plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>mage-tests</finalName> <finalName>mage-tests</finalName>
</build> </build>

View file

@ -0,0 +1,69 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.test.cards.abilities.keywords;
import mage.abilities.keyword.HexproofAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class HexproofTest extends CardTestPlayerBase {
/**
* Tests one target gets hexproof
*/
@Test
public void testOneTargetOneGainingHexproof() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, "Elder of Laurels");
addCard(Zone.HAND, playerA, "Ranger's Guile");
addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
addCard(Zone.HAND, playerB, "Into the Void");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Into the Void", "Elder of Laurels");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Ranger's Guile", "Elder of Laurels");
setStopAt(2, PhaseStep.END_TURN);
execute();
// because of hexproof the Elder should be onto the battlefield
assertPermanentCount(playerA, "Elder of Laurels", 1);
assertPowerToughness(playerA, "Elder of Laurels", 3, 4);
assertAbility(playerA, "Elder of Laurels", HexproofAbility.getInstance(), true);
}
/**
* Tests one target gets hexproof
*/
@Test
public void testTwoTargetsOneGainingHexproof() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, "Elder of Laurels");
addCard(Zone.BATTLEFIELD, playerA, "Arbor Elf");
addCard(Zone.HAND, playerA, "Ranger's Guile");
addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
addCard(Zone.HAND, playerB, "Into the Void");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Into the Void", "Elder of Laurels^Arbor Elf");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Ranger's Guile", "Elder of Laurels");
setStopAt(2, PhaseStep.END_TURN);
execute();
// because of hexproof the Elder should be onto the battlefield
assertPermanentCount(playerA, "Elder of Laurels", 1);
assertPowerToughness(playerA, "Elder of Laurels", 3, 4);
assertAbility(playerA, "Elder of Laurels", HexproofAbility.getInstance(), true);
assertPermanentCount(playerA, "Arbor Elf", 0);
}
}

View file

@ -1,10 +1,14 @@
package mage.target.targetpointer; package mage.target.targetpointer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.cards.Card; import mage.cards.Card;
import mage.game.Game; import mage.game.Game;
import mage.target.Target;
import java.util.*;
public class FirstTargetPointer implements TargetPointer { public class FirstTargetPointer implements TargetPointer {
@ -40,12 +44,16 @@ public class FirstTargetPointer implements TargetPointer {
public List<UUID> getTargets(Game game, Ability source) { public List<UUID> getTargets(Game game, Ability source) {
ArrayList<UUID> target = new ArrayList<UUID>(); ArrayList<UUID> target = new ArrayList<UUID>();
if (source.getTargets().size() > 0) { if (source.getTargets().size() > 0) {
Target currentTarget = source.getTargets().get(0);
for (UUID targetId : source.getTargets().get(0).getTargets()) { for (UUID targetId : source.getTargets().get(0).getTargets()) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card != null && zoneChangeCounter.containsKey(targetId) if (card != null && zoneChangeCounter.containsKey(targetId)
&& card.getZoneChangeCounter() != zoneChangeCounter.get(targetId)) { && card.getZoneChangeCounter() != zoneChangeCounter.get(targetId)) {
continue; continue;
} }
if (!currentTarget.canTarget(targetId, source, game)) {
continue;
}
target.add(targetId); target.add(targetId);
} }
} }